#*************************************************************
# Test Problem 3 from Chapter 11, section 4.4
# CSTR Problem
#*************************************************************
OPTION {{
FTOL = 1e-6;
OTOL = 1e-6;
NLP = "SNOPT";
RANDOMX;
}}
DECLARATION {{
INDEX {i};
SET CP = |0:10|; # Number of control parameters
SET CI = |0:9|; # Number of control intervals
SET J = |1:3|; # Number of states
XVAR {z3f, # Final Time Value of state 3
w(CP) # Control parameters
};
ZVAR {z(J),u};
ISPE {z(J)};
STP z(J) = {0.09,0.09,0};
TIME{0,0.078,0.156,0.234,0.312,0.39,0.468,0.546,0.624,0.702,0.78};
PARA time(CP) = {0,0.078,0.156,0.234,0.312,0.39,0.468,0.546,0.624,0.702,0.78};
# Variable Bounds
LBDS w(CP) = < i E CP | -0.5>;
UBDS w(CP) = < i E CP | 5>;
LBDS z3f = 0;
UBDS z3f = 1;
}}
MODEL {{
MIN: z3f;
dae1: z'(1) =e= -(z(1) + 0.25) + (z(2) + 0.5)*exp[25*z(1)/(z(1) + 2)] - (1+u)*(z(1) + 0.25);
dae2: z'(2) =e= 0.5 - z(2) - (z(2) + 0.5)*exp[25*z(1)/(z(1) + 2)];
dae3: z'(3) =e= z(1)^2 + z(2)^2 + 0.1*u^2;
control: u =e= interv[i E CI| w(i)+(w(i+1)-w(i))*(t-time(i))/(time(i+1)-time(i))] ;
endtime[10]: z3f - z(3) =e= 0;
}}