TOMLAB Solver Reference: Difference between revisions

From TomWiki
Jump to navigationJump to search
No edit summary
 
(46 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Part Of Manual|title=the TOMLAB Manual|link=[[TOMLAB|TOMLAB Manual]]}}
[[Category:Manuals]]
[[Category:Manuals]]
{{cleanup|Clean this article.}}
{{Part Of Manual|title=the TOMLAB Manual|link=[[TOMLAB|TOMLAB Manual]]}}
Detailed descriptions of the TOMLAB  solvers, driver routines and some utilities are given in the following sections. Also see the M-file help for each solver. All solvers except for the TOMLAB  Base Module are described in separate manuals.
Detailed descriptions of the TOMLAB  solvers, driver routines and some utilities are given in the following sections. Also see the M-file help for each solver. All solvers except for the TOMLAB  Base Module are described in separate manuals.


Line 63: Line 59:
*[[glcDirect]]
*[[glcDirect]]


====glcSolve====
==glcSolve==
 
'''Purpose'''


Solve general constrained mixed-integer global optimization problems.
Solve general constrained mixed-integer global optimization problems.


''glcSolve ''solves problems of the form
*[[glcSolve]]
 
 
<math>
\begin{array}{cccccc}
\min\limits_{x} & f(x) &  &  &  &  \\s/t & x_{L} & \leq  & x    & \leq  & x_{U} \\& b_{L} & \leq  & Ax  & \leq  & b_{U} \\& c_{L} & \leq  & c(x) & \leq  & c_{U} \\&      &      & x_i \mathrm{\ \ integer} &  & i \in I \\\end{array}
</math>
 
 
where <math>$x,x_{L},x_{U}\in \MATHSET{R}^{n}$</math> , <math>$c(x),c_{L},c_{U}\in\MATHSET{R}^{m_{1}}$</math> , <math>$A\in \MATHSET{R}^{m_{2}\times n}$</math> and <math>$b_{L},b_{U}\in \MATHSET{R}^{m_{2}}$</math>.
 
The variables <math>$x \in I$</math>, the index subset of <math>$1,...,n$</math> are restricted to be integers. Recommendation: Put the integers as the first variables. Put low range integers before large range integers. Linear constraints are specially treated. Equality constraints are added as penalties to the objective. Weights are computed automatically, assuming f(x) scaled to be roughly 1 at optimum. Otherwise scale f(x).
 
'''Calling  Syntax'''
 
Result = glcSolve(Prob,varargin)
 
Result = tomRun('glcSolve', Prob);
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''A''||Constraint matrix for linear constraints.
|-
||||''b_L''||Lower bounds on the linear constraints.
|-
|||''b_U''||Upper bounds on the linear constraints.
|-
|||''c_L''||Lower bounds on the general constraints.
|-
|||''c_U''||Upper bounds on the general constraints.
|-
|||''MIP''||Structure in ''Prob'', ''Prob.MIP''.
|-valign="top"
|||''Intvars''||If empty, all variables are assumed non-integer (LP problem) If length(IntVars)''> ''1 ==''> ''length(IntVars)  == length(c) should hold Then IntVars(i)  == 1 ==''> ''x(i)  integer.  IntVars(i)  == 0 ==''> ''x(i)  real If  length(IntVars)  ''< ''n, IntVars is assumed to be a set of indices. It is advised to number the integer values as the first variables, before the continuous. The tree search will then be done more efficiently.
|-
|||''fIP''||An upper bound on the optimal f(x) value. If empty, set as Inf.
|-valign="top"
|||''xIP''||The x-values  giving the fIP  value.  If fIP  empty and xIP  given, fIP  will  be computed if xIP nonempty, its feasibility is checked
|-valign="top"
|||''x_L''||Lower bounds for ''x'', must be given to restrict the search space. Any lower bounds that are inf are changed to -10000.
|-valign="top"
|||''x_U''||Upper bounds for ''x'', must be given to restrict the search space. Any upper bounds that are inf are changed to 10000.
|-
|||''FUNCS.f''||Name of m-file computing the objective function ''f ''(''x'').
|-
|||''FUNCS.c''||Name of m-file computing the vector of constraint functions ''c''(''x'').
|-
|||''Name''||Name of the problem. Used for security if doing warm start.
|-
|||''PriLevOpt''||Print level. 0 = silent. 1 = some printing.  2 = print each iteration.
|-valign="top"
|||''WarmStart''||If true (''> ''0), ''glcSolve ''reads the output  from the last run from the mat-file ''glcSave.mat'', and continues from the last run.  NOTE: All rectangles that are fathomed in the previous run are deleted.  This saves space and computational time and enables solving larger problems and more function evaluations to be done.
|-
|||''MaxCPU''||Maximal CPU Time (in seconds) to be used.
|-
|||''glcDirect''||Structure with DIRECT algorithm specific parameters. Fields used:
|-valign="top"
|||''fcALL''||=0 (Default). If linear constraints cannot be feasible anywhere inside rectangle, skip f(x) and c(x) computation for middle point.
|-valign="top"
||||||=1 Always compute f(x)  and c(x), even if linear constraints are not feasible anywhere in rectangle. Do not update rates of change for the constraints.
|-valign="top"
|||||=2 Always compute f(x)  and c(x), even if linear constraints are not feasible anywhere in rectangle. Update rates of change constraints.
|-valign="top"
|||''useRoC''||=1 (Default).  Use original Rate of Change (RoC) for constraints to weight the constraint violations in selecting which rectangle divide.
|-valign="top"
|||||=0 Avoid RoC, giving equal weights to all constraint violations. Suggested if difficulty  to find feasible points.  For problems where linear constraints have been added among the nonlinear (NOT  RECOMMENDED;  AVOID!!!),  then option useRoc=0  has been successful, whereas useRoC completely fails.
|-valign="top"
|||||=2  Avoid  RoC for linear constraints, giving weight  one to these constraint violations, whereas the nonlinear constraints use RoC.
|-valign="top"
|||||=3 Use RoC for nonlinear constraints, but linear constraints are not used to determine which rectangle to use.
|-valign="top"
|||''BRANCH''||=0 Divide rectangle by selecting the longest side, if ties use the lowest index. This is the Jones DIRECT  paper strategy.
|-valign="top"
|||||=1  First  branch the integer variables, selecting the variable with  the least splits. If all integer variables are split, split on the continuous variables as in BRANCH=0.  DEFAULT! Normally much more efficient than =0 for mixed- integer problems.
|-valign="top"
|||||=2 First branch the integer variables with 1,2 or 3 possible values, e.g \[0,1\],\[0,2\] variables, selecting the variable with least splits. Then branch the other integer variables, selecting the variable with the least splits. If all integer variables are split, split on the continuous variables  as in BRANCH=0.
|-valign="top"
|||||=3  Like  =2,  but  use priorities  on the variables, similar  to  ''mipSolve'', see Prob.MIP.VarWeight.
|-valign="top"
|||''RECTIE''||When minimizing the measure to find which new rectangle to try to get feasible, there are often ties, several rectangles have the same minimum. RECTIE = 0 or 1 seems reasonable choices. Rectangles  with low index are often larger then the rectangles with higher index.  Selecting one of each type could help, but often =0 is fastest.
|-
|||||=0 Use the rectangle with value a, with lowest index (original).
|-
|||||=1 (Default):  Use 1 of the smallest and 1 of largest rectangles.
|-
|||||=2 Use the last rectangle with the same value a, not the 1st.
|-
|||||=3 Use one of the smallest rectangles with same value a.
|-
|||||=4 Use all rectangles with the same value a, not just the 1st.
|-valign="top"
|||''EqConFac''||Weight factor for equality constraints when adding to objective function f(x) (Default value 10). The weight is computed as EqConFac/"right or left hand side constant value", e.g. if the constraint is Ax ''<''= b, the weight is EqCon- Fac/b If DIRECT  just is pushing down the f(x) value instead of fulfilling  the equality constraints, increase EqConFac.
|-valign="top"
|||''AxFeas''||Set nonzero to make glcSolve skip f(x) evaluations, when the linear constraints are infeasible, and still  no feasible point  has been found.  The default  is 0. Value 1 demands ''f cALL  ''== 0. This option could save some time if f(x) is a bit costly, however overall performance could on some problems be dramatically worse.
|-valign="top"
|||''fEqual''||All  points with  function values within  tolerance fEqual are considered to be global minima and returned. Default 1E-10.
|-valign="top"
|||''LinWeight''||''RateOfChange'' = ''LinWeight'' * <nowiki>||a(i, :)||</nowiki> for linear constraints.  Balance be- tween linear and nonlinear constraints. Default 0.1. The higher value, the less influence from linear constraints.
|-
|||''alpha''||Exponential forgetting factor in RoC computation, default 0.9.
|-valign="top"
|||''AvIter''||How many values to use in startup of RoC computation before switching to exponential smoothing with forgetting factor alpha. Default 50.
|-valign="top"
|||colspan="2"|If WarmStart is chosen, the following fields in ''glcSave.mat ''are also used and contains information from the previous run:
|-
|||''C''||Matrix  with all rectangle centerpoints.
|-
|||''D''||Vector with distances from centerpoint to the vertices.
|-
|||''F''||Vector with function values.
|-
|||''G''||Matrix with constraint values for each point.
|-
|||''Name''||''Name of the problem. Used for security if doing warm start.
|-valign="top"
|||''Split''||''Split''(''i, j'') is the number of splits along dimension ''i ''of rectangle ''j''.
|-
|||''T''||''T ''(''i'') is the number of times rectangle ''i ''has been trisected.
|-
|||''fMinEQ''||sum(abs(infeasibilities)) for minimum points, 0 if no equalities.
|-
|||''fMinIdx''||Indices of the currently best points.
|-
|||''feasible''||Flag indicating if a feasible point has been found.
|-
|||''glcfmin''||Best function value found at a feasible point.
|-valign="top"
|||''iL''||''iL''(''i, j'') is the lower bound for rectangle ''j ''in integer dimension ''I ''(''i'').
|-valign="top"
|||''iU''||''iU ''(''i, j'') is the upper bound for rectangle ''j ''in integer dimension ''I ''(''i'').
|-
|||''ignoreidx''||Rectangles to be ignored in the rectangle selection procedure.
|-
|||''s''||''s''(''j'') is the sum of observed rates of change for constraint ''j''.
|-
|||''s_0''||''s_''0 is used as ''s''(0).
|-
|||''t''||''t''(''i'') is the total number of splits along dimension ''i''.
|-
|||''SubRes''||Additional  output from nlp f, if suboptimization done.
|-valign="top"
|||''optParam''||Structure with special fields for optimization parameters, see Table 141 on page 229.
|-valign="top"
|||||Fields  used  by  ''glcSolve ''are: ''IterPrint'', ''bTol'', ''cTol'', ''MaxIter  ''(default''max''(5000'', n * ''1000)), ''MaxFunc ''(default ''max''(10000'', n * ''2000)), ''EpsGlob'', ''fGoal'', ''eps_f'', ''eps_x''.
|-
|''varargin''||colspan="2"|Other parameters directly sent to low level routines.
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization.  The following fields are changed:
|-
|||''x_k''||Matrix  with all points giving the function value ''f_k''.
|-
|||''f_k''||Function value at optimum.
|-
|||''c_k''||Nonlinear constraints values at ''x_k''.
|-
|||''glcSave.mat''||Special file containing:
|-
|||''C''||Matrix  with all rectangle centerpoints.
|-
|||''D''||Vector with distances from centerpoint to the vertices.
|-
|||''F''||Vector with function values.
|-
|||''G''||Matrix  with constraint values for each point.
|-
|||''Name''||''Name of the problem. Used for security if doing warm start.
|-
|||''Split''||''Split''(''i, j'') is the number of splits along dimension ''i ''of rectangle ''j''.
|-
|||''T''||''T ''(''i'') is the number of times rectangle ''i ''has been trisected.
|-
|||''fMinEQ''||sum(abs(infeasibilities)) for minimum points, 0 if no equalities.
|-
|||''fMinIdx''||Indices of the currently best points.
|-
|||''feasible''||Flag indicating if a feasible point has been found.
|-
|||''glcf min''||Best function value found at a feasible point.
|-
|||''iL''||''iL''(''i, j'') is the lower bound for rectangle ''j ''in integer dimension ''I ''(''i'').
|-
|||''iU''||''iU ''(''i, j'') is the upper bound for rectangle ''j ''in integer dimension ''I ''(''i'').
|-
|||''ignoreidx''|||Rectangles to be ignored in the rectangle selection procedure.
|-
|||''s''||''s''(''j'') is the sum of observed rates of change for constraint ''j''.
|-
|||''s_0''||''s_''0 is used as ''s''(0).
|-
|||''t''||''t''(''i'') is the total number of splits along dimension ''i''.
|-
|||''Iter''||Number of iterations.
|-
|||''FuncEv''||Number function evaluations.
|-
|||''maxTri''||Maximum size of any triangle.
|-
|||''ExitText''||Text string giving ExitFlag and Inform information.
|-
|||''ExitFlag''||0 - Reached maxFunc or maxIter. 
|-
|||||2 - Some upper bounds below lower bounds.
|-
|||||7 - Reached maxFunc or maxIter, NOT feasible.
|-
|||||8 - Empty domain for integer variables.
|-valign="top"
|||''Inform''||1 = Function value f is less than fGoal. 2 = Absolute function value f is less than fTol, only if fGoal = 0 or Relative error in function value f is less than fTol, i.e. abs(f-fGoal)/abs(fGoal) ''<''= fTol. 3 = Maximum number of iterations done. 4 = Maximum number of function evaluations done. 9 = Max CPU Time reached. 91= Infeasible. 99= Input error, see ExitFlag.
|}
 
'''Description'''
 
The routine ''glcSolve ''implements an extended version of DIRECT,  see  \[52\], that handles problems with  both nonlinear and integer constraints.
 
DIRECT is a modification of the standard Lipschitzian approach that eliminates the need to specify a Lipschitz constant. Since no such constant is used, there is no natural way of defining convergence (except when the optimal function value is known). Therefore ''glcSolve ''is run for a predefined number of function evaluations and considers the best function value found as the optimal one. It is possible for the user to '''restart '''''glcSolve ''with the final status of all parameters from the previous run, a so called ''warm start ''Assume that a run has been made with ''glcSolve ''on a certain problem for 500 function evaluations. Then a run of e.g. 200 function evaluations more should give the same result as if the run had been using 700 function evaluations in the first place. To do a warm start of ''glcSolve ''a flag ''Prob.WarmStart ''should be set to one. Then ''glcSolve ''is using output previously written to the file ''glcSave.mat ''to make the restart.
 
DIRECT does not explicitly  handle equality constraints.  It works best when the integer variables describe an ordered quantity and is less effective when they are categorical.
 
'''M-files  Used'''
 
''iniSolve.m'', ''endSolve.m''
 
====infLinSolve====


'''Purpose'''
==infLinSolve==


Finds a linearly constrained minimax solution of a function of several variables with  the use of any suitable TOMLAB  solver. The decision variables may be binary or integer.
Finds a linearly constrained minimax solution of a function of several variables with  the use of any suitable TOMLAB  solver. The decision variables may be binary or integer.


infLinSolve solves problems of the type:
*[[infLinSolve]]
 
 
<math>
\begin{array}{cccccc}
\min\limits_x & \multicolumn{5}{l}{\max Dx} \\\mbox{subject to} & x_L & \leq &    x  & \leq &  x_U \\& b_L & \leq &  Ax  & \leq &  b_U \\\end{array}
</Math>
 
 
where <Math>$x,x_L,x_U \in \Rdim{n}$</Math> , <Math>$b_L,b_U \in \Rdim{m_1}$</Math> , <Math>$A \in\Rdim{m_1 \times n}$</Math> and <Math>$D \in \Rdim{m_2 \times n}$</Math> . The variables <math>$x \in I$</Math> , the index subset of <Math>$1,...,n$</Math> are restricted to be integers. The different objectives are stored in D row-wise.
 
'''Calling  Syntax'''
 
Result=infLinSolve(Prob,PriLev)
 
'''Description  of Inputs'''
 
{|
|-valign="top"
|''Prob''||colspan="2"|Structure Prob.  Prob must be defined. Best is to use Prob = lp/mipAssign(.....),  if using the TQ format. Prob.QP.D matrix should then be set to the rows (Prob.QP.c ignored).
|-
|||''PriLev''||Print level in ''infLinSolve''.
|-
|||||= 0 Silent except for error messages.
|-
|||||''> ''0 Print summary information about problem transformation.
|-
|||||Calls ''PrintResult ''with specified ''PriLev''.
|-
|||||= 2 Standard output from ''PrintResult ''(default).
|-
|||colspan="2"|Extra fields used in Prob:
|-valign="top"
|||''SolverInf''||Name of the TOMLAB  solver. Valid names are: cplex, minos, snopt, xa and more.  SeeSolverList('lp');  or SolverList('mip');
|-
|||''QP.D''||The rows with the different objectives.
|-
|||''f_Low''||Lower bound on the objective (optional).
|-
|||''f_Upp''||Upper bound on the objective (optional).
|}
 
'''Description  of Outputs'''
 
{|
|-valign="top"
|''Result||colspan="2"|''Structure with results from optimization.  Output depends on the solver used.
|-valign="top"
|||||The fields ''x_k'', ''f_k'', ''x_0'', ''xState'', ''bState'', ''v_k ''are transformed back to match the original problem.
|-valign="top"
|||||The output in Result.Prob is the result after infLinSolve transformed the problem, i.e. the altered Prob structure
|}
 
