Quickguide QP Problem: Difference between revisions
From TomWiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
here <math>c, x, x_L, x_U \in \ | here <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>: | the 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 29: | Line 29: | ||
Open the file for viewing, and execute qpQG in Matlab. | Open the file for viewing, and execute qpQG in Matlab. | ||
< | <source lang="matlab"> | ||
% qpQG is a small example problem for defining and solving | % qpQG is a small example problem for defining and solving | ||
% quadratic programming problems using the TOMLAB format. | % quadratic programming problems using the TOMLAB format. | ||
Line 60: | Line 60: | ||
%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 07:46, 17 January 2012
This page is part of the Quickguide Manual. See Quickguide. |
The general formulation in TOMLAB for a quadratic programming problem is:
here , , , 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.
Example problem:
The following file defines this problem in TOMLAB.
File: tomlab/quickguide/qpQG.m
Open the file for viewing, and execute qpQG in Matlab.
% qpQG is a small example problem for defining and solving
% quadratic programming problems using the TOMLAB format.
Name = 'QP Example';
F = [ 8 1 % Matrix F in 1/2 * x' * F * x + c' * x
1 8 ];
c = [ 3 -4 ]'; % Vector c in 1/2 * x' * F * x + c' * x
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 = qpAssign(F, c, A, b_L, b_U, x_L, x_U, x_0, Name,...
[], [], [], x_min, x_max);
% Calling driver routine tomRun to run the solver.
% The 1 sets the print level after optimization.
Result = tomRun('qpSolve', Prob, 1);
%Result = tomRun('snopt', Prob, 1);
%Result = tomRun('sqopt', Prob, 1);
%Result = tomRun('cplex', Prob, 1);
%Result = tomRun('knitro', Prob, 1);
%Result = tomRun('conopt', Prob, 1);