Appendix is the data of yalmiptime and solvetime.
****************************************************************************
Iteration 1:
The main program:
sol = (Where sol is the return struct of solvesdp)
contains the following struct:
yalmipversion: '20181012'
yalmiptime: 9.5957
solvertime: 2.9813
info: 'Successfully solved (CPLEX-IBM)'
problem: 0
solveroutput: [1×1 struct]
solverinput: [1×1 struct]
yalmipmodel: [1×1 struct]
sub-problem:
sol =
Contains the following struct:
yalmipversion: '20181012'
yalmiptime: 1.9363
solvertime: 0.0367
info: 'Successfully solved (CPLEX-IBM)'
problem: 0
solveroutput: [1×1 struct]
****************************************************************************
Iteration 32:
The main program:
sol =
Contains the following struct:
yalmipversion: '20181012'
yalmiptime: 168.7463
solvertime: 2.2657
info: 'Successfully solved (CPLEX-IBM)'
problem: 0
solveroutput: [1×1 struct]
sub-problem:
sol =
Contains the following struct:
yalmipversion: '20181012'
yalmiptime: 20.7593
solvertime: 0.1087
info: 'Successfully solved (CPLEX-IBM)'
problem: 0
solveroutput: [1×1 struct]
****************************************************************************
Iteration 96:
The main program:
sol =
Contains the following struct:
yalmipversion: '20181012'
yalmiptime: 494.9447
solvertime: 3.4363
info: 'Successfully solved (CPLEX-IBM)'
problem: 0
solveroutput: [1×1 struct]
sub-problem:
sol =
Contains the following struct:
yalmipversion: '20181012'
yalmiptime: 57.9348
solvertime: 0.0572
info: 'Successfully solved (CPLEX-IBM)'
problem: 0
solveroutput: [1×1 struct]
****************************************************************************
Iteration 112:
The main program:
sol =
Contains the following struct:
yalmipversion: '20181012'
yalmiptime: 624.9390
solvertime: 7.2010
info: 'Successfully solved (CPLEX-IBM)'
problem: 0
solveroutput: [1×1 struct]
sub-problem:
sol =
Contains the following struct:
yalmipversion: '20181012'
yalmiptime: 72.5015
solvertime: 0.5995
info: 'Successfully solved (CPLEX-IBM)'
problem: 0
solveroutput: [1×1 struct]
q = 1;
for i = 1:10000
x = sdpvar(1);
y = sdpvar(1);
optimize(x+y ==q,x^2+y^2)
q = value(x)*value(y)
end
q = 1;
for i = 1:10000
yalmip('clear')
x = sdpvar(1);
y = sdpvar(1);
optimize(x+y ==q,x^2+y^2)
q = value(x)*value(y)
end
q = 1;
x = sdpvar(1);
y = sdpvar(1);
obj = x^2+y^2;
for i = 1:10000
optimize(x+y == q,obj)
q = value(x)*value(y)
end
q = sdpvar(1);
x = sdpvar(1);
y = sdpvar(1);
P = optimizer(x + y == q,x^2+y^2,sdpsettings('solver','cplex'),q,{x,y})
qval = 1;
for i = 1:10000
sol = P(qval);
qval = sol{1}*sol{2};
end
q = sdpvar(1);
x = sdpvar(1);
y = sdpvar(1);
P = optimizer(x + y == q,q*x^2+y*q + y^2,sdpsettings('solver','cplex'),q,{x,y})
qval = 1;
for i = 1:10000
sol = P(qval);
qval = sol{1}*sol{2};
end
Honorific Prof. johan.lofberg:
I have encountered several problems now.
1.My program contains subroutines,so I have to put the variable definition and assignment of the subproblem before the for loop of the main program. However, the subroutine needs to use the variable of the sdpvar type defined in the main program.
So I want to ask if the variable of the sdpvar type can be defined as a global variable? Or I still have to define the variable of the sdpvar type in the subroutine.
2.If I use the optimizer function, it means I only need to model the model once, and then i just need to solve it with the optimization solver?
Just like
controller = optimizer(constraints, objective,sdpsettings('solver','gurobi'),parameters_in,solutions_out);
...
[solutions,diagnostics] = controller{inputs};
You give on https://yalmip.github.io/example/standardmpc/
Honorific Prof. johan.lofberg:
I encountere several problems now.
Honorific Prof. johan.lofberg:
I encounter a problem now.
1.In the first iteration, Controller can run. And Matlab does not report any errors. where Controller = optimizer(con,obj,ops,Parameters,Outputs);
While in the second iteration, Matlab reports error, error is as follows.
when calling "optimizer/subsref",no assignment of output parameter "varargout{2}"(Other parameters may be included)
Best regard!
for t=1:24 if (3<=t)&&(t<=5)
Model = [Model, sum(d) == 1,
implies(d(1), [f == 8]); implies(d(2), [sdpvar1<=t, f == 7]); else Model = [Model,sdpvar1<=t, f == 7]); end
>> sdpvar x y(2,1);>> P = optimizer([], x*norm(y-x), [],x,y)