Interface for solving optimization problems
problem = Opt('H',H,'f',f,'pF',F,'A',A,'b',b,'Ae',Ae,...)
problem = Opt('M',M,'q',q,'Q',Q,'Ath',Ath,'bth',bth)
problem = Opt(Matrices)
problem = Opt(constraints, objective, theta, x)
H |
Quadratic part of the objective function. Class: double Default: [] |
f |
Linear part of the objective function. Class: double |
pF |
Linear part of the objective function for parameters. Class: double Default: [] |
Y |
Quadratic part of the objective function for parameters. Class: double Default: 0 |
C |
Linear part of the objective function for parameters. Class: double Default: 0 |
c |
Constant term in the objective function Class: double Default: 0 |
A |
Linear part of the inequality constraints ![]() Class: double |
b |
Right hand side of the inequality constraints ![]() Class: double |
pB |
Right hand side of the inequality constraints for parameters ![]() Class: double |
Ae |
Linear part of the equality constraints ![]() Class: double Default: [] |
be |
Right hand side of the equality constraints ![]() Class: double Default: [] |
pE |
Right hand side of the equality constraints for parameters ![]() Class: double Default: [] |
lb |
Lower bound for the decision variables ![]() Class: double Default: [] |
ub |
Upper bound for the decision variables ![]() Class: double Default: [] |
Ath |
Linear part of the inequality constraints ![]() Class: double Default: [] |
bth |
Right hand side of the inequality constraints ![]() Class: double Default: [] |
vartype |
A vector of strings determining the type of the variable.
Supported characters are C (continuous), I (integer), B (binary), N (semi-integer), S (semi-continuous).
Example: First variable from three is binary, the rest is continuous: vartype='BCC';
Class: char Default: '' |
solver |
S string specifying which solver should be called. Class: char Default: [] |
M |
Linear matrix involved in LCP. Class: double Default: [] |
q |
Right hand side vector involved in LCP. Class: double Default: [] |
Q |
Linear matrix involved in parametric formulation of LCP. Class: double Default: [] |
Matrices |
Structure with the matrices defining MPLP/MPQP problem as returned by mpt_constructMatrices function.
For detailed description, see help mpt_constructMatrices. Class: struct |
constraints |
Yalmip set of constraints that formulate the given problem. Class: lmi |
objective |
Yalmip variable that represents objective value of the given problem. Class: sdpvar |
theta |
Specification of parametric variables involved in problem formulated in Yalmip. Class: sdpvar |
x |
Specification of decision variables involved in problem formulated in Yalmip. Class: sdpvar |
problem |
Object of the Opt class that defines the optimization problem. Class: Opt |
f = [1 2 3]; A = randn(8,3); b = ones(8,1);Consruct the object
problem = Opt('f',f,'A',A,'b',b)
------------------------------------------------- Linear program Num variables: 3 Num inequality constraints: 8 Num equality constraints: 0 Solver: LCP -------------------------------------------------Solve the problem
problem.solve
ans = xopt: [3x1 double] lambda: [1x1 struct] obj: -2.25934252307113 how: 'ok' exitflag: 1
f = [-1 2 -3 4]; A = randn(12,4); b = ones(12,1); B = randn(12,2);Restrict the parameters to a unitbox of the size 5.
Ath = [eye(2); -eye(2)]; bth = 5*ones(4,1);Construct the object
problem = Opt('H',eye(4),'f',f,'A',A,'b',b,'pB',B,'Ath',Ath,'bth',bth)
------------------------------------------------- Parametric quadratic program Num variables: 4 Num inequality constraints: 12 Num equality constraints: 0 Num parameters: 2 Solver: PLCP -------------------------------------------------Solve the problem
solution = problem.solve
regions: 27, unexplored: 9 mpt_plcp: 43 regions Fixing the adjacency list... ...done. solution = xopt: [1x1 PolyUnion] exitflag: 1 how: 'ok' stats: [1x1 struct]Since we have an explicit solution, we can plot the partition
solution.xopt.plot
H = randn(5); M = sqrt(2)*H'*H; q = randn(5,1);Construct the object
problem = Opt('M',M,'q',q);Solve the problem
problem.solve
ans = xopt: [5x1 double] lambda: [5x1 double] obj: [] how: 'ok' exitflag: 1
A = 0.7*randn(2); B = randn(2,1);Define the optimization variables
u = sdpvar(repmat(1,1,5),repmat(1,1,5));
x = sdpvar(repmat(2,1,6),repmat(1,1,6));Define the constraints and the cost function.
objective = []; constraints = [];
for k = 1:5, objective = objective + norm(eye(2)*x{k},2) + norm(u{k},2); constraints = [constraints, x{k+1} == A*x{k} + B*u{k}]; constraints = [constraints, -5 <= u{k} <= 5, -10 <= x{k} <= 10]; endCreate the object
problem = Opt(constraints, objective, x{1}, u{1})
------------------------------------------------- Parametric linear program Num variables: 15 Num inequality constraints: 30 Num equality constraints: 10 Num lower bounds 15 Num upper bounds 15 Num parameters: 2 Solver: PLCP -------------------------------------------------Solve the problem explicitly
solution = problem.solve
mpt_plcp: 4 regions solution = xopt: [1x1 PolyUnion] exitflag: 1 how: 'ok' stats: [1x1 struct]Plot the explicit solution
solution.xopt.plot
sysStruct.A = 0.7*randn(2);
sysStruct.B = randn(2,1);
sysStruct.C = [1, -1];
sysStruct.D = 0;
sysStruct.xmin = [-10;-10];
sysStruct.xmax = [10;10];
sysStruct.umin = -5;
sysStruct.umax = 5;
probStruct.Q = 2*eye(2);
probStruct.R = 1;
probStruct.subopt_lev = 0;
probStruct.norm = 2;
probStruct.N = 5;Create problem data to MPQP
Matrices = mpt_constructMatrices(sysStruct,probStruct)
Function mpt_constructMatrices is obsolete and will be removed in a future MPT version. Iteration 1... Iteration 2... Iteration 3... Matrices = PbndIncluded: 1 G: [36x5 double] W: [36x1 double] E: [36x2 double] H: [5x5 double] F: [2x5 double] Y: [2x2 double] Cf: [0 0 0 0 0] Cx: [0 0] Cc: 0 symmetric: 0 bndA: [4x2 double] bndb: [4x1 double] Pinvset: [1x1 polytope] constraints_reduced: 1Construct object of the Opt class.
problem = Opt(Matrices)
------------------------------------------------- Parametric quadratic program Num variables: 5 Num inequality constraints: 36 Num equality constraints: 0 Num parameters: 2 Solver: PLCP -------------------------------------------------Solve the problem
solution = problem.solve
mpt_plcp: 7 regions solution = xopt: [1x1 PolyUnion] exitflag: 1 how: 'ok' stats: [1x1 struct]Plot the control law over the explicit solution
solution.xopt.fplot('primal')
◀ | eliminateequations | display | ▶ |
© 2010-2013 Colin Neil Jones: EPF Lausanne, colin.jones@epfl.ch
© 2010-2013 Martin Herceg: ETH Zurich, herceg@control.ee.ethz.ch