'''Description'''
 
The linear minimax problem is solved in infLinSolve by rewriting the problem as a linear optimization problem. One additional variable <math>$z\in \MATHSET{R}$</math>, stored as <math>$x_{n+1}$</math> is added and the problem is rewritten as:
 
 
<math>
\begin{array}{cccccc}
\multicolumn{6}{l}{\min\limits_x  z}\\
\\\mbox{subject to} & x_L & \leq & (x_1,x_2,\ldots,x_n)^T & \leq & x_U \\&  -\infty & \leq &  z                    & \leq & \infty \\&  b_L    & \leq & A x                    &\leq & b_U \\&  -\infty & \leq & D x - z e              & \leq & 0 \\
\end{array}
</math>
 
 
where <math>$e \in \Rdim{N},\; e(i)=1 \ \forall i$</math>.
 
To handle  cases where  a row in D\*x is taken the absolute value of: ''minmax\|D * x\|'', expand the problem with extra residuals with the opposite sign: \[''D * x''; ''-D * x''\].
 
'''See Also'''
 
''lpAssign''.
 
====infSolve====
 


 
==infSolve==
'''Purpose'''


Find a constrained minimax solution with the use of any suitable TOMLAB solver.
Find a constrained minimax solution with the use of any suitable TOMLAB solver.


infSolve solves problems of the type:
*[[infSolve]]
 
 
 
<math>
\begin{array}{cccccc}
\min\limits_x & \multicolumn{5}{l}{\max r(x)} \\\mbox{subject to} & x_L & \leq &    x  & \leq &  x_U \\& b_L & \leq &  Ax  & \leq &  b_U \\& c_L & \leq &  c(x) & \leq &  c_U \\
\end{array}
</math>
 
where <math>$x,x_L,x_U \in \Rdim{n}$</math> , <math>$r(x) \in \Rdim{N}$</math> , <math>$c(x),c_L,c_U \in\Rdim{m_1}$</math> , <math>$b_L,b_U \in \Rdim{m_2}$</math> and <math>$A \in \Rdim{m_2 \times n}$</math>.
 
'''Calling  Syntax'''
 
Result=infSolve(Prob,PriLev)
 
'''Description  of Inputs'''
 
{|
|-valign="top"
||''Prob''||colspan="2"|Problem description structure. Should be created in the '''cls''' format. infSolve uses two special fields in ''Prob'':
|-
|||''SolverInf''||Name of solver used to solve the transformed problem.
|-
|||||Valid choices are ''conSolve'', ''nlpSolve'', ''sTrustr ''and ''clsSolve''.
|-
|||||If TOMLAB /SOL is installed: ''minos'', ''snopt'', ''npopt''.
|-
|||''InfType''||1 - constrained formulation (default).
|-
|||||2 - LS penalty approach (experimental).
|-
|||colspan="2"|The remaining fields of ''Prob ''should be defined  as required by the selected subsolver.
|-
|||''PriLev''||Print level in ''infSolve''.
|-
|||||= 0 Silent except for error messages.
|-
|||||''> ''0 Print summary information about problem transformation.
|-
|||||Calls ''PrintResult'' with specified ''PriLev''.
|-
|||||= 2Standard output from ''PrintResult ''(default).
|}
 
'''Description  of Outputs'''
 
{|
|-valign="top"
|''Result''||colspan="2"|Structure with results from optimization.  Output depends on the solver used.
|-valign="top"
|||colspan="2"|The fields ''x_k'', ''r_k'', ''J_k'', ''c_k'', ''cJac'', ''x_0'', ''xState'', ''cState'', ''v_k ''are transformed back to match the original problem.
|-
|||colspan="2"|''g_k ''is calculated as <math>\VAR{J\_k</math><math>$^T$</math><math>}</math> <math>$\cdot$</math> <math>\VAR{r\_k}</math>.
|-valign="top"
|||colspan="2"|The output  in Result.Prob is the result after infSolve  transformed the problem, i.e. the altered Prob structure
|}
 
'''Description'''
 
The minimax problem is solved in infSolve by rewriting the problem as a general constrained optimization problem. One additional variable <math>$z\in \MATHSET{R}$</math>, stored as <math>$x_{n+1}$</math> is added and the problem is rewritten as:
 
<math>
\begin{array}{cccccc}
\multicolumn{6}{l}{\min\limits_x  z}\\\\\mbox{subject to} & x_L & \leq & (x_1,x_2,\ldots,x_n)^T & \leq & x_U \\&  -\infty & \leq &  z                    & \leq & \infty \\&  b_L    & \leq & A x                    & \leq & b_U \\&  c_L    & \leq & c(x)                  & \leq & c_U \\&  -\infty & \leq & r(x) - z e            & \leq & 0 \\\end{array}
</math>
 
 
where <math>$e \in \Rdim{N},\; e(i)=1 \ \forall i$</math>.
 
To handle cases where an element <math>$r_i(x)$</math> in <math>$r(x)$</math> appears in absolute value:  <math>$\min \max |r_i(x)|$</math>, expand the problem with extra residuals with the opposite sign: <math>$ [ r_i(x); -r_i(x) ] $</math>
 
'''Examples'''
 
''minimaxDemo.m''.
 
'''See Also'''
 
''clsAssign''.


====linRatSolve====
==linRatSolve==
 
'''Purpose'''


Finds a linearly constrained solution of a function of the ratio of two linear functions with the use of any suitable TOMLAB  solver. Binary and integer variables are not supported.
Finds a linearly constrained solution of a function of the ratio of two linear functions with the use of any suitable TOMLAB  solver. Binary and integer variables are not supported.


linRatSolve solves problems of the type:
*[[linRatSolve]]
 
 
<math>
\begin{array}{cccccc}
\min\limits_x & \multicolumn{5}{l}{ \Large (c1 x) \over (c2 x)  } \\\mbox{subject to} & x_L & \leq &    x  & \leq &  x_U \\& b_L & \leq &  Ax  & \leq &  b_U \\
\end{array}
</math>
 
where <math>$c1,c2,x,x_L,x_U \in \Rdim{n}$</math> , <math>$b_L,b_U \in \Rdim{m_1}$</math> and <math>$A \in \Rdim{m_1 \times n}$</math>.
 
'''Calling  Syntax'''
 
Result=linRatSolve(Prob,PriLev)
 
'''Description  of Inputs'''
 
{|
|-valign="top"
|''Prob''||colspan="2"|Structure Prob.  Prob must be defined. Best is to use Prob = lpAssign(.....), if using the TQ format. Prob.QP.c1/c2 matrices should then be set (Prob.QP.c ignored).
|-
|''PriLev''||Print level in ''linRatSolve''.
|-
|||= 0Silent except for error messages.
|-
|||''> ''0 Print summary information about problem transformation.
|-
|||Calls ''PrintResult ''with specified ''PriLev''.
|-
|||= 2 Standard output from ''PrintResult ''(default).
|-
|colspan="2"|Extra fields used in Prob:
|-valign="top"
|''SolverRat''||Name of the TOMLAB  solver. Valid names are: cplex, minos, snopt, xa and more.  See SolverList('lp');
|-
|''QP.c1''||The numerator in the objective.
|-
|''QP.c2''||The denominator in the objective.
|-
|''z1_L ''||Lower bound for z1 (default 1e-5). See description below
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||Structure with results from optimization. Output depends on the solver used.
|-valign="top"
|||The fields ''x_k'', ''f_k'', ''x_0'', ''xState'', ''bState'', ''v_k ''are transformed back to match the original problem.
|-
|||The output in Result.Prob is the result after linRatSolve transformed the problem, i.e. the altered Prob structure
|}
 
'''Description'''
 
The linear ratio problem is solved by linRatSolve by rewriting the problem as a linear constrained optimization problem. n+1 variables z1 and z2(2:n+1) are needed, stored as x(1:n+1).  The n original variables are removed so one more variable exists in the final problem.
 
 
<math>
\begin{array}{ccc}
\\
z1  &  = & 1 / (c2 x)  \\
z2  &  = & x  z1  \\
z1 (c1  x) & = &  (c1  z1  x) = c1  z2\\
\end{array}
</math>
 
 
The problem then becomes:
 
 
<math>
\begin{array}{cccccc}
\multicolumn{6}{l}{\min\limits_x  c1 z2}\\\\\mbox{subject to} & z1_L      & \leq & z1              & \leq & \infty \\&  1        & \leq & c2 z2          & \leq & 1 \\&  0        & \leq & A z2 - z1 beq  & \leq & 0 \\&  -\infty  & \leq & A z2 - z1 b_U  & \leq & 0 \\&  -\infty  & \leq & - A z2 + z1 b_L & \leq & 0 \\\\&  0        & \leq & A1 z2 - z1 xeq  & \leq & 0 \\&  -\infty  & \leq & A1 z2 - z1 x_U  & \leq & 0 \\&  -\infty  & \leq & - A1 z2 + z1 x_L & \leq & 0 \\
\end{array}
</math>
 
where <math>$A1 \in \Rdim{N},\; A1=speye(N)$</math>.
 
OBSERVE the denominator ''c''2''x ''must always be positive. It is normally a good a idea to run the problem with both signs (multiply  each side by -1).
 
'''See Also'''
 
''lpAssign''.
 
====lpSimplex====


'''Purpose'''
==lpSimplex==


Solve general linear programming problems.
Solve general linear programming problems.


''lpSimplex ''solves problems of the form
*[[lpSimplex]]
 
 
<math>
\begin{array}{cccccl}
\min\limits_{x} & f(x) & = & c^{T}x &  &  \\s/t & x_{L} & \leq  & x  & \leq  & x_{U} \\& b_{L} & \leq  & Ax  & \leq  & b_{U} \\
\end{array}
</math>
 
 
where <math>$x,x_{L},x_{U}\in \MATHSET{R} ^{n}$</math> , <math>$c \in \MATHSET{R}^{n}$</math> , <math>$A\in \MATHSET{R}^{m\times n}$</math> and <math>$b_{L},b_{U} \in \MATHSET{R}^{m}$</math>.


'''Calling  Syntax'''
==L1Solve==
 
Result = lpSimplex(Prob) or
 
Result = tomRun('lpSimplex', Prob, 1);
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''QP.c''||Constant vector.
|-
|||''A''||Constraint matrix for linear constraints.
|-
|||''b_L''||Lower bounds on the linear constraints.
|-
|||''b_U''||Upper bounds on the linear constraints.
|-
|||''x_L''||Lower bounds on the variables.
|-
|||''x_U''||Upper bounds on the variables.
|-
|||''x_0''||Starting point.
|-
|||''Solver.Alg''||Variable selection rule to be used:
|-
|||||0: Minimum reduced cost.
|-
|||||1: Bland's rule (default).
|-
|||||2: Minimum reduced cost. Dantzig's rule.
|-
|||''QP.B''||Active set ''B 0 ''at start:
|-
|||||''B''(''i'') = 1: Include variable ''x''(''i'') is in basic set.
|-
|||||''B''(''i'') = 0: Variable ''x''(''i'') is set on its lower bound.
|-
|||||''B''(''i'') = ''-''1: Variable ''x''(''i'') is set on its upper bound.
|-
|||''optParam''||Structure with special fields for optimization parameters,  see Table 141.
|-valign="top"
|||||Fields used are: ''MaxIter'', ''PriLev'', ''wait'', ''eps_f'', ''eps_Rank'', ''xTol ''and ''bTol''.
|}
 
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization.  The following fields are changed:
|-
|||''x_k''||Optimal point.
|-
|||''f_k''||Function value at optimum.
|-
|||''g_k''||Gradient value at optimum, ''c''.
|-
|||''v_k''||Lagrange multipliers.
|-
|||''x_0''||Starting point.
|-
|||''f_0''||Function value at start.
|-
|||''xState''||State of each variable, described in Table 150.
|-
|||''ExitFlag''||0: Optimal solution found.
|-
|||||1: Maximal number of iterations reached.
|-
|||||2: Unbounded feasible region.
|-
|||||5: Too many active variables in given initial  point.
|-
|||||6: No feasible point found with Phase 1.
|-
|||||10: Errors in input parameters.
|-
|||||11: Illegal initial  x as input.
|-
|||''Inform''||If ''ExitF lag > ''0, ''I nf orm ''= ''ExitF lag''.
|-
|||''QP.B''||Optimal active set. See input variable ''QP.B''.
|-
|||''Solver''||Solver used.
|-
|||''SolverAlgorithm ''||Solver algorithm used.
|-
|||''Iter''||Number of iterations.
|-valign="top"
|||''FuncEv''||Number of function evaluations. Equal to ''Iter''. ''ConstrEv ''Number of constraint evaluations.  Equal to ''Iter''.
|-
|||''Prob''||Problem structure used.
|}
 
'''Description'''
 
The routine ''lpSimplex ''implements an active  set strategy (Simplex method) for Linear Programming using an additional set of slack variables for the linear constraints. If the given starting point is not feasible then a Phase I objective is used until a feasible point is found.
 
'''M-files  Used'''
 
''ResultDef.m''
 
'''See Also'''
 
''qpSolve''
 
====L1Solve====
 
'''Purpose'''


Find a constrained L1 solution of a function of several variables with the use of any suitable nonlinear TOMLAB solver.
Find a constrained L1 solution of a function of several variables with the use of any suitable nonlinear TOMLAB solver.


''L1Solve ''solves problems of the type:
*[[L1Solve]]
 
 
<math>
\begin{array}{cccccc}
\min\limits_x & \multicolumn{5}{l}{\sum_i |r_i(x)|} \\\mbox{subject to} & x_L & \leq &  x  & \leq & x_U \\{}                & b_L & \leq &  Ax  & \leq & b_U \\{}                & c_L & \leq & c(x) & \leq & c_U \\
\end{array}
</math>
 
 
where <math>$x,x_L,x_U \in \Rdim{n}$</math> , <math>$r(x) \in \Rdim{N}$</math> , <math>$c(x),c_L,c_U\in \Rdim{m_1}$</math> , <math>$b_L,b_U \in \Rdim{m_2}$</math> and <math>$A\in \Rdim{m_2 \times n}$</math>.
 
 
'''Calling  Syntax'''
 
Result = L1Solve(Prob,PriLev)
 
'''Description  of Inputs'''
 
