parameters_in = {a,b,c,d,e};
solutions_out = {out1,out2};
ops = sdpsettings('verbose','2', 'solver', 'gurobi');
controller = optimizer(Constraints,objective,ops,parameters_in,solutions_out);
save saved controller;
load saved;
loadobj(controller);
[solutions,diagnostics] = controller{{a,b,c,d,e}};
Error using reshape
To RESHAPE the number of elements must not change.
Error in optimizer/subsref (line 140)
u = [u reshape(output.Primal(1+self.map),self.dimout)];
.... (line 133)
if isempty(self.output.z)
if ~isempty(output.Primal)
% Make sure we map index 0 to Nans
% 0 corresponds to variables which werent visible in
% problem
output.Primal = [nan;output.Primal];
u = [u reshape(output.Primal(1+self.map),self.dimout)];
else
u = [u reshape(0*self.map+nan,self.dimout)];
end
else
if ~isempty(output.Primal)
% Make sure we map index 0 to Nans
% 0 corresponds to variables which werent visible in
% problem
output.Primal = [nan;output.Primal];
assign(self.output.z,output.Primal(1+self.map));
assign(self.input.expression,thisData);
u = [u reshape(double(self.output.expression),self.dimout)];
end
end
....
>> yalmip('clear');clear all
>> sdpvar a b x y
>> P = optimizer([x;y]<=a+b,-x-y,[],{a,b},{x^2+y});
>> save dummy P
>> load dummy
>> P{{1,2}}
Error using reshape
To RESHAPE the number of elements must not change.
Error in optimizer/subsref (line 157)
u = [u reshape(output.Primal(1+self.map),self.dimout)];
fieldnames(controller)
P = optimizer([x;y]<=a+b,-x-y,[],{a,b},{x^2+y});
...
P{{1,2}}
P = optimizer([x;y]<=a+b,-x-y,[],{a,b},{x,y});
...
sol = P{{1,2}};
sol{1}^2+sol{2}
P = optimizer([x;y]<=a+b,-x-y,[],{a,b},{x^2+y});
names=fieldnames(P);
names =
'recover'
'model'
'dimin'
'dimout'
'diminOrig'
'dimoutOrig'
'complexInput'
'complexOutput'
'mask'
'map'
'input'
'output'
'parameters'
'nonlinear'
'F'
'h'
'ops'
'complicatedEvalMap'
P1 = optimizer([x;a*y]<=a+b,-x-y,[],{a,b},{x,y});
P2 = optimizer([b*x;y]<=2*a+b,-2*x-3*y,[],{a,b},{x,y});
save myfile P1 P2
clear all
load myfile
sol1 = P1{{1,2}};
sol2 = P2{{1,2}};
sol1{1}^2+sol1{2}
sol2{1}^4-sol2{2}^2