Quickguide QPBLOCK Problem: Difference between revisions
From TomWiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
</math> | </math> | ||
where <math>c, x, x_L, x_U \in \ | where <math>c, x, x_L, x_U \in \mathbb{R}^n</math>, <math>F \in \mathbb{R}^{n | ||
\times n}</math>, <math>A \in \ | \times n}</math>, <math>A \in \mathbb{R}^{m_1 \times n}</math>, and <math>b_L,b_U \in | ||
\ | \mathbb{R}^{m_1}</math>. Equality constraints are defined by setting the | ||
lower bound equal to the upper bound, i.e. for constraint <math>i</math>: | lower bound equal to the upper bound, i.e. for constraint <math>i</math>: | ||
<math>b_{L}(i) = b_{U}(i)</math>. Fixed variables are handled the same way. | <math>b_{L}(i) = b_{U}(i)</math>. Fixed variables are handled the same way. | ||
Line 60: | Line 60: | ||
Open the file for viewing, and execute qpblockQG in Matlab. | Open the file for viewing, and execute qpblockQG in Matlab. | ||
< | <source lang="matlab"> | ||
% qpblockQG is a small example problem for defining and solving | % qpblockQG is a small example problem for defining and solving | ||
% quadratic programming on a block structure using the TOMLAB format. | % quadratic programming on a block structure using the TOMLAB format. | ||
Line 114: | Line 114: | ||
% Result = tomRun('knitro', Prob, 1); | % Result = tomRun('knitro', Prob, 1); | ||
% Result = tomRun('conopt', Prob, 1); | % Result = tomRun('conopt', Prob, 1); | ||
</ | </source> |
Latest revision as of 18:34, 17 January 2012
This page is part of the Quickguide Manual. See Quickguide. |
The general formulation in TOMLAB for a quadratic programming problem is:
where , , , and . Equality constraints are defined by setting the lower bound equal to the upper bound, i.e. for constraint : . Fixed variables are handled the same way.
When using a general nonlinear solver such as SNOPT, KNITRO or CONOPT it is possible to define the objective on a block structure. The objective can take the following formats.
Case 1:
The quadratic objective can be separated into main sparse matrix F and one or more additional two part blocks. min 0.5 * x' * F * x + d' * x + 0.5 * x' * Fb.out' * Fb.inn * Fb.out * x (for i=1...p)
Case 2:
The quadratic objective can be separated into a main sparse matrix F and two outer blocks. min 0.5 * x' * F * x + d' * x + 0.5 * x' * Fb.out' * Fb.out * x (for i=1...p)
Case 3:
Case number 1 above, but F is supplied as a nx1 vector (diagonal)
Case 4:
Case number 2 above, but F is supplied as a nx1 vector (diagonal)
The following file defines a test case in TOMLAB.
File: tomlab/quickguide/qpblockQG.m
Open the file for viewing, and execute qpblockQG in Matlab.
% qpblockQG is a small example problem for defining and solving
% quadratic programming on a block structure using the TOMLAB format.
% See help qpblockAssign for more information.
Name = 'QP Block Example';
switch 1
case 1
F = [ 8 0
0 8 ];
Fb(1).out = ones(3,2);
Fb(1).inn = ones(3,3);
Fb(2).out = ones(4,2);
Fb(2).inn = ones(4,4);
d = [ 3 -4 ]';
case 2
F = [ 8 0
0 8 ];
Fb(1).out = ones(3,2);
Fb(2).out = ones(4,2);
d = [ 3 -4 ]';
case 3
F = [ 8 8]';
Fb(1).out = ones(3,2);
Fb(1).inn = ones(3,3);
Fb(2).out = ones(4,2);
Fb(2).inn = ones(4,4);
d = [ 3 -4 ]';
case 4
F = [ 8 8]';
Fb(1).out = ones(3,2);
Fb(2).out = ones(4,2);
d = [ 3 -4 ]';
end
A = [ 1 1 % Constraint matrix
1 -1 ];
b_L = [-inf 0 ]'; % Lower bounds on the linear constraints
b_U = [ 5 0 ]'; % Upper bounds on the linear constraints
x_L = [ 0 0 ]'; % Lower bounds on the variables
x_U = [ inf inf ]'; % Upper bounds on the variables
x_0 = [ 0 1 ]'; % Starting point
x_min = [-1 -1 ]; % Plot region lower bound parameters
x_max = [ 6 6 ]; % Plot region upper bound parameters
% Assign routine for defining a QP problem.
Prob = qpblockAssign(F, Fb, d, x_L, x_U, Name, x_0, A, b_L, b_U);
% Calling driver routine tomRun to run the solver.
% The 1 sets the print level after optimization.
Result = tomRun('snopt', Prob, 1);
% Result = tomRun('knitro', Prob, 1);
% Result = tomRun('conopt', Prob, 1);