function[Phi_best,w_best]=Example3(starttime,t_max)
%Example 3 in the manuscript Harman, Bachrata, Filova: Heuristic construction of exact experimental designs under multiple resource constraints
%Nonlinear regression model with simultaneous direct and cost constraints
%input:
%starttime: the time s=0,...,167 when the experiment is initiated 
%t_max: the time (in seconds) the heuristic is required to run
%output:
%Phi_best: the D-value of the design w_best
%w_best: D-efficient exact design found by the heuristic


t1=3532;
t2=0.2381;

for i=0:144
    F(1,i+1)=1/t2*(exp(-t2*max([i-72 0]))-exp(-t2*i));
    a=exp(-t2*max([i-72 0]));
    F(2,i+1)=t1/t2^2*(a*(-1-t2*max([i-72 0]))+exp(-t2*i)*(t2*i+1));
end;   

%generate the constraints
function[A,b]=schedule(starttime)

    g0=ones(1,168)*1.5;
    g0([1:6 116:168])=2;
    g0([9:17 33:41 57:65 81:89 105:113])=1;
    g0=[g0 g0];

    g=g0(starttime:(starttime+144));

    b=ones(146,1);
    b(146)=13;

    A=eye(145);
    A(146,:)=g;
        
end


%run the optimization
[A,b]=schedule(starttime);
wwstart=zeros(145,1);
wwstart(1)=1;
wwstart(73)=1;
wwstart(145)=1;

[Phi_best,w_best]=Hugo(F,A,b,wwstart,-1,t_max)

end