{|
|-valign="top"
|''Prob ''||colspan="2"|Problem description structure. ''Prob ''should be created in the '''cls '''constrained nonlinear format.
|-
|||colspan="2"|''L1Solve'' uses one special field in ''Prob'':
|-valign="top"
|||''SolverL1''||Name of the TOMLAB  solver used to solve the augmented general nonlinear problem generated by ''L1Solve''.
|-valign="top"
|||colspan="2"|Any other fields are passed along to the solver specified by ''Prob.SolverL1''. In particular:
|-
|||''A''||Linear constraint matrix.
|-
|||''b_L''||Lower bounds on variables.
|-
|||''b_U''||Upper bounds on variables.
|-
|||''c_L''||Lower bounds for nonlinear constraints.
|-
|||''c_U''||Upper bounds for nonlinear constraints..
|-
|||''x_L''||Lower bounds on variables.
|-
|||''x_U''||Upper bounds on variables.
|-
|||''x_0''||Starting point.
|-
|||''ConsPattern''||Nonzero patterns of constraint and residual Jacobians.
|-valign="top"
|||''JacPattern''||Prob.LS.y must have the correct residual length if ''JacPattern ''is empty  but ''ConsPattern ''is not.
|-valign="top"
|||||''L1Solve ''will create the new patterns for the sub-solver using the information supplied in these two fields.
|-
|||''PriLev''||Print level in ''L1Solve''.
|-
|||= 0||silent except for error messages.
|-
|||''> ''0||print summary information about problem transformation.
|-
|||||Calls ''PrintResult ''with specified ''PriLev''.
|-
|||= 2||standard output from ''PrintResult''.
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||Structure with results from optimization. Fields changed depends on which solver was used for the extended problem.
|-
|||The fields ''x_k'', ''r_k'', ''J_k'', ''c_k'', ''cJac'', ''x_0'', ''xState'', ''cState'', ''v_k'', are transformed back to the format of the original L1 problem. ''g k ''is calculated as <math>{J\_k</math><math>$^T$</math><math>}</math> · ''r k''.  The returned problem structure ''Result.Prob ''is the result after ''L1Solve ''transformed the problem, i.e. the altered ''Prob ''structure.
 
'''Description'''
 
L1Solve solves the L1 problem by reformulating it as the
 
general constrained optimization problem
 
 
<math>
\begin{array}{cccccc}
\min\limits_x & \multicolumn{5}{l}{\sum_i (y_i+z_i) }  \\
\mbox{subject to} & x_L & \leq & x        & \leq & x_U    \\
{}                & 0  & \leq & y        & \leq & \infty \\
{}                & 0  & \leq & z        & \leq & \infty \\
{}                & b_L & \leq & Ax      & \leq & b_U      \\
{}                & c_L & \leq & c(x)    & \leq & c_U    \\
{}                & 0  & \leq & r(x)+y-z & \leq & 0    \\
\end{array}
</math>
 
 
A problem with ''N ''residuals is extended with 2''N ''nonnegative variables <math>$y,z \in \Rdim{N}$</math> along with ''N'' equality constraints <math>$r_i(x) + y_i - z_i = 0$</math>.
 
'''See Also'''
 
''infSolve''
 
 
 
====MILPSOLVE====


'''Purpose'''
==MilpSolve==


Solve mixed integer linear programming problems (MILP).
Solve mixed integer linear programming problems (MILP).


''MILPSOLVE  ''solves problems of the form
*[[MilpSolve]]
 
 
<math>
\begin{array}{cccccc}
\min\limits_{x} & f(x) & = & c^{T}x &  \\s/t & x_{L} & \leq  & x  & \leq & x_{U} \\& b_{L} & \leq  & Ax & \leq & b_{U} \\&      &      & \multicolumn{3}{l}{x_{j} \in \MATHSET{N} \ \ \forall j \in $I$}  \\
\end{array}
</math>
 
 
where <math>c, x, x_L, x_U \in \MATHSET{R}^{n}</math> , <math>A\in\MATHSET{R}^{m\times n}</math> and <math>b_L, b_U \in MATHSET{R}^{m}</math>. The variables <math>x \in I</math> , the index subset of <math>1,...,n</math> are restricted to
be integers.
 
'''Calling  Syntax'''
 
Result = tomRun('MILPSOLVE',Prob, 1); or
 
Prob = ProbCheck(Prob, 'MILPSOLVE');
 
Result = milpsolveTL(Prob);
 
PrintResult(Result,1);
 
'''Description  of Inputs'''


{|
==minlpSolve==
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''x_L, x_U''||Lower and upper bounds on variables. (Must be dense).
|-
|||''b_L, b_U''||Lower and upper bounds on linear constraints. (Must be dense).
|-
|||''A''||Linear constraint matrix. (Sparse or dense).
|-
|||''QP.c''||Linear objective function coefficients,  size ''nx''1.
|-
|||''BIG''||Definition of infinity.  Default is 1e30.
|-valign="top"
|||''LargeScale''||Defines if milpsolveTL will convert the A matrix to a sparse matrix or not.
|-
|||||Largescale ! = 0 - sparse
|-
|||||LargeScale = 0 - dense
|-
|||||Default is to use the A matrix just as it is defined.
|-
|||''PriLevOpt''||Specifies the printlevel that will be used by MILPSOLVE.
|-
|||||0 (NONE) No outputs
|-
|||||1 (NEUTRAL) Only some specific debug messages in debug print rou- tines are reported.
|-valign="top"
|||||2 (CRITICAL) Only critical  messages are  reported.  Hard errors like instability,  out of memory.
|-
|||||3 (SEVERE) Only severe messages are reported. Errors.
|-
|||||4 (IMPORTANT) Only important messages are reported. Warnings and Errors.
|-
|||||5 (NORMAL) Normal messages are reported.
|-valign="top"
|||||6 (DETAILED) Detailed messages are reported. Like model size, con- tinuing B&B improvements.
|-
|||||7 (FULL)  All messages are reported. Useful for debugging purposes and small models.
|-valign="top"
|||||Default print level is 0, no outputs. PriLevOpt ''< ''0 is interpreted as 0, and larger than 7 is interpreted as 7.
|-valign="top"
|||''MaxCPU''||Maximal CPU Time (in seconds) to be used by MILPSOLVE, stops with best point found.
|-valign="top"
|colspan="3"|Fields used in '''Prob.MILPSOLVE '''(Structure with MILPSOLVE specific parameters)
|-valign="top"
|||''ANTI_DEGEN''||Binary vector. If empty, no anti-degeneracy handling is applied. If the length (i) of the vector is less than 8 elements,only the i first modes are considered. Also if i is longer than 8 elements, the elements after element8 are ignored.
|-
|||||ANTI_DEGEN specifies if special handling must be done to reduce de- generacy/cycling while solving. Setting this flag can avoid cycling, but can also increase numerical instability.
|-
|||||ANTIDEGEN FIXEDVARS  ! = 0 Check if  there are equality slacks in the basis and try  to drive  them out in order to reduce chance of degeneracy in Phase 1.
|-
|||||ANTIDEGEN COLUMNCHECK  != 0
|-
|||||ANTIDEGEN STALLING  != 0
|-
|||||ANTIDEGEN NUMFAILURE != 0
|-
|||||ANTIDEGEN LOSTFEAS != 0
|-
|||||ANTIDEGEN INFEASIBLE  != 0
|-
|||||ANTIDEGEN DYNAMIC != 0
|-
|||||ANTIDEGEN DURINGBB != 0
|-valign="top"
|||''basis''||If empty or erroneous, default basis is used. Default start base is the all slack basis (the default simplex starting basis).
|-
|||||Prob.MILPSOLVE.basis stores the basic variables. If an element is less then zero then it means on lower bound, else on upper bound. Element 0 of the array is unused. The default initial basis is bascolumn\[x\] = -x. By MILPSOLVE  convention, a basic variable is always on its lower bound, meaning that basic variables is always represented with a minus sign.
|-
|||||When a restart is done, the basis vector must be assigned  a correct starting basis.
|-valign="top"
|||''BASIS_CRASH''||The set basiscrash  function  specifies  which basis crash mode  MILP- SOLVE will used.
|-
|||||When no base crash is done (the default), the initial  basis from which MILPSOLVE starts to solve the model is the basis containing all slack or artificial variables that is automatically associates with each constraint.
|-
|||||When base crash is enabled, a heuristic "crash procedure" is executed before the first simplex iteration to quickly choose a basis matrix that has fewer artificial  variables. This procedure tends to reduce the num- ber of iterations to optimality  since a number of iterations are skipped. MILPSOLVE  starts iterating from this basis until optimality.
|-
|||||BASIS_CRASH ! = 2 - No basis crash
|-
|||||BASIS_CRASH = 2 - Most feasible basis
|-
|||||Default is no basis crash.
|-valign="top"
|||''BB_DEPTH_LIMIT''||Sets the maximum branch-and-bound depth.  This value makes  sense only if there are integer, semi-continuous or SOS variables in the model so that the branch-and-bound algorithm is used to solve the model. The branch-and-bound algorithm will not go deeper than this level. When BB DEPTH LIMIT i set to 0 then there is no limit  to the depth. The default value is -50. A positive value means that the depth is absolute. A negative value means a relative B&B  depth.  The "order"  of a MIP problem is defined to be 2 times the number of binary variables plus the number of SC and SOS variables. A relative value of -x results in a maximum depth of x times the order of the MIP problem.
|-
|||''BB_FLOOR_FIRST''||Specifies which branch to take first in branch-and-bound algorithm. Default value is 1.
|-
|||||BB_FLOOR_FIRST = 0 (BRANCH CEILING) Take ceiling branch first
|-
|||||BB_FLOOR_FIRST = 1 (BRANCH FLOOR) Take floor branch first
|-
|||||BB_FLOOR_FIRST = 2 (BRANCH AUTOMATIC) MILPSOLVE decides which branch being taken first
|-
|||''BB_RULE''||Specifies the branch-and-bound rule. Default value is 0.
|-
|||||BB_RULE  = 0 (NODE FIRSTSELECT)  Select lowest  indexed non- integer column
|-
|||||BB_RULE = 1 (NODE GAPSELECT) Selection based on distance from the current bounds
|-
|||||BB_RULE = 2 (NODE RANGESELECT) Selection based on the largest current bound
|-
|||||BB_RULE = 3 (NODE FRACTIONSELECT) Selection based on largest fractional value
|-
|||||BB_RULE = 4 (NODE PSEUDOCOSTSELECT4) Simple, unweighted pseudo-cost of a variable
|-
|||||BB_RULE = 5 (NODE PSEUDONONINTSELECT)  This is an ex- tended pseudo-costing strategy based on minimizing the number of in- teger infeasibilities.
|-
|||||BB RULE = 6 (NODE PSEUDORATIOSELECT)  This is an extended pseudo-costing strategy based on maximizing the normal pseudo-cost divided by the number of infeasibilities. Effectively, it is similar to (the reciprocal of ) a cost/benefit ratio.
|-
|||||BB_RULE = 7 (NODE USERSELECT)
|-valign="top"
|||''BB_RULE_ADD''||Additional values for the BB RULE. BB RULE is a vector. If the length i of the vector is less than 10 elements, only the i first modes are considered. Also if i is longer than 10 elements, the elements after element 10 is ignored.
|-
|||||BB_RULE ADD(1) ! = 0 (NODE WEIGHTREVERSEMODE)
|-
|||||BB_RULE ADD(2)  ! = 0 (NODE BRANCHREVERSEMODE) In case when get bb floorfirst is BRANCH AUTOMATIC, select the opposite direction (lower/upper branch) that BRANCH AUTOMATIC had cho- sen.
|-
|||||BB_RULE_ADD(3) ! = 0 (NODE GREEDYMODE)
|-
|||||BB_RULE_ADD(4) ! = 0 (NODE PSEUDOCOSTMODE)
|-
|||||BB_RULE_ADD(5) ! = 0 (NODE DEPTHFIRSTMODE) Select  the node that has already been selected before the number of times
|-
|||||BB_RULE_ADD(6) ! = 0 (NODE RANDOMIZEMODE)
|-
|||||BB_RULE_ADD(7) !  = 0 (NODE DYNAMICMODE)    When NODE DEPTHFIRSTMODE is selected, switch off this mode when a first solution is found.
|-
|||||BB_RULE_ADD(8) ! = 0 (NODE RESTARTMODE)
|-
|||||BB_RULE_ADD(9) ! = 0 (NODE BREADTHFIRSTMODE) Select the node that has been selected before the fewest number of times or not at all BB RULE ADD(10) ! = 0 (NODE AUTOORDER)
|-
|||''BFP''||Defines which Basis Factorization Package that will be used by MILP- SOLVE.
|-
|||||BFP = 0 : LUSOL
|-
|||||BFP = 1 : built in etaPHI from MILPSOLVE  v3.2
|-
|||||BFP = 2 : Additional  etaPHI BFP = 3 : GLPK
|-
|||||Default BFP is LUSOL.
|-valign="top"
|||''BREAK_AT_FIRST''||Specifies if the branch-and-bound algorithm stops at the first found so- lution (BREAK_AT_FIRST != 0) or not (BREAK_AT_FIRST = 0). De- fault is not to stop at the first found solution.
|-valign="top"
|||''BREAK_AT_VALUE'||Specifies if the branch-and-bound algorithm stops when the object value is better than a given value. The default value is (-) infinity.
|-valign="top"
|||''EPAGAP''||Specifies the absolute MIP gap tolerance for the branch and bound algo- rithm.  This tolerance is the difference between the best-found solution yet and the current solution. If the difference is smaller than this toler- ance then the solution (and all the sub-solutions) is rejected. The default value is 1e-9.
|-valign="top"
|||''EPGAP''||Specifies the relative MIP gap tolerance for the branch and bound algo- rithm.  The default value is 1e-9.
|-valign="top"
|||''EPSB''||Specifies the value that is used as a tolerance for the Right Hand Side (RHS) to determine whether  a value should be considered  as 0.  The default epsb value is 1.0e-10
|-valign="top"
|||''EPSD''||Specifies the value that is used as a tolerance for reduced costs to deter- mine whether a value should be considered as 0. The default epsd value is 1e-9. If EPSD is empty, EPSD is read from ''Prob.optParam.eps f''.
|-valign="top"
|||''EPSEL''||Specifies the value that is used as a tolerance for rounding values to zero. The default epsel value is 1e-12.
|-valign="top"
|||''EPSINT''||Specifies  the  tolerance that  is used  to determine whether a floating- point number is in fact an integer. The default value for epsint is 1e-7. Changing this tolerance value can result in faster solving times, but the solution is less integer.
|-valign="top"
|||''EPSPERTURB''||Specifies the value that is used as perturbation scalar for degenerative problems. The default epsperturb value is 1e-5.
|-valign="top"
|||''EPSPIVOT''||Specifies the value that is used as a tolerance pivot element to determine whether a value should be considered as 0. The default epspivot value is 2e-7
|-
|||''IMPROVEMENT_LEVEL''||Specifies the iterative improvement level.
|-
|||||IMPROVEMENT LEVEL = 0 (IMPROVE  NONE) improve none
|-
|||||IMPROVEMENT LEVEL = 1 (IMPROVE  FTRAN)  improve FTRAN
|-
|||||IMPROVEMENT LEVEL = 2 (IMPROVE  BTRAN)  improve BTRAN
|-
|||||IMPROVEMENT LEVEL  = 3 (IMPROVE  SOLVE) improve FTRAN + BTRAN.
|-
|||||IMPROVEMENT LEVEL  = 4 (IMPROVE  INVERSE)  triggers automatic inverse accuracy control in the dual simplex, and when an error gap is exceeded the basis is reinverted
|-
|||||Choice 1,2,3 should not be used with MILPSOLVE  5.1.1.3,  because of problems with the solver. Default is 0.
|-valign="top"
|||''LoadFile''||File that  contains the  model. If LoadFile is a nonempty string which corresponds to actual file, then the model is read from this file rather than from the Prob struct.
|-
|||''LoadMode''||1 - LP - MILPSOLVE  LP format
|-
|||||2 - MPS - MPS format
|-
|||||3 - FMPS - Free MPS format
|-
|||||A default value for this field does not exist. Both LoadFile and Load- Mode must be set if a problem will be loaded.
|-
|||||If there is something wrong with LoadMode or LoadFile, an error mes- sage will be printed and MILPSOLVE  will be terminated. Leave Load- Mode and LoadFile empty if the problem not will be loaded from file.
|-
|||''LogFile''||Name of file to print MILPSOLVE  log on.
|-
|||''MAXIMIZE ''||If  MAXIMIZE ! = 0, MILPSOLVE  is set to maximize the objective function, default is to minimize.
|-
|||''MAX_PIVOT''||Sets the maximum number of pivots between a re-inversion of the matrix. Default is 42.
|-
|||''NEG_RANGE''||Specifies the negative value below which variables are split into a negative and a positive part.  This value must always be zero or negative. If a positive value is specified, then 0 is taken. The default value is -1e6.
|-
|||''PRESOLVE''||Vector containing possible presolve options. If the length i of the vector is less than 7 elements, only the i first modes are considered. Also if i is longer than 7 elements, the elements after element 7 is ignored.
|-
|||||PRESOLVE(1) ! = 0 (PRESOLVE ROWS) Presolve rows
|-
|||||PRESOLVE(2) ! = 0 (PRESOLVE COLS) Presolve columns
|-
|||||PRESOLVE(3) ! = 0 (PRESOLVE LINDEP)  Eliminate linearly depen- dent rows
|-
|||||PRESOLVE(4) ! = 0 (PRESOLVE SOS) Convert constraints to SOSes (only SOS1 handled)
|-
|||||PRESOLVE(5) ! = 0 (PRESOLVE REDUCEMIP)  If the phase 1 solu- tion process finds that a constraint is redundant then this constraint is deleted.
|-
|||||PRESOLVE(6) ! = 0 (PRESOLVE DUALS) Calculate duals PRESOLVE(7) ! = 0 (PRESOLVE SENSDUALS) Calculate sensitivity if there are integer variables
|-
|||||Default is not to do any presolve.
|-
|||''PRICING_RULE''||The pricing rule can be one of the following rules.
|-
|||||PRICING_RULE = 0 Select first (PRICER_FIRSTINDEX)
|-
|||||PRICING_RULE = 1 Select according to Dantzig (PRICER_DANTZIG)
|-
|||||PRICING_RULE = 2 Devex pricing from Paula Harris (PRICER_DEVEX)
|-
|||||PRICING_RULE = 3 Steepest Edge (PRICER STEEPESTEDGE)
|-valign="top"
|||''PRICING_MODE''||Additional pricing settings, any combination of the modes below. This is a binary vector. If the length i of the vector is less than 7 elements, only the i first modes are considered. Also if i is longer than 7 elements, the elements after element 7 is ignored.
|-
|||||PRICE_PRIMALFALLBACK ! = 0 In case of Steepest Edge, fall back to DEVEX in primal.
|-
|||||PRICE_MULTIPLE ! = 0 Preliminary implementation of the multiple pricing scheme.  This means that attractive candidate entering columns from one iteration may be used in the subsequent iteration, avoiding full updating of reduced costs. In the current implementation, MILPSOLVE only reuses the 2nd best entering column alternative.
|-
|||||PRICE_PARTIAL ! = 0 Enable partial pricing
|-
|||||PRICE_ADAPTIVE ! = 0 Temporarily use First Index if cycling is detected
|-
|||||PRICE_RANDOMIZE  ! = 0 Adds a small randomization effect to the selected pricer
|-
|||||PRICE_LOOPLEFT  ! = 0 Scan entering/leaving columns left rather than right
|-
|||||PRICE_LOOPALTERNATE ! = 0 Scan entering/leaving columns alternatingly left/right
|-
|||||Default basis is PRICER DEVEX combined with PRICE ADAPTIVE.
|-
|||''sa''||Struct  containing information  of the sensitivity analysis (SA) MILPSOLVE will perform.
|-
|||||sa.obj =! 0 Perform sensitivity analysis on the objective function
|-
|||||sa.obj = 0 Do not perform sensitivity analysis on the objective function
|-
|||||sa.rhs =! 0 Perform sensitivity analysis on the right hand sides.
|-
|||||sa.rhs = 0 Do not perform sensitivity analysis on the right hand sides.
|-valign="top"
|||''SaveFileAfter''||Name  of a file to save the MILPSOLVE object after presolve.The name must be of type string (char), Example: Prob.MILPSOLVE.SaveFileAfter = 'save2' If the type is not char SaveFileBefore is set to save2.\[file extension\].
|-valign="top"
|||''SaveFileBefore''||Name of a file to save the MILPSOLVE object before presolve. The name must be  of type string (char), Example: Prob.MILPSOLVE.SaveFileBefore = 'save1'. If the type  is not char SaveFileBefore is set to save1.\[file extension\].
|-
|||''SaveMode''||1 - LP - MILPSOLVE  LP format
|-
|||||2 - MPS - MPS format
|-
|||||3 - FMPS - Free MPS format
|-
|||||If empty, the default format LP is used.
|-valign="top"
|||''SCALE_LIMIT''||Sets the relative  scaling convergence  criterion  to  the  absolute value of SCALE_LIMIT for the active scaling mode. The integer part of SCALE_LIMIT specifies the maximum number of iterations. Default is 5.
|-
|||''SCALING_ALG''||Specifies which scaling algorithm will be used by MILPSOLVE.
|-
|||||0 No scaling algorithm
|-
|||||1 (SCALE EXTREME) Scale to convergence using largest absolute value
|-
|||||2 (SCALE RANGE) Scale based on the simple numerical range
|-
|||||3 (SCALE MEAN) Numerical range-based scaling
|-
|||||4 (SCALE GEOMETRIC) Geometric scaling
|-
|||||7 (SCALE CURTISREID) Curtis-reid scaling
|-
|||||Default is 0, no scaling algorithm.
|-valign="top"
|||''SCALING_ADD''||Vector containing possible additional scaling parameters. If the length (i) of the vector is less than 7 elements, only the i first modes are considered. Also if i is longer than 7 elements, the elements after element 7 is ignored. SCALING ADD ! = 0 (SCALE_QUADRATIC)
|-
|||||SCALING ADD ! = 0 (SCALE_LOGARITHMIC) Scale to convergence using logarithmic mean of all values
|-
|||||SCALING_ADD  !  = 0  (SCALE_USERWEIGHT) User can specify scalars
|-
|||||SCALING_ADD ! = 0 (SCALE_POWER2) also do Power scaling
|-
|||||SCALING_ADD  ! = 0 (SCALE_EQUILIBRATE) Make  sure that  no scaled number is above 1
|-
|||||SCALING_ADD ! = 0 (SCALE_INTEGERS) Also scaling integer vari- ables
|-
|||||SCALING_ADD ! = 0 (SCALE_DYNUPDATE) Dynamic update
|-
|||||Default is 0, no additional mode.
|-
|||||Settings SCALE_DYNUPDATE is a way to make sure that scaling factors are recomputed. In that case, the scaling factors are recomputed also when a restart is done.
|-
|||''SIMPLEX_TYPE''||Sets the desired combination of primal and dual simplex algorithms.
|-
|||||5 (SIMPLEX_PRIMAL_PRIMAL) Phase1 Primal, Phase2 Primal
|-
|||||6 (SIMPLEX_DUAL_PRIMAL) Phase1 Dual, Phase2 Primal
|-
|||||9 (SIMPLEX_PRIMAL_DUAL) Phase1 Primal, Phase2 Dual
|-
|||||10 (SIMPLEX_DUAL_DUAL) Phase1 Dual, Phase2 Dual
|-
|||||Default is SIMPLEX DUAL PRIMAL (6).
|-valign="top"
|||''SOLUTION_LIMIT''||Sets the solution number that will be returned. This value is only consid- ered if there are integer, semi-continuous or SOS variables in the model so that the branch-and-bound algorithm is used. If there are more solutions with the same objective value, then this number specifies which solution must be returned. Default is 1.
|-
|||''sos''||List of structs containing data about Special Ordered Sets (SOS). See below for further description.
|-
|colspan="3"|Fields used in '''Prob.MIP '''(Structure with MIP specific parameters)
|-
|||''IntVars''||Defines which variables are integers, of general type I or binary type B Variable indices should be in the range \[1,...,n\].
|-
|||||IntVars is a logical vector ==''> x''(''f ind''(''I ntV ars > ''0)) are integers
|-
|||||IntVars is a vector of indices ==''> x''(''I ntV ars'') are integers (if \[\], then no integers of type I or B are defined) variables with x L=0 and x U=1, is are set to binary. It is possible to combine integer and semi-continuous type to obtain the semi-integer type.
|-valign="top"
|||''fIP''||This parameter specifies the initial "at least better than" guess for objective function. This is only used in the branch-and-bound algorithm when integer variables exist in the model. All solutions with a worse objective value than this value are immediately rejected. The default is infinity.
|-valign=top"
|||''SC''||A vector with indices for variables of type semi-continuous (SC), a logical vector or a scalar (see MIP.IntVars). A semi-continuous variable i takes either the value 0 or some value in the range \[x L(i), x U(i)\].  It is possible to combine integer and semi-continuous type to obtain the semi-integer type.
|-valign="top"
|||''sos1''||List of structures defining the Special Ordered Sets of Order One (SOS1). For SOS1 set k, sos1(k).var is a vector of indices for variables of type SOS1 in set k, sos1(k).row is the priority  of SOS k in the set of SOS1 and sos1(k).weight is a vector of the same length as sos1(k).var and it describes the order MILPSOLVE  will weight the variables in SOS1 set k.
|-
|||||a low number of a row and a weight means high priority.
|-
|||''sos2''||List of n structures defining the Special Ordered Sets (SOS) of Order Two (SOS2). (see MIP.sos1)
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization. The following fields are changed:
|-
|||''x_k''||Optimal  solution (or some other solution if optimum could not been found)
|-
|||''f_k''||Optimal objective value.
|-
|||''v_k''||\[rc; duals\]. If Reduced cost and dual variables are not available, then v_k is empty.
|-
|||''ExitFlag''||TOMLAB information parameter.
|-
|||||0 = Optimal solution found.
|-
|||||1 = Suboptimal solution or user abort.
|-
|||||2 = Unbounded solution.
|-
|||||3 = Numerical failure.
|-
|||||4 = Infeasible model.
|-
|||||10 = Out of memory.
|-
|||||11 = Branch and bound stopped.
|-
|||''ExitText''||Status text from MILPSOLVE.
|-
|||''Inform''||MILPSOLVE  information parameter.
|-
|||||-2 = Out of memory.
|-
|||||0 = Optimal solution found.
|-
|||||1 = Suboptimal solution.
|-
|||||2 = Infeasible model.
|-
|||||3 = Unbounded solution.
|-
|||||4 = Degenerate solution.
|-
|||||5 = Numerical failure.
|-
|||||6 = User abort.
|-
|||||7 = Timeout.
|-
|||||10 = Branch and bound failed.
|-
|||||11 = Branch and bound stopped.
|-
|||||12 = Feasible branch and bound solution.
|-
|||||13 = No feasible branch and bound solution. Other = Unknown status.
|-valign="top"
|||''Iter''||The total  number of nodes processed in the branch-and-bound algorithm. Is only applicable if the model contains integer variables. In the case of an LP model Result.Iter contains the number of iterations. This is however not documented.
|-
|||''MinorIter''||The total number of Branch-and-bound iterations. When the problem is LP, MinorIter equals Result.Iter
|-
|||''MILPSOLVE.basis''||Optimal basis, on the format described above under Prob.MILPSOLVE.basis.
|-
|||''MILPSOLVE.MaxLevel''||The deepest Branch-and-bound  level of the last solution. Is only applicable if the model contains integer variables.
|-
|||''MILPSOLVE.sa.objStatus''||1 successful
|-
|||||0 SA not requested
|-
|||||-1 Error: error from MILPSOLVE
|-
|||||-3 no SA available
|-
|||''MILPSOLVE.sa.ObjLower''||An array that  will  contain the values of the lower limits  on the objective function.
|-
|||''MILPSOLVE.sa.ObjUpper''||An array that will contain the values of the upper limits on the objective function.
|-
|||''MILPSOLVE.sa.RhsStatus''||see MILPSOLVE.sa.objStatus.
|-
|||''MILPSOLVE.sa.RhsLower''||An array that will contain the values of the lower limits on the RHS.
|-
|||''MILPSOLVE.sa.RhsUpper''||An array that will contain the values of the upper limits on the RHS.
|-
|||''xState''||State of each variable
|-
|||||0 - free variable,
|-
|||||1 - variable on lower bound,
|-
|||||2 - variable on upper bound,
|-
|||||3 - variable is fixed, lower bound = upper bound.
|-
|||''bState''||State of each linear constraint
|-
|||||0 - Inactive constraint,
|-
|||||1 - Linear constraint on lower bound,
|-
|||||2 - Linear constraint on upper bound,
|-
|||||3 - Linear equality constraint.
|}
 
====minlpSolve====
 
'''Purpose'''


Branch & Bound algorithm for Mixed-Integer Nonlinear Programming (MINLP) with convex or nonconvex sub problems using NLP relaxation (Formulated as minlp-IP).  
Branch & Bound algorithm for Mixed-Integer Nonlinear Programming (MINLP) with convex or nonconvex sub problems using NLP relaxation (Formulated as minlp-IP).  


The parameter Convex (see below) determines if to assume the NLP subproblems are convex or not.
*[[minlpSolve]]
 
minlpSolve depends on a suitable NLP solver.
 
''minlpSolve ''solves problems of the form
 
 
<math>
\begin{array}{cccccc}
\min\limits_{x} & f(x) \\s/t & x_{L} & \leq  & x  & \leq & x_{U} \\& b_{L} & \leq  & Ax & \leq & b_{U} \\& c_{L} & \leq  & c(x) & \leq & c_{U} \\&      &      & \multicolumn{3}{l}{x_{j} \in \MATHSET{N} \ \ \forall j \in $I$}  \\
\end{array}
</math>
 
 
where <math>x,x_{L},x_{U}\in \MATHSET{R}^{n}</math> , <math>c(x),c_{L},c_{U}\in
\MATHSET{R}^{m_{1}}</math> , <math>A\in \MATHSET{R}^{m_{2}\times n}</math> and
<math>b_{L},b_{U}\in \MATHSET{R}^{m_{2}}</math>. The variables <math>x \in I</math> , the
index subset of <math>1,...,n</math> are restricted to be integers.
 
'''Calling  Syntax'''
 
Result = tomRun('minlpSolve',Prob,...)
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''x_L''||Lower bounds on x.
|-
|||''x_U''||Upper bounds on x.
|-
|||''A''||The linear constraint matrix.
|-
|||''b_L''||Lower bounds on linear constraints.
|-
|||''b_U''||Upper bounds on linear constraints.
|-
|||''c_L''||Lower bounds on nonlinear constraints.
|-
|||''c_U''||Upper bounds on nonlinear constraints.
|-
|||''x_0''||Starting point.
|-valign="top"
|||''Convex''||If  Convex==1,  assume NLP  problems are convex,  and only one local NLP solver call is used at each node. If Convex==0 (Default), multiMin  is used to do many calls to a local solver to determine the global minima at each node. The global minimum with most components integer valued is chosen.
|-
|||''MaxCPU''||Maximal CPU Time (in seconds) to be used by minlpSolve, stops with  best point found
|-
|||''PriLev''||Print level in minlpSolve (default 1). Also see optParam.IterPrint
|-
|||''PriLevOpt''||Print level in sub solvers (SNOPT and other NLP solvers):
|-
|||||=0 No output; ''>''0 Convergence results
|-
|||||''>''1 Output every iteration, ''>''2 Output each step in the NLP alg
|-
|||||For other NLP solvers,  see the documentation for the solver
|-valign="top"
|||''WarmStart''||If  true, ''>''0, minlpSolve  reads the output  from the last run  from Prob.minlpSolve, if it exists. If it doesn't exist, minlpSolve attempts to open and read warm start data from mat-file minlpSolveSave.mat. minlpSolve uses the warm start information to continue from the last run. The mat-file minlp- SolveSave.mat is saved every Prob.MIP.SaveFreq iteration.
|--valign="top"
|||''SolverNLP''||Name of the solver used for NLP subproblems.  If empty, the default solver is found calling GetSolver('con',1); If TOMLAB  /SOL installed, SNOPT is the default solver. If SolverNLP is a SOL solver (SNOPT, MINOS or NPSOL), the SOL.optPar and SOL.PrintFile is used: See help minosTL.m, npsolTL.m or snoptTL.m for how to set these parameters
|-valign="top"
|||''RandState''||If Convex == 0, RandState is sent to multiMin  to initialize the random gen- erator. RandState is used as follows:
|-
|||||If ''> ''0, rand('state',RandState) is set to initialize the pseudo-random generator
|-
|||||if ''< ''0, rand('state',sum(100\*clock)) is set to give a new set of random values each run
|-
|||||if RandState == 0, rand('state',) is not called. Default RandState = -1
|-
|||''MIP''||Structure in Prob, Prob.MIP. Defines integer optimization parameters. Fields used:
|-valign="top"
|||''IntVars''||If empty, all variables are assumed non-integer. If islogical(IntVars) (=all  el- ements are 0/1),  then 1 = integer variable, 0 = continuous variable.  If any element ''>''1, IntVars is the indices for integer variables.
|-valign="top"
|||''VarWeight''||Weight for each variable in the variable selection phase. A lower value gives higher priority.  Setting Prob.MIP.VarWeight might improve convergence.
|-valign="top"
|||''DualGap''||''minlpSolve ''stops if the duality gap is less than DualGap. DualGap = 1, stop at first integer solution e.g. DualGap = 0.01, stop if solution ''< ''1% from optimal solution.
|-valign="top"
|||''fIP''||An upper bound on the IP value wanted. Makes it possible to cut branches and avoid node computations. Used even if xIP not given.
|-
|||''xIP''||The x-values giving the fIP value, if a solution (xIP,fIP)  is known.
|-
|||''NodeSel''||Node selection method in branch and bound
|-
|||||= 0 Depth First.  Priority  on nodes with more integer components
|-
|||||= 1 Breadth First.  Priority  on nodes with more integer components
|-
|||||= 2 Depth First.  When integer solution found, use NodeSel = 1 (default)
|-
|||||= 3 Pure LIFO (Last in, first out) Depth First
|-
|||||= 4 Pure FIFO (First in, first out) Breadth First
|-
|||||= 5 Pure LIFO Depth First.  When integer solution found, use NodeSel 4
|-
|||''VarSel''||Variable selection method in branch and bound:
|-
|||||= 1 Use variable with most fractional value
|-
|||||= 2 Use gradient and distance to nearest integer value
|-
|||''KNAPSACK''||If = 1, use a knapsack heuristic. Default 0.
|-
|||''ROUNDH''||If = 1, use a rounding heuristic. Default 0.
|-valign="top"
|||''SaveFreq''||Warm start info saved on minlpSolveSave.mat  every SaveFreq iteration (default -1, i.e. no warm start info is saved)
|-
|||''optParam''||Structure in Prob. Fields used in Prob.optParam, also in sub solvers:
|-
|||''MaxIter''||Maximal number of iterations, default 10000
|-valign="top"
|||''IterPrint''||Print short information each iteration (PriLev ''> ''0 ==''> ''IterPrint = 1). Iter- ation number: Depth in tree (symbol L\[\] - empty list, symbol Gap - Dual Gap convergence),  fNLP (Optimal  f(x)  current node), fIPMin  (Best integer feasi- ble f(x) found), LowBnd (Lower bound on optimal integer feasible f(x)), Dual Gap in absolut value and percent, The length of the node list L, -L-, The Inform and ExitFlag the solver returned at the current node, FuEv (Number of function evaluations  used by solver at current node), date/time stamp.
|-
|||''bTol''||Linear constraint violation convergence tolerance.
|-
|||''cTol''||Constraint violation convergence tolerance.
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization.  The following fields are changed:
|-
|||''Iter ''||Number of iterations.
|-
|||''ExitFlag ''||0: Global optimal solution found, or integer solution with duality gap less than user tolerance.
|-
|||||1: Maximal number of iterations reached.
|-
|||||2: Empty feasible set, no integer solution found.
|-
|||||4: No feasible point found running NLP relaxation.
|-
|||||5: Illegal ''x 0 ''found in NLP relaxation.
|-
|||||99: Maximal CPU Time used (cputime ''> ''Prob.MaxCPU).
|-
|||''Inform''||Code telling type of convergence, returned from subsolver.
|-
|||''ExitText''||Text string giving ExitFlag and Inform information.
|-valign="top"
|||''DualGap''||Relative  duality  gap,  max(0,fIPMin-fLB)/-fIPMin-, if fIPMin =0; max(0,fIPMin-fLB) if fIPMin == 0. If fIPMin  =0:  Scale with 100, 100\*Dual- Gap, to get the percentage duality gap. For absolute value duality gap: scale with fIPMin, fIPMin \* DualGap
|-
|||''x_k''||Solution.
|-
|||''v_k''||Lagrange multipliers.  Bounds, Linear and Nonlinear Constraints, n + mLin + mNonLin.
|-
|||''f_k''||Function value at optimum.
|-
|||''g_k''||Gradient vector at optimum.
|-
|||''x_0''||Starting point x 0.
|-
|||''f_0''||Function value at start.
|-
|||''c_k''||Constraint values at optimum.
|-
|||''cJac''||Constraint derivative values at optimum.
|-
|||''xState''||State of each variable, described in Table 150.
|-
|||''bState''||State of each constraint, described in Table 151.
|-
|||''cState''||State of each general constraint, described in Table 152.
|-
|||''Solver''||Solver used ('mipSolve').
|-
|||''SolverAlgorithm''||Text description of solver algorithm used.
|-
|||''Prob''||Problem structure used.
|-valign="top"
|||''minlpSolve''||A structure with  warm start information.  Use with  WarmDefGLOBAL,  see example below.
|}
 
