function GM_Mat=DCGModel(O,D,fc,delta)
%This function solves the doubly constrained gravity model during trip
%distribution
%O input vector of traffic demand in each zone
%D input vector of trip end in each zone
%fc input travel impedance function
%GM_Mat output trip distribution matrix of the input OD zone
%% index initialization
m=size(O,2);
%define vectors of factor a and b with first iteration(fi) and next
%iteration(ni) respectively
a_fi=zeros(1,size(O,2));
b_fi=zeros(1,size(D,2));
a_ni=zeros(1,size(O,2));
b_ni=zeros(1,size(D,2));
%first let all elements in a_fi=1
a_fi(:)=1;
%% iteration commences
%set judging factor flag=0
flag=0;
%use flag to judge when should the loop stop
while flag==0
%compute