Quickguide LP Problem: Difference between revisions

From TomWiki
Jump to navigationJump to search
(Created page with "{{Part Of Manual|title=the Quickguide Manual|link=Quickguide}} The general formulation in TOMLAB for a linear programming problem is: <br clear="all" /> <math> ...")
 
No edit summary
 
Line 15: Line 15:




where <math>c, x, x_L, x_U \in \MATHSET{R}^n</math>, <math>A \in \MATHSET{R}^{m_1 \times n}</math>, and <math>b_L,b_U \in \MATHSET{R}^{m_1}</math>. Equality constraints are defined by setting the lower bound to the upper bound.
where <math>c, x, x_L, x_U \in \mathbb{R}^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 to the upper bound.


Example problem:
Example problem:
Line 39: Line 39:
Open the file for viewing, and execute lpQG in Matlab.
Open the file for viewing, and execute lpQG in Matlab.


<syntaxhighlight lang="matlab">
<source lang="matlab">
  % lpQG is a small example problem for defining and solving
  % lpQG is a small example problem for defining and solving
  % linear programming problems using the TOMLAB format.
  % linear programming problems using the TOMLAB format.
Line 80: Line 80:
  %Result = tomRun('cplex', Prob, 1);
  %Result = tomRun('cplex', Prob, 1);
  %Result = tomRun('xpress-mp', Prob, 1);
  %Result = tomRun('xpress-mp', Prob, 1);
</syntaxhighlight>
</source>

Latest revision as of 07:45, 17 January 2012

Notice.png

This page is part of the Quickguide Manual. See Quickguide.

The general formulation in TOMLAB for a linear programming problem is:



where , , and . Equality constraints are defined by setting the lower bound to the upper bound.

Example problem:



The following file defines this problem in TOMLAB.

File: tomlab/quickguide/lpQG.m

Open the file for viewing, and execute lpQG in Matlab.

 % lpQG is a small example problem for defining and solving
 % linear programming problems using the TOMLAB format.
 
 Name  = 'lpQG';     % Problem name, not required.
 c     = [-7 -5]';   % Coefficients in linear objective function 
 A     = [ 1  2
           4  1 ];   % Matrix defining linear constraints
 b_U   = [ 6 12 ]';  % Upper bounds on the linear inequalities
 x_L   = [ 0  0 ]';  % Lower bounds on x
 
 % x_min and x_max are only needed if doing plots
 x_min = [ 0  0 ]';
 x_max = [10 10 ]';
 
 % b_L, x_U and x_0 have default values and need not be defined.
 % It is possible to call lpAssign with empty [] arguments instead
 b_L   = [-inf -inf]';
 x_U   = [];
 x_0   = [];
 
 % Assign routine for defining an LP problem. This allows the user
 % to try any solver, including general nonlinear solvers.
 Prob = lpAssign(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.x_k contains the optimal decision variables.
 % Result.f_k is the optimal value.
 
 Result = tomRun('pdco', Prob, 1);
 
 %Result = tomRun('lpSimplex', Prob, 1);
 %Result = tomRun('minos', Prob, 1);
 %Result = tomRun('snopt', Prob, 1);
 %Result = tomRun('conopt', Prob, 1);
 %Result = tomRun('knitro', Prob, 1);
 %Result = tomRun('cplex', Prob, 1);
 %Result = tomRun('xpress-mp', Prob, 1);