'''Description'''
 
To make a restart (warm start), just set the warm start flag, and call minlpSolve once again:
 
Prob.WarmStart = 1;
 
Result = tomRun('minlpSolve', Prob,  2);
 
minlpSolve will read warm start information from the minlpSolveSave.mat file. Another warm start (with same MaxFunc) is made by just calling tomRun again:
 
Result  = tomRun('minlpSolve', Prob,  2);
 
To make a restart from the warm start information in the Result structure, make a call to WarmDefGLOBAL before calling minlpSolve. WarmDefGLOBAL moves information from the Result structure to the Prob structure and sets the warm start flag, Prob.WarmStart = 1;
 
Prob = WarmDefGLOBAL('minlpSolve', Prob,  Result);


where Result is the result structure returned by the previous run. A warm start (with same MaxIter)  is done by just calling tomRun again:
==mipSolve==
 
Result  = tomRun('minlpSolve', Prob,  2);
 
To make another warm start with new MaxIter 100, say, redefine MaxIter as:
 
Prob.optParam.MaxIter = 100;
 
Then repeat the two lines:
 
Prob = WarmDefGLOBAL('minlpSolve', Prob,  Result);
 
Result  = tomRun('minlpSolve', Prob,  2);
 
====mipSolve====
 
'''Purpose'''


