Originally posted by: Devin063
function iterate(plant, t, u, varargin)
switch nargin
case 3
...
case 4
if varargin{1,1} == false
...
else
plant.needRecord = true;
end
otherwise
error('Number of arguments does not match.')
end
constraintsLeft = [plant.c.AC0; ...
-plant.c.s*plant.x(27)*plant.dt; ...
plant.c.Aeq;...
plant.c.Aspec];
constraintsRight = [plant.c.bC0; ...
plant.x-plant.c.lowConcLmt; ...
plant.c.beq; ...
plant.p.bspec];
plant.p.bspec(end-1) = 2.2 * 4e-5 * plant.x(5) / (1.5 + plant.x(5));
[j,fval,exitflag,output,lambda] = cplexlp(-plant.c.s(27,:), constraintsLeft, constraintsRight,...
[], [], zeros(plant.c.numReac,1), [], [], plant.c.options);
if exitflag ~= 1
disp(t);
error('Infeasible solution in the plant module!');
end
plant.hist.cnstr(:,t) = constraintsLeft * j - constraintsRight;
plant.hist.j(:,t) = j;
plant.hist.fval(t) = fval;
plant.p.vol = plant.p.vol + u * 1e-3 *plant.dt ;
plant.x = plant.x + plant.c.s * j * plant.x(27) * plant.dt ...
+ ((u * 400 / 147) / (1 * plant.p.vol)) * plant.dt * plant.c.inp...
- (u * 1e-3 / plant.p.vol) * plant.dt * plant.x;
if plant.needRecord == true
plant.hist.u(:,t) = u;
plant.hist.x(:,t) = plant.x;
plant.record(t);
end
end
s is a coefficient matrix for linear programming problem.
BTW, Sir, you asked me to upload engine file in another question. But I don't know how to generate engine file through Matlab APIs. Could you give me some hints?
Thank you very much!
#DecisionOptimization#OPLusingCPOptimizer