Solve mixed integer linear programming problems (MIP).
Solve mixed integer linear programming problems (MIP).


''mipSolve ''solves problems of the form
*[[mipSolve]]
 
 
<math>
\begin{array}{cccccc}
\min\limits_{x} & f(x) & = & c^{T}x &  \\s/t & x_{L} & \leq  & x  & \leq & x_{U} \\& b_{L} & \leq  & Ax & \leq & b_{U} \\ &      &      & \multicolumn{3}{l}{x_{j} \in \MATHSET{N} \ \ \forall j \in $I$}  \\
\end{array}
</math>
 
 
where <math>c, x, x_L, x_U \in \MATHSET{R}^{n}</math> , <math>A\in \MATHSET{R}^{m\times n}</math> and <math>b_L, b_U \in\MATHSET{R}^{m}</math>.The variables <math>x \in I</math> , the index subset of <math>1,...,n</math> are restricted to beintegers.
 
Starting with TOMLAB  version 4.0, ''mipSolve ''accepts upper and lower bounds on the linear constraints like most other TOMLAB  solvers. Thus it is no longer necessary to use slack variables to handle inequality constraints.
 
'''Calling  Syntax'''
 
Result = tomRun('mipSolve',Prob,...)
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''c''||The vector ''c ''in <math>c^{T}x</math>.
|-
|||''A ''||Constraint matrix for linear constraints.
|-
|||''b_L''||Lower bounds on the linear constraints. If empty, ''Prob.b U ''is used.
|-
|||''b_U''||Upper bounds on the linear constraints.
|-
|||''x_L''||Lower bounds on the variables.
|-
|||''x_U''||Upper bounds on the variables.
|-
|||''x_0''||Starting point.
|-valign="top"
|||''MaxCPU''||Maximal CPU Time (in seconds) to be used by mipSolve, stops with best point found.
|-
|||''QP.B''||Active set ''B 0 ''at start:
|-
|||||''B''(''i'') = 1: Include variable ''x''(''i'') is in basic set.
|-
|||||''B''(''i'') = 0: Variable ''x''(''i'') is set on its lower bound.
|-
|||||''B''(''i'') = ''-''1: Variable ''x''(''i'') is set on its upper bound.
|-valign="top"
|||''SolverLP''||Name of solver used for initial  LP subproblem. Default solver is used if empty, see ''GetSolver.m ''and ''tomSolve.m''.
|-valign="top"
|||''SolverDLP''||Name of solver used for the dual LP subproblems. Default  solver is used if empty, see ''GetSolver.m ''and ''tomSolve.m''.
|-
|||''PriLevOpt ''||Print level in ''lpSimplex ''and ''DualSolve'':
|-
|||||0: No output; ''> ''0: Convergence result;
|-
|||||''> ''1: Output every iteration; ''> ''2: Output each step in simplex algorithm.
|-
|||''PriLev''||Print level in ''mipSolve''.
|-
|||''SOL.optPar''||Parameters for the SOL solvers, if they are used as subsolvers.
|-
|||''SOL.PrintFile''||Name of print file for SOL solvers, if they are used as subsolvers.
|-
|||''MIP''||Structure with fields for integer optimization The following fields are used:
|-
|||''IntVars''||The set of integer variables.
|-
|||||If empty, all variables are assumed non-integer (LP problem)
|-
|||''VarWeight''||Weight for each variable in the variable selection phase.
|-
|||||A lower value gives higher priority. Setting ''Prob.MIP.VarWeight  ''= ''Prob.c'' improves convergence for knapsack problems.
|-
|||''DualGap''||''mipSolve ''stops if the duality  gap is less than ''DualGap''. To stop at the first found integer solution, set ''DualGap ''=1. For example, ''DualGap ''= 0.01 makes the algorithm stop if the solution is ''< ''1% from the optimal solution.
|-
|||''fIP''||An upper bound on the IP value wanted.  Makes it possible to cut branches and avoid node computations.
|-
|||''xIP''||The ''x''-value giving the ''fIP ''value.
|-
|||''KNAPSACK''||If solving a knapsack problem, set to true (1) to use a knapsack heuristic.
|-
|||''optParam''||Structure with special fields for optimization parameters, see Table 141.Fields used are: ''IterPrint'', ''MaxIter'', ''PriLev'', ''wait'', ''eps f ''and ''eps Rank''.
|-
|||''Solver''||Structure with fields for algorithm choices:
|-
|||''Alg''||Node selection method:
|-
|||||0: Depth first
|-
|||||1: Breadth first
|-
|||||2: Depth first. When integer solution found, switch to Breadth.
|-
|||''method''||Rule to select new variables in DualSolve/lpSimplex:
|-
|||||0: Minimum reduced cost, sort variables increasing. (Default)
|-
|||||1: Bland's rule (default).
|-
|||||2: Minimum reduced cost. Dantzig's rule.
|}
 
'''Description  of Outputs'''
 
{|
|-valign"top"
|''Result''||colspan="2"|Structure with result from optimization. The following fields are changed:
|-
|||''x_k''||Optimal point.
|-
|||''f_k''||Function value at optimum.
|-
|||''g_k''||Gradient value at optimum, ''c''.
|-
|||''v_k''||Lagrange multipliers, \[Constraints + lower + upper bounds\].
|-
|||''x_0''||Starting point.
|-
|||''f_0''||Function value at start.
|-
|||''xState''||State of each variable, described in Table 150, page 239.
|-
|||''Inform''||If ''ExitF lag > ''0, ''I nf orm ''= ''ExitF lag''.
|-
|||''QP.B''||Optimal active set. See input variable ''QP.B''.
|-
|||''QP.y''||Dual parameters ''y ''(also part of ''Result.v_k''.
|-
|||''p_dx''||Search steps in ''x''.
|-
|||''alphaV''||Step lengths for each search step.
|-
|||''ExitFlag''||0: OK.
|-
|||||1: Maximal number of iterations reached.
|-
|||||2: Empty feasible set, no integer solution found.
|-
|||||3: Rank problems. Can not find any solution point.
|-
|||||4: No feasible point found running LP relaxation.
|-
|||||5: Illegal''x_0 ''found in LP relaxation.
|-
|||||99: Maximal CPU Time used (cputime ''> ''Prob.MaxCPU).
|-
|||''Iter''||Number of iterations.
|-
|||''Solver''||Solver used ('mipSolve').
|-
|||''SolverAlgorithm''||Text description of solver algorithm used.
|-
|||''Prob''||Problem structure used.
|}
 
'''Description'''
 
The routine ''mipSolve ''is an implementation of a branch and bound algorithm from Nemhauser and Wolsey \[58, chap.  8.2\].  ''mipSolve ''normally uses the linear programming routines ''lpSimplex ''and ''DualSolve ''to solve relaxed subproblems. ''mipSolve ''calls the general interface routines ''SolveLP ''and ''SolveDLP''. By changing the setting of the structure fields ''Prob.Solver.SolverLP ''and ''Prob.Solver.SolverDLP'', different sub-solvers are possible to use, see the help for the interface routines.
 
'''Algorithm'''
 
See \[58, chap. 8.2\] and the code in ''mipSolve.m''.
 
'''Examples'''
 
See ''exip39'',  ''exknap'', ''expkorv''.
 
'''M-files  Used'''
 
''lpSimplex.m'', ''DualSolve.m'', ''GetSolver.m'', ''tomSolve.m''
 
'''See Also'''
 
''cutplane'', ''balas'', ''SolveLP'', ''SolveDLP''
 
====multiMin====
 
'''Purpose'''
 
multiMin  solves general constrained  mixed-integer global optimization problems. It tries to find all local minima by a multi-start  method using a suitable nonlinear programming subsolver.
 
''multiMin  ''solves problems of the form
 
 
<math>
\begin{array}{cccccc}
\min\limits_{x} & f(x) &  &  &  &  \\
s/t & x_{L} & \leq  & x    & \leq  & x_{U} \\
& b_{L} & \leq  & Ax  & \leq  & b_{U} \\
& c_{L} & \leq  & c(x) & \leq  & c_{U} \\
&      &      & \multicolumn{3}{c}{x_i \in \MATHSET{N} \; \forall i \in I} \\
\end{array}
</math>
 
where <math>x,x_{L},x_{U}\in \MATHSET{R}^{n}</math> , <math>c(x),c_{L},c_{U}\in \MATHSET{R}^{m_{1}}</math> , <math>A\in \MATHSET{R}^{m_{2}\times n}</math> and <math>b_{L},b_{U}\in \MATHSET{R}^{m_{2}}</math>.
 
The variables <math>x \in I</math> , the index subset of <math>1,...,n</math> are restricted to be integers.
 
The integer components of every x_0 is rounded to the nearest integer value inside simple bounds, and these components are fixed during the nonlinear local search.
 
If generating random points and there are linear constraints, multiMin  checks feasibility with respect to the linear constraints, and for each initial  point tries 100 times to get linear feasibility before accepting the initial  point.
 
'''Calling  Syntax'''
 
Result = multiMin(Prob, xInit)
 
Result = tomRun('multiMin', Prob, PriLev) (driver call)
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|''xInit''||colspan="2"|Either, 1x1 number - The number of random initial  points, default 10\*Prob.N dxm matrix - Every column is an initial  point (of length d=Prob.N). May also be set as Prob.xInit.
|-
|||''fCut''||If initial  f(x_0) ''> ''fCut, no local optimization is done.
|-valign="top"
|||''WarmStart''||If true, ''> ''0, multiMin assumes the field multiMin  defined with the output from a previous run on the same problem. See the Output fields of Result.multiMin. Use WarmDefGLOBAL  to set the correct fields in the Prob structure.  Nec- essary fields are fOpt and xOpt. If any of the other fields are missing, the corresponding variables are initialized to 0. These other fields are: localTry, Iter, FuncEv, GradEv, HessEv, ConstrEv Inform (is set to zeros(length(fOpt,1) if not defined).
|-
|||||In WarmDefGLOBAL the Result structure for the optimal run will be fed back to multiMin  as Prob.multiMin.ResOpt In case this field is not defined, and no better point is found during the runs, a special call to the localSolver is used to generate a proper Result structure.
|-valign="top"
|||''RandState''||If ''WarmStart ''and isscalar(xInit), RandState is used as follows: If  ''> ''0, rand('state',RandState) is set to initialize the pseudo-random generator if ''< ''0, rand('state',sum(100\*clock)) is set to give a new set of random values each run if RandState == 0, rand('state',) is not called Default RandState = -1
|-valign="top"
|||''xEqTol''||Tolerance to test if new point  x_k already defined as optimum: ''norm(xk - xOpt(:, i))'' <= ''xEqTol * max(1, norm(xk))'' If test fulfilled x_k is assumed to be too close to xOpt(:,i) Default xEqTol = 1E-5
|-
|||''x_L''||Lower bounds for each element in x. If generating random points, -inf elements of x L are set to -10000.
|-valign="top"
|||''x_U''||Upper bounds for each element in x. If generating random points, inf elements of x U are set to 10000.
|-
|||''A''||Constraint matrix for linear constraints.
|-
|||''b_L''||Lower bounds on the linear constraints.
|-
|||''b_U''||Upper bounds on the linear constraints.
|-
|||''c_L''||Lower bounds on the general constraints.
|-
|||''c_U''||Upper bounds on the general constraints.
|-
|||''PriLevOpt''||0 = silent.
|-
|||||1 = Display one row for each unique local minima found. The minima are sorted, lowest value first (possibly the global minima)
|-
|||||The following 4 information values are displayed:
|-
|||||1. Order \#
|-
|||||2. Function value f(x) at local minima
|-
|||||3. Point x at local minima. Only up to 10 values are displayed
|-
|||||4. Inform value returned from local Solver (normally 0)
|-
|||||2 = One row of output from each multiMin  local optimization trial
|-
|||||The following 6 information values are displayed:
|-
|||||1. Step \#
|-
|||||2. Text Old (previously found local minima), FAIL (solver failed to verify local minima) or blank (solver success, new local minima found)
|-
|||||3. Inform value from local solver
|-
|||||4. f(x_0) - function value f(x_0) for initial  x_0
|-
|||||5. f(x) - best f(x) value found in this local search
|-
|||||6. x - point for which best f(x) value was found in this local search. Only up to 10 values are displayed.
|-
3 = tomRun (PrintResult)  output from every optimization, print level 1.
|-
|||||4 = tomRun (PrintResult)  output from every optimization, print level 2. For constrained problems output  of sum(-constr-) and information if optimal point was accepted w.r.t.  feasibility.
|-
|||||5 = tomRun (PrintResult)  output from every optimization, print level 3.
|-
|||''GO''||Structure in ''Prob'', ''Prob.GO''. Fields used:
|-valign="top"
|||''localSolver''||The local solver used to run all local optimizations. Default is the license dependent output of GetSolver('con',1,0).
|-
|||''optParam''||Defines optimization parameters. Fields used:
|-valign="top"
|||''fGoal''||Goal for function value f(x), if empty not used. If fGoal is reached, no further local optimizations are done.
|-
|||''eps_f''||Relative accuracy for function value, fTol == eps_f. Stop if abs(f-fGoal) ''<''= abs(fGoal) \* fTol , if fGoal  = 0. Stop if abs(f-fGoal) ''<''= fTol , if fGoal ==0.
|-valign="top"
|||''bTol''||The local solver used to run all local optimizations. Default is the license dependent output of GetSolver('con',1,0).
|-valign="top"
|||''MIP.IntVars''||Structure in Prob, Prob.MIP. If empty, all variables are assumed non-integer (LP problem). If ''length''(''I ntV ars'') ''> ''1 ==''> length''(''I ntV ars'') == ''length''(''c'') should hold.  Then ''I ntV ars''(''i'')  == 1 ==''> x''(''i'')  integer. ''I ntV ars''(''i'')  == 0 ==''> x''(''i'')  real.  If  ''length''(''I ntV ars'')  ''< n'', IntVars  is assumed to be a set of indices.  It is advised to number the integer values as the first variables, before the continuous. The tree search will then be done more efficiently.
|-
|''varargin''||colspan="2"|Other parameters directly sent to low level routines.
|}


'''Description  of Outputs'''
==multiMin==


{|
multiMin solves general constrained mixed-integer global optimization problems. It tries to find all local minima by a multi-start method using a suitable nonlinear programming subsolver.
|''Result''||colspan="2"|Structure with result from optimization. The following fields are changed:
|-
|||colspan="2"|The following fields in Result are changed by multiMin  before return:
|-
|||''ExitFlag''||= 0 normal output, of if fGoal set and found.
|-
|||||= 1 A solution reaching the user defined fGoal was not found
|-
|||colspan="2"|The Solver, SolverAlgorithm and ExitText  fields are also reset.
|-
|||colspan="2"|A special field in Result is also returned, Result.multiMin:
|-valign="top"
|||''xOpt''||Prob.N x k matrix with k distinct local optima, the test being ''norm''(''xk -xOpt''(:'', i'')) ''<''= ''xEqT ol * max''(1'', norm''(''xk '')) that if fulfilled assumes x k to be to closeto xOpt(:,i)
|-
|||''fOpt''||The k function values in the local optima xOpt(:,i),i=1,...,k.
|-valign="top"
|||''Inform''||The Inform value returned by the local solver when finding each of the local optima xOpt(:,i);  i=1,...,k. The Inform value can be used to judge the validity of the local minimum reported.
|-
|||''localTry''||Total number of local searches.
|-
|||''Iter''||Total number of iterations.
|-
|||''FuncEv''||Total number of function evaluations.
|-
|||''GradEv''||Total number of gradient evaluations.
|-
|||''HessEv''||Total number of Hessian evaluations.
|-
|||''ConstrEv''||Total number of constraint function evaluations.
|-
|||''ExitText''||Text string giving ExitFlag and Inform information.
|}


====multiMINLP====
*[[multiMin]]


'''Purpose'''
==multiMINLP==


multiMINLP solves general constrained  mixed-integer global nonlinear optimization problems.
multiMINLP solves general constrained  mixed-integer global nonlinear optimization problems.


It is aimed for problems where the number of integer combinations nMax is huge and relaxation of the integer constraint is possible.
*[[multiMINLP]]
 
If no integer variables, multiMINLP calls multiMin. If nMax ''<''= min(Prob.optParam.MaxFunc,5000), glcDirect is used. Otherwise, multiMINLP first finds a set M of local minima calling multiMin  with no integer restriction on any variable. The best local minimum is selected.  glcDirect is called to find the best integer feasible solution fIP in a small area (''< ''+- 2 units) around the best local minimum found.
 
The other local minima are pruned, if fOpt(i) ''> ''fIP, no integer feasible solution could be found close to this local minimum i.
 
The area close to the remaining candidate local minima are searched one by one by calling glcDirect to find any fIPi ''< ''fIP.
 
''multiMINLP ''solves problems of the form
 
 
<math>
\begin{array}{cccccc}
\min\limits_{x} & f(x) \\
s/t & x_{L} & \leq  & x  & \leq & x_{U} \\
& b_{L} & \leq  & Ax & \leq & b_{U} \\
& c_{L} & \leq  & c(x) & \leq & c_{U} \\
&      &      & \multicolumn{3}{l}{x_{j} \in \MATHSET{N} \ \ \forall j \in $I$}  \\
\end{array}
</math>
 
where <math>x,x_{L},x_{U}\in \MATHSET{R}^{n}</math> , <math>c(x),c_{L},c_{U}\in
\MATHSET{R}^{m_{1}}</math> , <math> A\in \MATHSET{R}^{m_{2}\times n}</math> and
<math>b_{L},b_{U}\in \MATHSET{R}^{m_{2}}</math> . The variables <math>x \in I</math> , the index subset of <math>1,...,n</math> are restricted to be integers.
 
'''Calling  Syntax'''
 
Result = tomRun('multiMINLP',Prob,...)
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||||Prob is a structure, defined  as to solve a standard MINLP  problem. The Prob structure is fed to the localSolver. See e.g. minlpAssign.
|-
|||||See multiMin  and glcDirect for input to the subsolvers e.g. Prob.xInit is used in multiMin (and fCut, RandState, xEQTol).
|-valign="top"
|||''x_L''||Lower bounds for each element in x. If generating random points, -inf elements of x L are set to min(-L,xMin,x  U-L) xMin is the minimum of the finite x L values.
|-valign="top"
|||''x_U''||Upper bounds for each element in x. If generating random points, inf elements of x U are set to max(L,xMax,x L+L) xMax is the maximum of the finite x U values.
|-
|||||L is 100 for nonlinear least squares, otherwise 1000.
|-
|||''b_L''||Lower bounds on linear constraints.
|-
|||''b_U''||Upper bounds on linear constraints.
|-
|||''A''||The linear constraint matrix.
|-
|||''c_L''||Lower bounds on nonlinear constraints.
|-
|||''c_U''||Upper bounds on nonlinear constraints.
|-
|||''PriLev''||Print Level:
|-
|||||0 = Silent
|-
|||||1 = Display 2 summary rows
|-
|||||2 = Display some extra summary rows
|-
|||||5 = Print level 1 in tomRun call
|-
|||||6 = Print level 2 in tomRun call
|-
|||||7 = Print level 3 in tomRun call
|-
|||''xInit''||Used in multiMin. See help for multiMin.
|-valign="top"
|||''GO.localSolver ''||The local solver used to run all local optimizations. Default is the license dependent output of GetSolver('con',1,0).
|-valign="top"
|||''optParam''||Structure in Prob, Prob.optParam. Defines optimization parameters. Fields used:
|-
|||''MaxFunc''||Max number of function evaluations in each subproblem
|-
|||''fGoal''||Goal for function value f(x), if empty not used. If fGoal is reached, no further local optimizations are done
|-valign="top"
|||''eps_f''||Relative accuracy for function value, fTol == eps_f.  Stop if abs(f-fGoal) ''<''= abs(fGoal) \* fTol , if fGoal = 0. Stop if abs(f-fGoal) ''<''= fTol , if fGoal ==0. Default 1e-8.
|-
|||''bTol''||Linear constraint feasibility tolerance. Default 1e-6
|-
|||''cTol''||Nonlinear constraint feasibility tolerance. Default 1e-6
|-valign="top"
|||''MIP''||Structure in Prob, Prob.MIP. Defines integer optimization parameters. Fields used:
|-valign="top"
|||''IntVars''||If empty, all variables are assumed non-integer. If islogical(IntVars) (=all  el- ements are 0/1),  then 1 = integer variable, 0 = continuous variable. If any element ''>''1, IntVars is the indices for integer variables.
|-
|||''nMax''||Number of integer combinations possible, if  empty multiMINLP computes nMax.
|-
|||''Rfac''||Reduction factor for real variables in MINLP  subproblem  close to local multiMINLP minimum. Bounds set to x_L = max(x_L,x-Rfac\*(x_U-x_L)) and x_U= min(x_U,x+Rfac\*(x_U-x_L)). Default 0.25.
|}
 
'''Description  of Outputs'''
{|
|''Result''||colspan="2"|Structure with result from optimization. The following fields are changed:
|-
|||||Result structure from the last good optimization step giving the best f(x) value, the possible global MINLP  minimum.
|-
|||||The following fields in Result are changed by multiMINLP before return:
|-
|||''ExitFlag''||= 0 normal output, of if fGoal set and found.
|-
|||||= 1 A solution reaching the user defined fGoal was not found.
|-
|||||= 2 Unbounded problem.
|-
|||||=4 Infeasible problem.
|-
|||||The Solver, SolverAlgorithm and ExitText fields are also reset.
|-
|||||A special field in Result is also returned, Result.multiMINLP:
|-
|||''xOpt''||Prob.N x k matrix with k distinct  local optima, the test being norm(x k- xOpt(:,i)) ''<''= xEqTol\*max(1,norm(x k)) that if fulfilled assumes x_k to be to close to xOpt(:,i).
|-
|||''fOpt''||The k function values in the local optima xOpt(:,i),i=1,...,k.
|-
|||''Inform''||The Inform value returned by the local solver when finding each of the local optima xOpt(:,i);  i=1,...,k.  The Inform value can be used to judge the validity of the local minimum reported.
|-
|||''localTry''||Total number of local searches.
|-
|||''Iter''||Total number of iterations.
|-
|||''FuncEv''||Total number of function evaluations.
|-
|||''GradEv''||Total number of gradient evaluations.
|-
|||''HessEv''||Total number of Hessian evaluations.
|-
|||''ConstrEv''||Total number of constraint function evaluations.
|-
|||''ExitText''||Text string giving Inform information.
|}


====nlpSolve====
==nlpSolve==
 
'''Purpose'''


Solve general constrained nonlinear optimization problems.
Solve general constrained nonlinear optimization problems.


''nlpSolve ''solves problems of the form
*[[nlpSolve]]
 
 
<math>
\begin{array}{cccccc}
\min\limits_{x} & f(x) &  &  &  &  \\
s/t & x_{L} & \leq  & x    & \leq  & x_{U} \\
& b_{L} & \leq  & Ax  & \leq  & b_{U} \\
& c_{L} & \leq  & c(x)    & \leq  & c_{U}
\end{array}
</math>
 
 
where <math>x,x_{L},x_{U}\in \MATHSET{R}^{n}</math> , <math>c(x),c_{L},c_{U}\in \MATHSET{R} ^{m_{1}}</math> , <math>A\in \MATHSET{R}^{m_{2}\times n}</math> and <math>b_{L},b_{U}\in \MATHSET{R}^{m_{2}}</math>.
 
'''Calling  Syntax'''
 
Result = nlpSolve(Prob, varargin)
 
Result = tomRun('nlpSolve', Prob);
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''A''||Constraint matrix for linear constraints.
|-
|||''b_L''||Lower bounds on the linear constraints.
|-
|||''b_U''||Upper bounds on the linear constraints.
|-
|||''c_L''||Lower bounds on the general constraints.
|-
|||''c_U''||Upper bounds on the general constraints.
|-
|||''x_L''||Lower bounds on the variables.
|-
|||''x_U''||Upper bounds on the variables.
|-
|||''x_0''||Starting point.
|-valign="top"
|||''PriLevOpt''||Print level: 0 Silent, 1 Final result, 2 Each iteration, short, 3 Each iteration, more info, 4 Matrix  update information.
|-
|||''FUNCS.f''||Name of m-file computing the objective function ''f ''(''x'').
|-
|||''FUNCS.g''||Name of m-file computing the gradient vector ''g''(''x'').
|-
|||''FUNCS.H''||Name of m-file computing the Hessian matrix ''H ''(''x'').
|-
|||''FUNCS.c''||Name of m-file computing the vector of constraint functions ''c''(''x'').
|-
||||''FUNCS.dc''||Name of m-file computing the matrix of constraint normals ''?c''(''x'')''/dx''.
|-valign="top"
|||''FUNCS.d2c''||Name of m-file computing the second derivatives of the constraints, weighted by an input Lagrange vector
|-
|||''NumDiff''||How to obtain derivatives (gradient, Hessian).
|-
|||''ConsDiff''||How to obtain the constraint derivative matrix.
|-
|||''SolverQP''||Name of the solver used for QP subproblems. If empty, the default solver is used. See GetSolver.m and tomSolve.m.
|-
|||''SolverFP''||Name of the solver used for FP subproblems. If empty, the default solver is used. See GetSolver.m and tomSolve.m.
|-
|||''optParam''||Structure with special fields for optimization parameters,  see Table 141.
|-
|||||Fields used are: ''eps_g'', ''eps_x'', ''MaxIter'', ''wait'', ''size_x'', ''method'', ''IterPrint'', ''xTol'', ''bTol'', ''cTol'', and ''QN InitMatrix''.
|-
|''varargin''||colspan="2"|Other parameters directly sent to low level routines.
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization. The following fields are changed:
|-
|||''x_k''||Optimal point.
|-
|||''f_k''||Function value at optimum.
|-
|||''g_k''||Gradient value at optimum.
|-
|||''c_k''||Value of constraints at optimum.
|-
|||''H_k''||Hessian value at optimum.
|-
|||''v_k''||Lagrange multipliers.
|-
|||''x_0''||Starting point.
|-
|||''f_0''||Function value at start.
|-
|||''cJac''||Constraint Jacobian at optimum.
|-
|||''xState''||State of each variable, described in Table 150.
|-
|||''bState''||State of each linear constraint, described in Table 151.
|-
|||''cState''||State of each general constraint.
|-
|||''Inform''||Type of convergence.
|-
|||''ExitFlag''||Flag giving exit status.
|-
|||''ExitText''||0: Convergence. Small step. Constraints fulfilled.
|-
|||||1: Infeasible problem?
|-
|||||2: Maximal number of iterations reached.
|-
|||||3: No progress in either function value or constraint reduction.
|-
|||''Inform''||1: Iteration points are close.
|-
|||||2: Small search direction
|-
|||||3: Function value below given estimate. Restart with lower fLow if minimum not reached.
|-
|||||4: Projected gradient small.
|-
|||||10: Karush-Kuhn-Tucker conditions fulfilled.
|-
|||''Iter''||Number of iterations.
|-
|||''Solver''||Solver used.
|-
|||''SolverAlgorithm''||Solver algorithm used.
|-
|||''Prob''||Problem structure used.
|}
 
'''Description'''
 
The routine ''nlpSolve ''implements the Filter SQP by Roger Fletcher and Sven Leyffer presented in the paper \[21\].
 
'''M-files  Used'''
 
''tomSolve.m'', ''ProbCheck.m'', ''iniSolve.m'', ''endSolve.m''
 
'''See Also'''
 
''conSolve'', ''sTrustr''
 
====pdcoTL====
 
'''Purpose'''
 
''pdcoTL ''solves linearly constrained convex nonlinear optimization problems of the kind
 
 
<math>
\begin{array}{cccccc}
\min\limits_x & f(x) \\
\mathrm{s/t} & x_L & \leq & x  & \leq & x_U \\
{}          & b_L & \leq & Ax & \leq & b_U \\
\end{array}
</math>
 
 
where <math>f(x)</math> is a convex nonlinear function, <math>x,x_L,x_U \in \RR^n</math> , <math>A\in \RR^{m \times n}</math> and <math>b_L, b_U \in \RR^m</math>.
 
'''Calling  Syntax'''
 
Result=tomRun('pdco',Prob,...);
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''x_0''||Initial ''x ''vector, used if non-empty.
|-
|||''A''||The linear constraint matrix.
|-
|||''b_L,b_U''||Lower and upper bounds for the linear constraints.
|-
|||''PriLevOpt''||Print level in ''pdsco ''solver. If ''> ''0: prints summary information.
|-
|||''SOL''||Structure with SOL special parameters:
|-
|||''pdco''||Options structure with fields as defined  by ''pdcoSet''.
|-valign="top"
|||''d1''||Primal regularization vector. Must be a positive vector (length ''n'') or scalar, in which case ''D''1 = ''diag''(''d''1) is used. Default: 10''-''4 .
|-valign="top"
|||''d2''||Dual regularization vector.  Must be a positive vector (length ''m'') or a scalar value, in which case ''D''2 = ''diag''(''d''2) is used. Default: 10''-''4 .
|-
|||''y0''||Initial  dual parameters for linear constraints (default 0)
|-valign="top"
|||''z0''||Initial  dual parameters for simple bounds (default 1''/N '')
''xsize'',''zsize ''are used to scale (''x, y, z''). Good estimates should improve the performance of the barrier method.
|-
|||''xsize''||Estimate of the biggest x at the solution. (default 1''/N '')
|-
|||''zsize''||Estimate of the biggest z at the solution. (default 1''/N '')
|-
|||''optParam''||Structure with optimization parameters. The following fields are used:
|-
|||''MaxIter''||Maximum number of iterations. (''Prob.SOL.pdco.MaxIter'').
|-valign="top"
|||''MinorIter''||Maximum number of iterations in ''LSQR'' (''Prob.SOL.pdco.LSQRMaxIter'').
|-
|||''eps_x''||Accuracy for satisfying ''x''1 ''. * z''1 = 0'', x''2 ''.z''1 = 0, where ''z ''= ''z''1 ''- z''2 and ''z''1 '', z''2 ''> ''0.(''Prob.SOL.pdco.OptTol'')
|-valign="top"
|||''bTol''||Accuracy for satisfying ''Ax ''+ ''D''2 ''r ''= ''b'', ''AT y ''+ ''z ''= ''?f ''(''x'') and ''x - x''1  = ''bL , x ''+''x''2 = ''bU '', where ''x''1 '', x''2  ''> ''0 (''Prob.SOL.pdco.FeaTol'')
|-
|||''wait''||0 - solve the problem with default internal parameters; 1 - pause: allows interactive resetting of parameters. (''Prob.SOL.pdco.wait'')
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization. The following fields are set by ''pdcoTL''
|-
|||''x_k''||Solution vector
|-
|||''f_k''||Function value at optimum
|-
|||''g_k''||Gradient of the function at the solution
|-
|||''H_k''||Hessian of the function at the solution, diagonal only
|-
|||''x_0''||Initial  solution vector
|-
|||''f_0''||Function value at start, x = x_0
|-
|||''xState''||State of variables. Free == 0; On lower == 1; On upper == 2; Fixed == 3;
|-valign="top"
|||''bState''||State of linear constraints.  Free == 0; Lower == 1; Upper == 2; Equality == 3;
|-
|||''v_k''||Lagrangian multipliers (orignal bounds + constraints )
|-valign="top"
|||''y_k''||Lagrangian multipliers (for bounds + dual solution vector) The full \[''z''; ''y''\] vec- tor as returned from ''pdco'', including slacks and extra linear constraints after rewriting constraints:  ''-inf  < b L < A * x < b U < inf ''; non-inf lower AND upper bounds
|-
|||''ExitFlag''||Tomlab Exit status from ''pdco ''MEX
|-
|||''Inform''||''pdco''information parameter: 0 = Solution found;
|-
|||0||Solution found
|-
|||1||Too many iterations
|-
|||2||Linesearch failed too often
|-
|||''Iter''||Number of iterations
|-
|||''FuncEv''||Number of function evaluations
|-
|||''GradEv''||Number of gradient evaluations
|-
|||''HessEv''||Number of Hessian evaluations
|-
|||''Solver''||Name of the solver ('pdco')
|-
|||''SolverAlgorithm''||Description of the solver
|}
 
'''Description'''
 
''pdco ''implements an primal-dual barrier method developed at Stanford Systems Optimization Laboratory (SOL).
 
The problem (19) is first reformulated into SOL PDCO form:
 
 
<math>
\begin{array}{cccccc}
\min\limits_x & f(x) \\
\mathrm{s/t} & x_L & \leq & x  & \leq & x_U \\
{}          &    &      & Ax &  =  & b \\
{}          & \multicolumn{5}{l}{r \mathrm{\ unconstrained}} \\
\end{array}
</math>
 
 
The problem actually solved by ''pdco ''is
 
 
<math>
\begin{array}{lllcll}
\min\limits_{x,r} &
\multicolumn{5}{l}{\phi(x) + \frac{1}{2}\|D_1 x\|^2 + \frac{1}{2}\|r\|^2 } \\
\\
\mathrm{s/t}  & x_L & \leq & x      & \leq & x_U  \\
{}            & Ax  &  +  & D_{2}r &  =  & b    \\
\end{array}
</math>
 
 
where <math>D_1</math> and <math>D_2</math> are positive-definite diagonal matrices defined from <math>d_1</math>, <math>d_2</math> given in Prob.SOL.d1 and Prob.SOL.d2.
 
In particular, <math>d_2</math> indicates the accuracy required for satisfying each row of <math>Ax=b</math>. See ''pdco'' for a detailed discussion of <math>D_1</math> and <math>D_2</math>. Note that in ''pdco'', the objective <math>f(x)</math> is denoted <math>\phi(x)</math>, <math>bl == x\_L</math> and <math>bu == x\_U</math>.
 
'''Examples'''
 
Problem 14 and 15 in ''tomlab/testprob/con prob.m.m ''are good examples of the use of ''pdcoTL''.
 
'''M-files  Used'''
 
''pdcoSet.m'', ''pdco.m'', ''Tlsqrmat.m''
 
'''See Also'''
 
''pdscoTL.m''
 
====pdscoTL====
 
'''Purpose'''
 
''pdscoTL ''solves linearly constrained convex nonlinear optimization problems of the kind
 
 
<math>
\begin{array}{cccccc}
\min\limits_x & f(x) \\
\mathrm{s/t} & x_L & \leq & x  & \leq & x_U \\
{}          & b_L & \leq & Ax & \leq & b_U \\
\end{array}
</math>
 
where <math>f(x)</math> is a convex separable nonlinear function, <math>x,x_L,x_U
\in \RR^n</math> , <math>A\in \RR^{m \times n}</math> and <math>b_L, b_U \in\RR^m</math>.
 
'''Calling  Syntax'''
 
Result=tomRun('pdsco',Prob,...);
 
'''Description  of Inputs'''
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''x_0''||Initial ''x ''vector, used if non-empty.
|-
|||''A''||The linear constraints coefficient matrix.
|-
|||''b_L,b_U''||Lower and upper bounds for the linear constraints.
|-valign="top"
|||''HessPattern''||Non-zero pattern for the objective function. Only the diagonal is needed. Default if empty is the unit matrix.
|-
|||''PriLevOpt''||Print level in ''pdsco ''solver. If ''> ''0: prints summary information.
|-
|||''SOL''||Structure with SOL special parameters:
|-
|||''pdco''||Options structure with fields as defined  by ''pdscoSet''.
|-
|||''gamma''||Primal regularization parameter.
|-
|||''delta''||Dual regularization parameter.
|-
|||''y0''||Initial  dual parameters for linear constraints (default 0)
|-
|||''z0''||Initial  dual parameters for simple bounds (default 1''/N '')
|-
|||||''xsize'',''zsize ''are used to scale (''x, y, z''). Good estimates should improve the performance of the barrier method.
|-
|||''xsize''||Estimate of the biggest ''x ''at the solution. (default 1''/N '')
|-
|||''zsize''||Estimate of the biggest ''z ''at the solution. (default 1''/N '')
|-
|||''optParam''||Structure with optimization parameters. The following fields are used:
|-
|||''MaxIter''||Maximum number of iterations. (''Prob.SOL.pdco.MaxIter'').
|-
|||''MinorIter''||Maximum number of iterations in ''LSQR ''(''Prob.SOL.pdco.LSQRMaxIter'').
|-
|||''eps_x''||Accuracy for satisfying ''x. * z ''= 0
|-valign="top"
|||''bTol''||Accuracy for satisfying ''Ax ''+ ''r ''= ''b'', ''AT y ''+ ''z ''= ''?f ''(''x'') and ''x - x''1  = ''bL , x ''+ ''x''2 =''bU'', where ''x''1 '', x''2  ''> ''0. (''Prob.SOL.pdco.FeaTol'')
|-valign="top"
|||''wait''||0 - solve the problem with default internal parameters; 1 - pause: allows interactive resetting of parameters. (''Prob.SOL.pdco.wait'')
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization. The following fields are set by ''pdscoTL'':
|-
|||''x_k''||Solution vector
|-
|||''f_k''||Function value at optimum
|-
|||''g_k''||Gradient of the function at the solution
|-
|||''H_k''||Hessian of the function at the solution, diagonal only
|-
|||''x_0''||Initial  solution vector
|-
|||''f_0''||Function value at start, x = x_0
|-
|||''xState''||State of variables. Free == 0; On lower == 1; On upper == 2; Fixed == 3;
|-
|||''bState''||State of linear constraints.  Free == 0; Lower == 1; Upper == 2; Equality == 3;
|-
|||''v_k''||Lagrangian multipliers (orignal bounds + constraints )
|-valign="top"
|||''y k''||Lagrangian multipliers (for bounds + dual solution vector) The full \[''z''; ''y''\] vec- tor as returned from ''pdsco'', including slacks and extra linear constraints after rewriting constraints:  ''-inf  < b L < A * x < b U < inf ''; non-inf lower AND upper bounds
|-
|||''ExitFlag''||Tomlab Exit status from ''pdsco ''MEX
|-
|||''Inform''||''pdsco ''information parameter: 0 = Solution found;
|-
|||0||Solution found
|-
|||1||Too many iterations
|-
|||2||Linesearch failed too often
|-
|||''Iter''||Number of iterations
|-
|||''FuncEv''||Number of function evaluations
|-
|||''GradEv''||Number of gradient evaluations
|-
|||''HessEv''||Number of Hessian evaluations
|-
|||''Solver''||Name of the solver ('pdsco')
|-
|||''SolverAlgorithm''||Description of the solver
|}
 
'''Description'''
 
''pdsco ''implements  an primal-dual barrier method developed at Stanford Systems Optimization Laboratory (SOL). The problem (20) is first reformulated into SOL PDSCO form:
 


<math>
==pdcoTL==
\begin{array}{clll}
\min\limits_x  & f(x) \\
\mathrm{s/t} & x  & \geq & x_U \\
{}          & Ax &  = & b. \\
\end{array}
</math>


''pdcoTL ''solves linearly constrained convex nonlinear optimization problems.


The problem actually solved by ''pdsco ''is
*[[pdcoTL]]


==pdscoTL==


<math>
''pdscoTL'' solves linearly constrained convex nonlinear optimization problems.
\begin{array}{lllcll}
\min\limits_{x,r} &
\multicolumn{5}{l}{f(x) +
\frac{1}{2}\|\gamma x\|^2 + \frac{1}{2}\|r / \delta \|^2 } \\
\\
\mathrm{s/t}  &    &      & x & \geq & 0  \\
{}            & Ax  &  +  & r &  =  & b  \\
{}            & \multicolumn{5}{l}{r \mathrm{\ unconstrained}} \\
\end{array}
</math>


*[[pdscoTL]]


where <math>\gamma</math> is the primal regularization parameter, typically small but 0 is allowed. Furthermore, <math>\delta</math> is the dual regularization parameter, typically small or 1; must be strictly greater than zero.
==qpSolve==
 
With positive <math>\gamma,\delta</math> the primal-dual solution <math>(x,y,z)</math> is bounded and unique.
 
See ''pdsco'' for a detailed discussion of </math>\gamma</math> and <math>\delta</math>. Note that in ''pdsco'', the objective <math>f(x)</math> is denoted <math>\phi(x)</math>, <math>bl == x\_L</math> and <math>bu == x\_U</math>.
 
'''Examples'''
 
Problem 14 and 15 in tomlab/testprob/con prob.m are good examples of the use of ''pdscoTL''.
 
'''M-files  Used'''
 
''pdscoSet.m'', ''pdsco.m'', ''Tlsqrmat.m''
 
'''See Also'''
 
''pdcoTL.m''
 
====qpSolve====
 
'''Purpose'''


Solve general quadratic programming problems.
Solve general quadratic programming problems.


''qpSolve ''solves problems  of the form
*[[qpSolve]]
 
 
<math>
\begin{array}{cccccl}
\min\limits_{x} & f(x) & = & \frac{1}{2}(x)^{T}Fx + c^{T}x &  &  \\s/t & x_{L} & \leq  & x  & \leq  & x_{U} \\& b_{L} & \leq  & Ax  & \leq  & b_{U} \\
\end{array}
</math>
 
 
where <math>x,x_{L},x_{U}\in \MATHSET{R} ^{n}</math>, <math>F\in \MATHSET{R}^{n\times n}</math>, <math>c \in \MATHSET{R}^{n}</math>, <math>A\in \MATHSET{R}^{m\times n}</math> and <math>b_{L},b_{U}\in \MATHSET{R}^{m}</math>.
 
'''Calling  Syntax'''
 
Result = qpSolve(Prob) or
 
Result = tomRun('qpSolve', Prob, 1);
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''QP.F''||Constant matrix, the Hessian.
|-
|||''QP.c''||Constant vector.
|-
|||''A''||Constraint matrix for linear constraints.
|-
|||''b_L''||Lower bounds on the linear constraints.
|-
|||''b_U''||Upper bounds on the linear constraints.
|-
|||''x_L''||Lower bounds on the variables.
|-
|||''x_U''||Upper bounds on the variables.
|-
|||''x_0''||Starting point.
|-valign="top"
|||''optParam''||Structure with special fields for optimization parameters, see Table 141.Fields used are: ''eps f'', ''eps Rank'', ''MaxIter'', ''wait'', ''bTol ''and ''PriLev''.
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization.  The following fields are changed:
|-
|||''x_k''||Optimal point.
|-
|||''f_k''||Function value at optimum.
|-
|||''g_k''||Gradient value at optimum.
|-
|||''H_k''||Hessian value at optimum.
|-
|||''v_k''||Lagrange multipliers.
|-
|||''x_0''||Starting point.
|-
|||''f_0''||Function value at start.
|-
|||''xState''||State of each variable, described in Table 150 .
|-
|||''Iter''||Number of iterations.
|-
|||''ExitFlag''||0: OK, see ''Inform ''for type of convergence.
|-
|||||2: Can not find feasible starting point ''x_0''.
|-
|||||3: Rank problems. Can not find any solution point.
|-
|||||4: Unbounded solution.
|-
|||||10: Errors in input parameters.
|-valign="top"
|||''Inform''||If ''ExitF lag > ''0, ''I nf orm ''= ''ExitF lag'', otherwise ''I nf orm ''show type of convergence:
|-
|||||0: Unconstrained solution.
|-
|||||1: ''? = ''0.
|-
|||||2: ''? = ''0. No second order Lagrange mult. estimate available.
|-
|||||3: ''? ''and 2nd order Lagr. mult.  positive, problem is not negative definite.
|-
|||||4: Negative definite problem. 2nd order Lagr.  mult. positive, but releasing variables leads to the same working set.
|-
|||''Solver''||Solver used.
|-
|||''SolverAlgorithm''||Solver algorithm used.
|-
|||''Prob''||Problem structure used.
|}
 
'''Description'''
 
Implements an active set strategy for Quadratic Programming. For negative definite problems it computes eigen- values and is using directions of negative curvature to proceed. To find an initial  feasible point the Phase 1 LP problem is solved calling ''lpSimplex''. The routine is the standard QP solver used by ''nlpSolve'', ''sTrustr ''and ''conSolve''.
 
'''M-files  Used'''
 
''ResultDef.m'', ''lpSimplex.m'', ''tomSolve.m'', ''iniSolve.m'', ''endSolve.m''
 
'''See Also'''
 
''qpBiggs'', ''qpe'', ''qplm'', ''nlpSolve'', ''sTrustr ''and ''conSolve''


====slsSolve====
==slsSolve==
 
'''Purpose'''


Find a Sparse Least Squares (sls) solution to a constrained least squares problem with  the use of any suitable TOMLAB  NLP solver.
Find a Sparse Least Squares (sls) solution to a constrained least squares problem with  the use of any suitable TOMLAB  NLP solver.


''slsSolve ''solves problems of the type:
*[[slsSolve]]
 
 
<math>
\begin{array}{cccccc}
\min\limits_x & \frac{1}{2}r(x)^T r(x)\\\mbox{subject to} & x_L & \leq &    x & \leq & x_U \\{}                & b_L & \leq &  Ax & \leq & b_U \\{}                & c_L & \leq & c(x) & \leq & c_U \\
\end{array}
</math>
 
 
where <math>x,x_L,x_U \in \Rdim{n}</math>, <math>r(x) \in \Rdim{m}</math>, <math>A \in\Rdim{m_1,n}</math>, <math>b_L,b_U \in \Rdim{m_1}</math> and <math>c(x),c_L,c_U \in\Rdim{m_2}</math>.
 
The use of ''slsSolve ''is mainly for large, sparse problems, where the structure in the Jacobians of the residuals and the nonlinear constraints are utilized by a sparse NLP solver, e.g. ''SNOPT''.
 
'''Calling  Syntax'''
 
Result=slsSolve(Prob,PriLev)
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure.  Should be created in the '''cls '''format, preferably by calling''Prob=clsAssign(...) ''if using the '''TQ  '''format.
|-
|||colspan="2"|slsSolve uses two special fields in ''Prob'':
|-valign="top"
|||''SolverL2''||Text  string with  name of the NLP solver used for solving the reformulated problem. Valid choices are ''conSolve'', ''nlpSolve'', ''sTrustr'', ''clsSolve''. Suitable SOL solvers, if available: ''minos'', ''snopt'', ''npopt''.
|-valign="top"
|||''L2Type''||Set to 1 for standard constrained formulation. Currently this is the only allowed choice.
|-
|||colspan="2"|All other fields should be set as expected  by the nonlinear solver selected. In particular:
|-
|||''A''||Linear constraint matrix.
|-
|||''b_L''||Lower bounds on the linear constraints.
|-
|||''b_U''||Upper bounds on the linear constraints.
|-
|||''c_L''||Upper bounds on the nonlinear constraints.
|-
|||''c_U''||Lower bounds on the nonlinear constraints.
|-
|||''x_L''||Lower bounds on the variables.
|-
|||''x_U''||Upper bounds on the variables.
|-
|||''x_0''||Starting point.
|-
|||''ConsPattern''||The nonzero pattern of the constraint Jacobian.
|-
|||''JacPattern''||The nonzero pattern of the residual Jacobian.
|-
|||||Note that  ''Prob.LS.y ''must be of correct length if ''JacPattern ''is empty (but ConsPattern is not). ''slsSolve ''will create the new ''Prob.ConsPattern ''to be used by the nonlinear solver using the information in the supplied ''ConsPattern ''and ''JacPattern''.
|-
|||''PriLev''||Print level in ''slsSolve''. Default value is 2.
|-
|||0||Silent except for error messages.
|-
|||''> ''1||Print summary information about problem transformation. ''slsSolve ''calls ''Print- Result(Result,PriLev)''.
|-
|||2||Standard output in PrintResult.
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with results from optimization. The contents of ''Result ''depend on which nonlinear solver was used to solved
|-
|||colspan="2"|''slsSolve ''transforms the following fields of ''Result ''back to the format of the original problem:
|-
|||''x_k''||Optimal point.
|-
|||''r_k''||Residual at optimum.
|-
|||''J_k''||Jacobian of residuals at optimum.
|-
|||''c_k''||Nonlinear constraint vector at optimum.
|-
|||''v_k''||Lagrange multipliers.
|-
|||''g_k''||The gradient vector is calculated as ''J kT  · r k''.
|-
|||''cJac''||Jacobian of nonlinear constraints at optimum.
|-
|||''x_0''||Starting point.
|-
|||''xState''||State of variables at optimum.
|-
|||''cState''||State of constraints at optimum.
|-
|||''Result.Prob''||The problem structure defining the reformulated problem.
|}
 
'''Description'''
 
The constrained least squares problem is solved in slsSolve by rewriting  the problem as a general constrained optimization problem. A set of ''m ''(the number of residuals) extra variables <math>z=(z_1,z_2,\ldots,z_m)</math> are added at the end of the vector of unknowns. The reformulated problem
 
 
<math>
\begin{array}{cccccc}
\min \limits_x & \multicolumn{5}{l}{\frac{1}{2} z^T z} \\
\mbox{subject to} & x_L & \leq & (x_1,x_2,\ldots,x_n) & \leq & x_U \\
{}                & b_L & \leq &  Ax                & \leq & b_U \\
{}                & c_L & \leq & c(x)                & \leq & c_U \\
{}                & 0  & \leq & r(x) - z            & \leq &  0 \\
\end{array}
</math>
 
 
is then solved by the solver given by ''Prob.SolverL2''.
 
'''Examples'''
 
''slsDemo.m''
 
'''M-files  Used'''


''iniSolve.m'', ''GetSolver.m''
==sTrustr==
 
====sTrustr====
 
'''Purpose'''


Solve optimization problems constrained by a convex feasible region.
Solve optimization problems constrained by a convex feasible region.


''sTrustr ''solves problems of the form
*[[sTrustr]]


==Tfmin==


<math>
Minimize function of one variable. Find miniumum x in [x_L, x_U] for function Func within tolerance xTol. Solves using Brents minimization algorithm.
\begin{array}{cccccc}
\min\limits_{x} & f(x) &  &  &  &  \\
s/t & x_{L} & \leq  & x    & \leq  & x_{U} \\
& b_{L} & \leq  & Ax  & \leq  & b_{U} \\
& c_{L} & \leq  & c(x) & \leq & c_{U} \\
\end{array}
</math>


*[[Tfmin]]


where <math>x,x_{L},x_{U}\in \MATHSET{R}^{n}</math>, <math>c(x),c_{L},c_{U}\in \MATHSET{R}^{m_{1}}</math>, <math>A\in \MATHSET{R}^{m_{2}\times n}</math> and <math>b_{L},b_{U}\in \MATHSET{R}^{m_{2}}</math>.
==Tfzero==
 
'''Calling  Syntax'''
 
Result = sTrustr(Prob, varargin)
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''A ''||Constraint matrix for linear constraints.
|-
|||''b_L''||Lower bounds on the linear constraints.
|-
|||''b_U''||Upper bounds on the linear constraints.
|-
|||''c_L''||Lower bounds on the general constraints.
|-
|||''c_U''||Upper bounds on the general constraints.
|-
|||''x_L''||Lower bounds on the variables.
|-
|||''x_U''||Upper bounds on the variables.
|-
|||''x_0''||Starting point.
|-
|||''FUNCS.f''||Name of m-file computing the objective function ''f ''(''x'').
|-
|||''FUNCS.g''||Name of m-file computing the gradient vector ''g''(''x'').
|-
|||''FUNCS.H''||Name of m-file computing the Hessian matrix ''H ''(''x'').
|-
|||''FUNCS.c''||Name of m-file computing the vector of constraint functions ''c''(''x'').
|-
|||''FUNCS.dc''||Name of m-file computing the matrix of constraint normals ''?c''(''x'')''/dx''.
|-
|||''optParam''||Structure with special fields for optimization parameters, see Table 141.
|-
|||||Fields used are: ''eps f'', ''eps g'', ''eps c'', ''eps x'', ''eps Rank'', ''MaxIter'', ''wait'', ''size x'', ''size f'', ''xTol'', ''LowIts'', ''PriLev'', ''method ''and ''QN InitMatrix''.
|-
|||''PartSep''||Structure with special fields for partially separable functions, see Table 142.
|-
|||''varargin''||Other parameters directly sent to low level routines.
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization. The following fields are changed:
|-
|||''x_k''||Optimal point.
|-
|||''f_k''||Function value at optimum.
|-
|||''g_k''||Gradient value at optimum.
|-
|||''c_k''||Value of constraints at optimum.
|-
|||''H_k''||Hessian value at optimum.
|-
|||''v_k''||Lagrange multipliers.
|-
|||''x_0''||Starting point.
|-
|||''f_0''||Function value at start.
|-
|||''cJac''||Constraint Jacobian at optimum.
|-
|||''xState''||State of each variable, described in Table 150.
|-
|||''Iter''||Number of iterations.
|-
|||''ExitFlag''||Flag giving exit status.
|-
|||''Inform''||Binary code telling type of convergence:
|-
|||||1: Iteration points are close.
|-
|||||2: Projected gradient small.
|-
|||||3: Iteration points are close and projected gradient small.
|-
|||||4: Relative function value reduction low for ''LowIts ''iterations.
|-
|||||5: Iteration points are close and relative function value reduction low for LowIts iterations.
|-
|||||6: Projected gradient small and relative function value reduction low for LowIts iterations.
|-
|||||7:  Iteration  points are close, projected gradient  small and relative  function value reduction low for LowIts iterations.
|-
|||||8: Too small trust region.
|-
|||||9: Trust region small. Iteration points close.
|-
|||||10: Trust region and projected gradient small.
|-
|||||11: Trust region and projected gradient small, iterations close.
|-
|||||12: Trust region small, Relative f(x) reduction low.
|-
|||||13: Trust region small, Relative f(x) reduction low. Iteration points are close.
|-
|||||14: Trust region small, Relative f(x) reduction low. Projected gradient small.
|-
|||||15:  Trust  region small, Relative  f(x)  reduction low. Iteration  points close, Projected gradient small.
|-
|||||101: Maximum number of iterations reached.
|-
|||||102: Function value below given estimate.
|-
|||||103: Convergence to saddle point (eigenvalues computed).
|-
|||''Solver''||Solver used.
|-
|||''SolverAlgorithm ''||Solver algorithm used.
|-
|||''Prob''||Problem structure used.
|}
 
'''Description'''
 
The routine ''sTrustr ''is a solver for general constrained optimization, which uses a structural trust region algorithm combined with an initial  trust region radius algorithm (''itrr''). The feasible region defined by the constraints must be convex. The code is based on the algorithms in \[13\] and \[67\]. BFGS or DFP is used for the Quasi-Newton update, if the analytical Hessian is not used. ''sTrustr ''calls internal routine ''itrr''.
 
'''M-files  Used'''
 
''qpSolve.m'', ''tomSolve.m'', ''iniSolve.m'', ''endSolve.m''
 
'''See Also'''
 
''conSolve'', ''nlpSolve'', ''clsSolve''
 
====Tfmin====
 
'''Purpose'''
 
Minimize function of one variable. Find miniumum x in [x_L, x_U] for function Func within tolerance xTol.  Solves using Brents minimization algorithm. Reference: "Computer Methods for Mathematical Computations", Forsythe, Malcolm, and Moler, Prentice-Hall, 1976.
 
 
'''Calling  Syntax'''
 
[x, nFunc] = Tfmin(Func, x_L, x_U, xTol, Prob)
 
'''Description  of Inputs'''
 
{|
|''Variable''||Description
|-
|''Func''||Function of x to be minimized. Func must be defined as:
|-
|||f = Func(x) if no 5th argument Prob is given or
|-
|||f = Func(x, Prob) if 5th argument Prob is given.
|-
|''x_L''||Lower bound on x.
|-
|''x_U''||Upper bound on x.
|-
|''xTol''||Tolerance on accuracy of minimum.
|-valign="top"
|''Prob''||Structure (or any Matlab variable) sent to Func. If many parameters are to be sent to Func set them in Prob as a structure.  Example for parameters a and b:
|-
|||Prob.user.a = a; Prob.user.b = b;
|-
|||[x, nFunc] = Tfmin('myFunc',0,1,1E-5,Prob); In myFunc:
|-
|||function f = myFunc(x, Prob)
|-
|||a = Prob.user.a;
|-
|||b = Prob.user.b;
|-
|||f = "matlab expression dependent of x, a and b";
|}
 
'''Description  of Outputs'''
 
{|
|''Variable''||Description
|-
|''x''||Solution.
|-
|''nFunc''||Number of calls to Func.
|}
 
====Tfzero====
 
'''Purpose'''


Tfzero, TOMLAB  fzero routine.
Tfzero, TOMLAB  fzero routine.


Tfzero, TOMLAB fzero routine.\\ \\Find a zero for <math>f(x)</math> in the interval <math>[x_L, x_U]</math>. Tfzero searches for a zero of a function <math>f(x)</math> between the given scalar values <math>x_L</math> and <math>x_U</math> until the width of the interval (xLow, xUpp) has collapsed to within a tolerance specified by the stopping criterion, <math>abs(xLow-xUpp) <= 2.*(RelErr*abs(xLow)+AbsErr)</math>. The method used is an efficient combination of bisection and the secant rule and is due to T. J. Dekker.
*[[Tfzero]]


'''Calling  Syntax'''
==ucSolve==
 
[xLow, xUpp, ExitFlag] = Tfzero(x L, x U, Prob, x 0, RelErr, AbsErr)
 
'''Description  of Inputs'''
 
{|
|''Variable''||Description
|-
|''x_L''||Lower limit  on the zero x to f(x).
|-
|''x_U''||Upper limit  on the zero x to f(x).
|-valign="top"
|''Prob''||Structure, sent to Matlab routine ZeroFunc. The function name should be set in Prob.FUNCS.f0. Only the function will be used, not the gradient.
|-
|''x_0''||An initial  guess on the zero to f(x). If empty, x 0 is set as the middle point in [x_L, x_U].
|-
|''RelErr''||Relative error tolerance, default 1E-7.
|-
|''AbsErr''||Absolute error tolerance, default 1E-14.
|}
 
'''Description  of Outputs'''
 
{|
|''Variable''||Description
|-
|''xLow''||Lower limit on the zero x to f(x).
|-
|''xUpp''||Upper limit on the zero x to f(x).
|-
|''ExitFlag''||Status flag 1,2,3,4,5.
|-
|||1: xLow is within the requested tolerance of a zero. The interval (xLow, xUpp) collapsed to the requested tolerance, the function changes sign in (xLow, xUpp), and f(x) decreased in magnitude as (xLow, xUpp) collapsed.
|-
|||2: f(xLow) = 0. However, the interval (xLow, xUpp) may not have collapsed to the requested tolerance.
|-
|||3:  xLow may be near a singular point  of f(x).  The interval  (xLow, xUpp) collapsed to the requested tolerance and the function changes sign in (xLow, xUpp),  but  f(x)  increased in  magnitude as (xLow,  xUpp)  collapsed, i.e. ''abs''(''f ''(''xLow'')) ''> max''(''abs''(''f ''(''xLow - I N ''))'', abs''(''f ''(''xU pp - I N ''))).
|-
|||4:  No change in sign of f(x)  was found although the interval (xLow, xUpp) collapsed to the requested tolerance.  The user must examine this case and decide whether xLow is near a local minimum of f(x), or xLow is near a zero of even multiplicity, or neither of these.
|-
|||5:  Too  many (> 500)  function evaluations used.
|}
 
====ucSolve====
 
'''Purpose'''


Solve unconstrained  nonlinear optimization problems with simple bounds on the variables.
Solve unconstrained  nonlinear optimization problems with simple bounds on the variables.


''ucSolve ''solves problems of the form
*[[ucSolve]]
 
 
<math>
\begin{array}{cccccc}
\min\limits_{x} & f(x) &  &  &  &  \\
s/t & x_{L} & \leq  & x & \leq  & x_{U} \\
\end{array}
</math>
 
 
where <math>x,x_{L},x_{U}\in \MATHSET{R} ^{n}</math>.
 
'''Calling  Syntax'''
 
Result = ucSolve(Prob, varargin)
 
'''Description  of Inputs'''
 
{|
|''Prob''||colspan="2"|Problem description structure. The following fields are used:
|-
|||''x_L''||Lower bounds on the variables.
|-
|||''x_U''||Upper bounds on the variables.
|-
|||''x_0''||Starting point.
|-
|||''FUNCS.f''||Name of m-file computing the objective function ''f ''(''x'').
|-
|||''FUNCS.g''||Name of m-file computing the gradient vector ''g''(''x'').
|-
|||''FUNCS.H''||Name of m-file computing the Hessian matrix ''H ''(''x'').
|-
|||''f_Low''||Lower bound on function value.
|-
|||''Solver.Alg ''||Solver algorithm to be run:
|-
|||||0: Gives default, either Newton or BFGS.
|-
|||||1: Newton with subspace minimization, using SVD.
|-
|||||2: Safeguarded BFGS with inverse Hessian updates (standard).
|-
|||||3: Safeguarded BFGS with Hessian updates.
|-
|||||4: Safeguarded DFP with inverse Hessian updates.
|-
|||||5: Safeguarded DFP with Hessian updates.
|-
|||||6: Fletcher-Reeves CG.
|-
|||||7: Polak-Ribiere CG.
|-
|||||8: Fletcher conjugate descent CG-method.
|-
|||''Solver.Method''||Method used to solve equation system:
|-
|||||0: SVD (default).
|-
|||||1: LU-decomposition.
|-
|||||2: LU-decomposition with pivoting.
|-
|||||3: Matlab built in QR.
|-
|||||4: Matlab inversion.
|-
|||||5: Explicit  inverse.
|-
|||''Solver.Method''||Restart or not for C-G method:
|-
|||||0: Use restart in CG-method each n:th step.
|-
|||||1: Use restart in CG-method each n:th step.
|-
|||''LineParam ''||Structure with line search parameters,  see routine ''LineSearch ''and Table 140.
|-
|||''optParam ''||Structure with special fields for optimization parameters,  see Table 141.
|-
|||||Fields used are: ''eps absf'', ''eps f'', ''eps g'', ''eps x'', ''eps Rank'', ''MaxIter'', ''wait'', ''size x'', ''xTol'', ''size f'', ''LineSearch'', ''LineAlg'', ''xTol'', ''IterPrint ''and ''QN InitMatrix''.
|-
|||''PriLevOpt''||Print level.
|-
|''varargin''||colspan="2"|Other parameters directly sent to low level routines.
|}
 
'''Description  of Outputs'''
 
{|
|''Result''||colspan="2"|Structure with result from optimization.  The following fields are changed:
|-
|||''x_k''||Optimal point.
|-
|||''f_k''||Function value at optimum.
|-
|||''g_k''||Gradient value at optimum.
|-
|||''H_k''||Hessian value at optimum.
|-
|||''B_k''||Quasi-Newton approximation of the Hessian at optimum.
|-
|||''v_k''||Lagrange multipliers.
|-
|||''x_0''||Starting point.
|-
|||''f_0''||Function value at start.
|-
|||''xState''||State of each variable, described in Table 150.
|-
|||''Iter''||Number of iterations.
|-
|||''ExitFlag''||0 if convergence to local min. Otherwise errors.
|-
|||''Inform''||Binary code telling type of convergence:
|-
|||||1: Iteration points are close.
|-
|||||2: Projected gradient small.
|-
|||||4: Relative function value reduction low for ''LowIts ''iterations.
|-
|||||101: Maximum number of iterations reached.
|-
|||||102: Function value below given estimate.
|-
|||||104: Convergence to a saddle point.
|-
|||''Solver''||Solver used.
|-
|||''SolverAlgorithm''||Solver algorithm used.
|-
|||''Prob''||Problem structure used.
|}
 
'''Description'''
 
The solver ''ucSolve ''includes several of the most popular search step methods for unconstrained optimization. The search step methods included in ''ucSolve ''are: the Newton method, the quasi-Newton BFGS and DFP methods, the Fletcher-Reeves and Polak-Ribiere conjugate-gradient method, and the Fletcher conjugate descent method. The quasi-Newton methods may either update the inverse Hessian (standard) or the Hessian itself. The Newton method and the quasi-Newton methods updating the Hessian are using a subspace minimization  technique to handle rank problems, see  Lindstr¨om  \[53\]. The quasi-Newton algorithms also use safe guarding techniques to avoid rank problem in the updated matrix. The line search algorithm in the routine ''LineSearch ''is a modified version of an algorithm by Fletcher \[20\]. Bound constraints are treated as described in Gill, Murray and Wright \[28\]. The accuracy in the line search is critical for the performance of quasi-Newton BFGS and DFP methods and for the CG methods. If the accuracy parameter ''Prob.LineParam.sigma ''is set to the default value 0''.''9, ''ucSolve ''changes it automatically according to:
 
{|
|''Prob.Solver.Alg''||''Prob.LineParam.sigma''
|-
|4,5 (DFP)||0.2
|-
|6,7,8 (CG)||0.01
|}
 
'''M-files  Used'''
 
''ResultDef.m'', ''LineSearch.m'', ''iniSolve.m'', ''tomSolve.m'', ''endSolve.m''
 
'''See Also'''


''clsSolve''
==Additional solvers==
c
====Additional solvers====


Documentation for the following solvers is only available at http://tomopt.com and in the m-file help.
Documentation for the following solvers is only available at http://tomopt.com and in the m-file help.

Latest revision as of 13:30, 17 July 2011

Notice.png

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

Detailed descriptions of the TOMLAB solvers, driver routines and some utilities are given in the following sections. Also see the M-file help for each solver. All solvers except for the TOMLAB Base Module are described in separate manuals.

For a description of solvers called using the MEX-file interface, see the M-file help, e.g. for the MINOS solver minosTL.m. For more details, see the User's Guide for the particular solver.

clsSolve

Solves dense and sparse nonlinear least squares optimization problems with linear inequality and equality con- straints and simple bounds on the variables.

conSolve

Solve general constrained nonlinear optimization problems.

cutPlane

Solve mixed integer linear programming problems (MIP).

DualSolve

Solve linear programming problems when a dual feasible solution is available.

expSolve

Solve exponential fitting problems for given number of terms p.

glbDirect

Solve box-bounded global optimization problems.

glbSolve

Solve box-bounded global optimization problems.

glcCluster

Solve general constrained mixed-integer global optimization problems using a hybrid algorithm.

glcDirect

Solve global mixed-integer nonlinear programming problems.

glcSolve

Solve general constrained mixed-integer global optimization problems.

infLinSolve

Finds a linearly constrained minimax solution of a function of several variables with the use of any suitable TOMLAB solver. The decision variables may be binary or integer.

infSolve

Find a constrained minimax solution with the use of any suitable TOMLAB solver.

linRatSolve

Finds a linearly constrained solution of a function of the ratio of two linear functions with the use of any suitable TOMLAB solver. Binary and integer variables are not supported.

lpSimplex

Solve general linear programming problems.

L1Solve

Find a constrained L1 solution of a function of several variables with the use of any suitable nonlinear TOMLAB solver.

MilpSolve

Solve mixed integer linear programming problems (MILP).

minlpSolve

Branch & Bound algorithm for Mixed-Integer Nonlinear Programming (MINLP) with convex or nonconvex sub problems using NLP relaxation (Formulated as minlp-IP).

mipSolve

Solve mixed integer linear programming problems (MIP).

multiMin

multiMin solves general constrained mixed-integer global optimization problems. It tries to find all local minima by a multi-start method using a suitable nonlinear programming subsolver.

multiMINLP

multiMINLP solves general constrained mixed-integer global nonlinear optimization problems.

nlpSolve

Solve general constrained nonlinear optimization problems.

pdcoTL

pdcoTL solves linearly constrained convex nonlinear optimization problems.

pdscoTL

pdscoTL solves linearly constrained convex nonlinear optimization problems.

qpSolve

Solve general quadratic programming problems.

slsSolve

Find a Sparse Least Squares (sls) solution to a constrained least squares problem with the use of any suitable TOMLAB NLP solver.

sTrustr

Solve optimization problems constrained by a convex feasible region.

Tfmin

Minimize function of one variable. Find miniumum x in [x_L, x_U] for function Func within tolerance xTol. Solves using Brents minimization algorithm.

Tfzero

Tfzero, TOMLAB fzero routine.

ucSolve

Solve unconstrained nonlinear optimization problems with simple bounds on the variables.

Additional solvers

Documentation for the following solvers is only available at http://tomopt.com and in the m-file help.

  • goalSolve - For sparse multi-objective goal attainment problems, with linear and nonlinear constraints.
  • Tlsqr - Solves large, sparse linear least squares problem, as well as unsymmetric linear systems.
  • lsei - For linearly constrained least squares problem with both equality and inequality constraints.
  • Tnnls - Also for linearly constrained least squares problem with both equality and inequality constraints.
  • qld - For convex quadratic programming problem.