Knitro / AMPL reference

A complete list of available Knitro options can always be shown by typing:

knitroampl -=

in a terminal, which produces the following output.

act_lpalg                LP algorithm used in Active or SQP subproblems
act_lpdumpmps            Dump LPs to MPS files in Active or SQP algorithm
act_lpfeastol            Feasibility tolerance for LP subproblems
act_lppenalty            Controls constraint penalization in LP subproblems
act_lppresolve           Controls LP presolve in Active or SQP subproblems
act_lpsolver             LP solver used by Active or SQP algorithm
act_parametric           Use parametric LP in Active or SQP algorithm
act_qpalg                QP subproblem alg used by Active or SQP algorithm
act_qppenalty            Controls constraint penalization in QP subproblems
alg                      Algorithm (0=auto, 1=direct, 2=cg, 3=active, 4=sqp, 5=multi)
algorithm                Synonym for alg
bar_conic_enable         Special handling of conic constraints
bar_directinterval       Frequency for trying to force direct steps
bar_feasible             Emphasize feasibility
bar_feasmodetol          Tolerance for entering stay feasible mode
bar_initmu               Initial value for barrier parameter
bar_initpi_mpec          Initial value for barrier MPEC penalty parameter
bar_initpt               Barrier initial point strategy for slacks/multipliers
bar_linsys               Barrier linear system form
bar_maxcorrectors        Maximum number of corrector steps
bar_maxcrossit           Maximum number of crossover iterations
bar_maxrefactor          Maximum number of KKT refactorizations allowed
bar_murule               Rule for updating the barrier parameter
bar_penaltycons          Apply penalty method to constraints
bar_penaltyrule          Rule for updating the penalty parameter
bar_refinement           Whether to refine barrier solution
bar_relaxcons            Whether to relax constraints
bar_slackboundpush       Amount by which slacks are pushed inside bounds
bar_switchobj            Objective for barrier switching alg
bar_switchrule           Rule for barrier switching alg
bar_watchdog             Enable watchdog heuristic for barrier algs?
bfgs_scaling             Initial scaling for BFGS/L-BFGS Hessian
blasoption               Which BLAS/LAPACK library to use
blasoptionlib            Name of dynamic BLAS/LAPACK library
bndrange                 Constraint/variable bound range
cg_maxit                 Maximum number of conjugate gradient iterations
cg_pmem                  Memory for incomplete Cholesky
cg_precond               Preconditioning method
cg_stoptol               Stopping tolerance for CG subproblems
convex                   Declare the problem as convex
cplexlibname             Name of dynamic CPLEX library
cpuplatform              Target CPU platform/architecture
debug                    Debugging level (0=none, 1=problem, 2=execution)
delta                    Initial trust region radius
derivcheck               Whether to use derivative checker
derivcheck_terminate     Derivative checker type (1=error, 2=always)
derivcheck_tol           Relative tolerance for derivative checker
derivcheck_type          Derivative checker type (1=forward, 2=central)
feastol                  Feasibility stopping tolerance
feastol_abs              Absolute feasibility tolerance
feastolabs               Absolute feasibility tolerance
findiff_relstepsize      Relative stepsize for finite-difference gradients
findiff_terminate        Termination for finite-difference gradients
fstopval                 Stop based on obj. function value
ftol                     Stop based on small change in obj. function
ftol_iters               Stop based on small change in obj. function
gradopt                  Gradient computation method
hessopt                  Hessian computation method
honorbnds                Enforce satisfaction of the bounds
infeastol                Infeasibility stopping tolerance
infeastol_iters          Stop based on small change in feasibility error
initpenalty              Initial merit function penalty value
leastsquares             Solve as a least-squares model
linesearch               Which linesearch method to use
linesearch_maxtrials     Maximum number of linesearch trial points
linsolver                Which linear solver to use
linsolver_maxitref       Maximum number of iterative refinement steps
linsolver_ooc            Use out-of-core option?
linsolver_pivottol       Initial pivot tolerance
lmsize                   Number of limited-memory pairs stored for LBFGS
ma_maxtime_cpu           Maximum CPU time when 'alg=multi', in seconds
ma_maxtime_real          Maximum real time when 'alg=multi', in seconds
ma_outsub                Enable subproblem output when 'alg=multi'
ma_terminate             Termination condition when option 'alg=multi'
maxfevals                Maximum number of function evaluations
maxit                    Maximum number of iterations
maxtime_cpu              Maximum CPU time in seconds, per start point
maxtime_real             Maximum real time in seconds, per start point
mip_branchrule           MIP branching rule
mip_clique               Add clique cuts (0=none, 1=root, 2=tree, 3=root+tree)
mip_cutfactor            Limit on the number of cuts allowed in node subproblem
mip_debug                MIP debugging level (0=none, 1=all)
mip_gub_branch           Branch on GUBs (0=no, 1=yes)
mip_heuristic            MIP heuristic search
mip_heuristic_maxit      MIP heuristic iteration limit
mip_heuristic_terminate  MIP heuristic termination
mip_implications         Add logical implications (0=no, 1=yes)
mip_integer_tol          Threshold for deciding integrality
mip_integral_gap_abs     Absolute integrality gap stop tolerance
mip_integral_gap_rel     Relative integrality gap stop tolerance
mip_intvar_strategy      Treatment of integer variables
mip_knapsack             Add knapsack cuts (0=none, 1=ineqs, 2=lifted, 3=all)
mip_lpalg                LP subproblem algorithm
mip_maxnodes             Maximum nodes explored
mip_maxsolves            Maximum subproblem solves
mip_maxtime_cpu          Maximum CPU time in seconds for MIP
mip_maxtime_real         Maximum real in seconds time for MIP
mip_method               MIP method (0=auto, 1=BB, 2=HQG, 3=MISQP)
mip_mir                  Add mixed integer rounding cuts
mip_nodealg              Standard node relaxation algorithm
mip_outinterval          MIP output interval
mip_outlevel             MIP output level
mip_outsub               Enable MIP subproblem output
mip_pseudoinit           Pseudo-cost initialization
mip_relaxable            Are integer variables relaxable?
mip_rootalg              Root node relaxation algorithm
mip_rounding             MIP rounding rule
mip_selectdir            MIP node selection direction
mip_selectrule           MIP node selection rule
mip_strong_candlim       Strong branching candidate limit
mip_strong_level         Strong branching tree level limit
mip_strong_maxit         Strong branching iteration limit
mip_terminate            Termination condition for MIP
mip_zerohalf             Add zero half cuts (0=no, 1=root, 2=tree, 3=all)
ms_deterministic         Use deterministic multistart
ms_enable                Enable multistart
ms_maxbndrange           Maximum unbounded variable range for multistart
ms_maxsolves             Maximum Knitro solves for multistart
ms_maxtime_cpu           Maximum CPU time for multistart, in seconds
ms_maxtime_real          Maximum real time for multistart, in seconds
ms_num_to_save           Feasible points to save from multistart
ms_outsub                Enable subproblem output for parallel multistart
ms_savetol               Tol for feasible points being equal
ms_seed                  Seed for multistart random generator
ms_startptrange          Maximum variable range for multistart
ms_terminate             Termination condition for multistart
newpoint                 Use newpoint feature
objno                    objective number: 0 = none, 1 = first (default),
                         2 = second (if _nobjs > 1), etc.
objrange                 Objective range
objrep                   Whether to replace
                           minimize obj: v;
                         with
                           minimize obj: f(x)
                         when variable v appears linearly
                         in exactly one constraint of the form
                           s.t. c: v >= f(x);
                         or
                           s.t. c: v == f(x);
                         Possible objrep values:
                         0 = no
                         1 = yes for v >= f(x) (default)
                         2 = yes for v == f(x)
                         3 = yes in both cases
optionsfile              Name/location of Knitro options file if provided
opttol                   Optimality stopping tolerance
opttol_abs               Absolute optimality tolerance
opttolabs                Absolute optimality tolerance
out_csvinfo              Create knitro_solve.csv info file
out_csvname              Name for csv info file
out_hints                Print hints for parameter settings
outappend                Append to output files (0=no, 1=yes)
outdir                   Directory for output files
outlev                   Control printing level
outmode                  Where to direct output (0=screen, 1=file, 2=both)
outname                  Name for output file
par_blasnumthreads       Number of parallel threads for BLAS
par_lsnumthreads         Number of parallel threads for linear solver
par_msnumthreads         Number of parallel threads for multistart
par_numthreads           Number of parallel threads
presolve                 Knitro presolver level
presolve_dbg             Knitro presolver debugging level
presolve_initpt          Knitro presolver initial point handling
presolve_level           Knitro presolver level
presolve_passes          Knitro presolver pass limit
presolve_tol             Knitro presolver tolerance
presolveop_tighten       Knitro presolve tightening operations
qpcheck                  whether to check for a QP: 0 = no, 1 (default) = yes
relax                    whether to ignore integrality: 0 (default) = no, 1 = yes
restarts                 Maximum number of restarts allowed
restarts_maxit           Maximum number of iterations before restarting
scale                    Automatic scaling option
soc                      Second order correction options
storequadcoefs           Store quadratic coefficients when solving QCQPs
strat_warm_start         Enable warm-start strategy?
threads                  Number of parallel threads
timing                   Whether to report problem I/O and solve times:
                           0 (default) = no
                           1 = yes, on stdout
tuner                    Enables Knitro Tuner
tuner_maxtime_cpu        Maximum CPU time when 'tuner=on', in seconds
tuner_maxtime_real       Maximum real time when 'tuner=on', in seconds
tuner_optionsfile        Name/location of Tuner options file if provided
tuner_outsub             Enable subproblem output when 'tuner=on'
tuner_terminate          Termination condition when 'tuner=on'
version                  Report software version
wantsol                  solution report without -AMPL: sum of
                           1 ==> write .sol file
                           2 ==> print primal variable values
                           4 ==> print dual variable values
                           8 ==> do not print solution message
xpresslibname            Name of dynamic Xpress library
xtol                     Stepsize stopping tolerance
xtol_iters               Stop based on small change in variables

These options are detailed below.

Knitro options in AMPL

  • act_lpalg: LP subproblem algorithm in Active Set or SQP algorithm (default 0). See act_lpalg.

Value

Description

0

default LP algorithm

1

primal simplex algorithm

2

dual simplex algorithm

3

barrier/interior-point algorithm

  • act_lpdumpmps: Used for internal debugging.

  • act_lpfeastol: feasibility tolerance for LP subproblems (default 1.0e-8). See act_lpfeastol.

  • act_lppenalty: Use penalty formulation for LP subproblems in Active Set or SQP algorithm (default 1). See act_lppenalty.

Value

Description

1

penalize all constraints

2

penalize only nonlinear constraints

3

dynamically choose which constraints to penalize

  • act_lppresolve: Control presolve for LP subproblems in Active Set or SQP algorithm (default 0). See act_lppresolve.

Value

Description

0

presolve turned off for LP subproblems

1

presolve turned on for LP subproblems

  • act_lpsolver: LP solver used in Active Set or SQP algorithm (default 1). See act_lpsolver.

  • act_parametric: Use parametric LP subproblems in Active Set or SQP algorithm (default 1). See act_parametric.

Value

Description

0

do not use a parametric solve

1

use a parametric solve sometimes

2

always try a parametric solve

  • act_qpalg: QP subproblem algorithm in Active Set or SQP algorithm (default 0). See act_qpalg.

Value

Description

0

let Knitro decide the QP algorithm

1

Interior/Direct (barrier) algorithm

2

Interior/CG (barrier) algorithm

3

Active Set algorithm

  • act_qppenalty: Use penalty formulation for QP subproblems in SQP algorithm (default -1). See act_qppenalty.

Value

Description

-1

let Knitro determine automatically

0

do not penalize constraints in QP subproblems

1

penalize all constraints in QP subproblems

  • alg or algorithm: optimization algorithm used (default 0). See algorithm.

Value

Description

0

let Knitro choose the algorithm

1

Interior/Direct (barrier) algorithm

2

Interior/CG (barrier) algorithm

3

Active Set algorithm

4

Sequential Quadratic Programming (SQP) algorithm

5

Run multiple algorithms

  • bar_conic_enable: enable special treatment for conic constraints (default -1). See bar_conic_enable.

Value

Description

-1

let Knitro determine automatically

0

do not apply any special treatment for conic constraints

1

apply special treatments for any Second Order Cone (SOC) constraints

  • bar_directinterval: frequency for trying to force direct steps (default 10). See bar_directinterval.

  • bar_feasible: whether feasibility is given special emphasis (default 0). See bar_feasible.

Value

Description

0

no special emphasis on feasibility

1

iterates must honor inequalities

2

emphasize first getting feasible before optimizing

3

implement both options 1 and 2 above

  • bar_feasmodetol: tolerance for entering stay feasible mode (default 1.0e-4). See bar_feasmodetol.

  • bar_initmu: initial value for barrier parameter (default 1.0e-1). See bar_initmu.

  • bar_initpi_mpec: initial value for barrier MPEC penalty parameter. Knitro uses an internal formula to initialize the MPEC penalty parameter if a non-positive value is specified (default 0.0). See bar_initpi_mpec.

  • bar_initpt: initial settings of x (if not set by user), slacks and multipliers for barrier algorithms (default 0). See bar_initpt.

Value

Description

0

let Knitro choose the initial point strategy

1

initialization strategy for LP, convex QP (x unaffected if initialized by user)

2

initialization strategy staying near bounds (x unaffected if initialized by user)

3

initialization strategy more central to bounds (x unaffected if initialized by user)

  • bar_linsys: linear system form used in barrier direct algorithm (default -1). See bar_linsys.

Value

Description

-1

let Knitro choose automatically

0

use the full system

1

eliminate the slack variables

2

eliminate slacks and bounds

3

eliminate slacks, bounds, and some inequalities

  • bar_linsys_storage: linear system storage used for barrier direct algorithm (default -1). See bar_linsys_storage.

Value

Description

-1

let Knitro choose automatically

1

low memory storage (use the same memory for multiple systems)

2

normal storage (separate memory for different linear systems)

  • bar_maxcorrectors: maximum number of primal-dual corrector steps (default -1). See bar_maxcorrectors.

  • bar_maxcrossit: maximum number of allowable crossover iterations (default 0). See bar_maxcrossit.

  • bar_maxrefactor: maximum number of KKT refactorizations allowed (default -1). See bar_maxrefactor.

  • bar_murule: barrier parameter update rule (default 0). See bar_murule.

Value

Description

0

let Knitro choose the barrier update rule

1

monotone decrease rule

2

adaptive rule based on complementarity gap

3

probing rule (Interior/Direct only)

4

safeguarded Mehrotra predictor-corrector type rule

5

Mehrotra predictor-corrector type rule

6

rule based on minimizing a quality function

  • bar_penaltycons: technique for penalizing constraints in the barrier algorithms (default -1). See bar_penaltycons.

Value

Description

-1

let Knitro choose the strategy

0

do not apply penalty approach to any constraints

2

apply a penalty approach to all general constraints

  • bar_penaltyrule: penalty parameter rule for step acceptance (default 0). See bar_penaltyrule.

Value

Description

0

let Knitro choose the strategy

1

use single penalty parameter approach

2

use more tolerant, flexible strategy

  • bar_refinement: specify whether to refine barrier solution for more precision (default 0). See bar_refinement.

Value

Description

0

do not apply refinement phase

1

try to refine the barrier solution

  • bar_relaxcons: specify whether to relax constraints in the barrier algorithms (default 2). See bar_relaxcons.

Value

Description

0

do not relax constraints

1

relax equality constraints only

2

relax inequality constraints only

3

relax all constraints

  • bar_slackboundpush: minimum amount by which initial slack variables are pushed inside the bounds (default 1.0e-1). See bar_slackboundpush.

  • bar_switchobj: the objective function to use when Knitro switches to feasibility phase in the barrier algorithms (default 1). See bar_switchobj.

Value

Description

0

no (or zero) objective function

1

proximal point objective scaled by a scalar value

2

proximal point objective using a diagonal scaling

  • bar_switchrule: controls technique for switching between feasibility phase and optimality phase in the barrier algorithms (default -1). See bar_switchrule.

Value

Description

-1

let Knitro determine the switching procedure

0

never switch to feasibility phase

2

allow switches to feasibility phase

3

use more aggressive switching rule

  • bar_watchdog: specify whether to enable watchdog heuristic for barrier algorithms (default 0). See bar_watchdog.

Value

Description

0

do not apply watchdog heuristic

1

enable watchdog heuristic

  • bfgs_scaling: specify the initial scaling to use for the BFGS or L-BFGS Hessian (default 0). See bfgs_scaling.

Value

Description

0

make a dynamic choice of which scaling to use (for L-BFGS this may change at each iteration)

1

use a scaling that approximates the scale of the inverse Hessian

2

use a scaling that approximates the scale of the Hessian

  • blasoption: specify the BLAS/LAPACK function library to use (default 1). See blasoption.

Value

Description

0

use Knitro built-in functions

1

use Intel Math Kernel Library functions

2

use the dynamic library specified with blasoptionlib

  • blasoptionlib: specify the BLAS/LAPACK function library if using blasoption=2. See blasoptionlib.

  • bndrange: max limit for finite bounds (default 1e20). See bndrange.

  • cg_maxit: maximum allowable conjugate gradient (CG) iterations (default -1). See cg_maxit.

Value

Description

0

let Knitro set the number based on the problem size

n

maximum of n > 0 CG iterations per minor iteration

  • cg_pmem: amount of memory n used for the incomplete Cholesky preconditioner where n enforces the maximum number of nonzero elements per column in the matrix (default 10). See cg_pmem.

  • cg_precond: whether or not to apply an incomplete Cholesky preconditioner for the CG subproblems in the barrier algorithms (default 0). See cg_precond.

Value

Description

0

no preconditioner used

1

apply incomplete Cholesky preconditioner

  • cg_stoptol: relative stopping tolerance for CG subproblems (default 1.0e-2). See cg_stoptol.

  • convex: declare the problem as convex (default -1). See convex.

Value

Description

-1

Knitro will try to automatically determine convexity

0

Knitro will treat the problem as non-convex

1

Knitro will treat the problem as convex

  • cpuplatform: Target CPU platform/architecture (default -1). See cpuplatform.

Value

Description

-1

determine automatically

1

target compatible SSE2-based architecture

2

target SSE2

3

AVX

4

AVX2

5

AVX512

  • debug: enable debugging output (default 0). See debug.

Value

Description

0

no extra debugging

1

print info to debug solution of the problem

2

print info to debug execution of the solver

  • delta: initial trust region radius scaling (default 1.0e0). See delta.

  • feastol: feasibility termination tolerance (relative) (default 1.0e-6). See feastol.

  • feastol_abs: feasibility termination tolerance (absolute) (default 1.0e-3). See feastol_abs.

  • findiff_relstepsize: relative stepsize for finite-difference gradients (default sqrt(eps) for forward-difference and eps^(1/3) for central difference). See findiff_relstepsize.

  • findiff_terminate: termination rule when using finite-difference gradients (default 1). See findiff_terminate.

Value

Description

0

use standard termination conditions

1

allow termination based on finite-difference error estimates

  • fstopval: stop based on user-defined function value (default KN_INFINITY). See fstopval.

  • ftol: stop based on small (feasible) changes in the objective function (default 1.0e-15). See ftol.

  • ftol_iters: stop based on small (feasible) changes in the objective function (default 5). See ftol_iters.

  • gradopt: gradient computation method (default 1). See gradopt.

Value

Description

1

use exact gradients

2

compute forward finite-difference approximations

3

compute centered finite-difference approximations

  • hessopt: Hessian (Hessian-vector) computation method (default 1). See hessopt.

Value

Description

1

use exact Hessian derivatives

2

use dense quasi-Newton BFGS Hessian approximation

3

use dense quasi-Newton SR1 Hessian approximation

4

compute Hessian-vector products by finite diffs

5

compute exact Hessian-vector products

6

use limited-memory BFGS Hessian approximation

  • honorbnds: allow or not bounds to be violated during the optimization (default -1). See honorbnds.

Value

Description

-1

automatically determine the best setting

0

allow bounds to be violated during the optimization

1

enforce bounds satisfaction of all iterates

2

enforce bounds satisfaction of initial point

  • infeastol: tolerance for declaring infeasibility (default 1.0e-8). See infeastol.

  • infeastol_iters: stop based on small changes in the feasibility error while infeasible (default 50). See infeastol_iters.

  • linesearch: linesearch strategy for algorithms using a linesearch (default 0). See linesearch.

Value

Description

0

let Knitro automatically choose the strategy

1

use a simple backtracking linesearch

2

use a cubic interpolation linesearch

3

linesearch satisfying the weak Wolfe conditions (unconstrained only)

  • linesearch_maxtrials: maximum number of linesearch trial evaluations (default 3). See linesearch_maxtrials.

  • linsolver: linear system solver to use inside Knitro (default 0). See linsolver.

Value

Description

0

let Knitro choose the linear system solver

1

(not currently used; same as 0)

2

use a hybrid approach; solver depends on system

3

use a dense QR method (small problems only)

4

use HSL MA27 sparse symmetric indefinite solver

5

use HSL MA57 sparse symmetric indefinite solver

6

use Intel MKL PARDISO sparse symmetric indefinite solver

  • linsolver_maxitref: maximum number of iterative refinement steps when solving a linear system (default 2). See linsolver_maxitref.

  • linsolver_ooc: solve linear system out-of-core (default 0). See linsolver_ooc.

Value

Description

0

do not solve linear systems out-of-core

1

invoke Intel MKL PARDISO out-of-core option sometimes (only when linsolver = 6)

2

invoke Intel MKL PARDISO out-of-core option always (only when linsolver = 6)

  • linsolver_pivottol: initial pivot threshold for matrix factorizations (default 1.0e-8). See linsolver_pivottol.

  • lmsize: number of limited-memory pairs stored in LBFGS approach (default 10). See lmsize.

  • ma_maxtime_cpu: maximum CPU time in seconds before terminating for the multi-algorithm (alg=5) procedure (default 1.0e8). See ma_maxtime_cpu.

  • ma_maxtime_real: maximum real time in seconds before terminating for the multi-algorithm (alg=5) procedure (default 1.0e8). See ma_maxtime_real.

  • ma_outsub: enable writing algorithm output to files for the multi-algorithm (alg=5) procedure (default 0). See ma_outsub.

Value

Description

0

do not write detailed algorithm output to files

1

write detailed algorithm output to files named knitro_ma_*.log

  • ma_terminate: termination condition for multi-algorithm (alg=5) procedure (default 1). See ma_terminate.

Value

Description

0

terminate after all algorithms have completed

1

terminate at first local optimum

2

terminate at first feasible solution

3

terminate after first completed optimization (any termination status)

  • maxfevals: maximum number of function evaluations before terminating (default unlimited). See maxfevals.

  • maxit: maximum number of iterations before terminating (default 0). See maxit.

Value

Description

0

let Knitro set the number based on the problem

n

maximum limit of n > 0 iterations

  • maxtime_cpu: maximum CPU time in seconds before terminating (default 1.0e8). See maxtime_cpu.

  • maxtime_real: maximum real time in seconds before terminating (default 1.0e8). See maxtime_real.

  • mip_branchrule: MIP branching rule (default 0). See mip_branchrule.

Value

Description

0

let Knitro choose the branching rule

1

most-fractional branching

2

pseudo-cost branching

3

strong branching

  • mip_clique: enable clique cuts (default 0). See mip_clique.

Value

Description

0

do not allow clique cuts

1

add clique cuts derived from root node

2

add clique cuts derived at every node

3

add clique cuts derived from combining root and tree

  • mip_cutfactor: limit on the number of cuts allowed in node subproblem (default 1.0). See mip_cutfactor.

  • mip_debug: MIP debugging level (default 0). See mip_debug.

Value

Description

0

no MIP debugging output

1

print MIP debugging information

Value

Description

0

do not branch on GUB constraints

1

allow branching on GUB constraints

  • mip_heuristic: heuristic search approach (default -1). See mip_heuristic.

Value

Description

-1

let Knitro decide whether to apply a heuristic

0

do not apply any heuristic

2

use feasibility pump heuristic

3

use MPEC heuristic

4

use diving heuristic

Value

Description

1

terminate at first feasible point or iteration limit

2

always run the heuristic to the iteration limit

Value

Description

0

do not add constraints from logical implications

1

add constraints from logical implications

  • mip_integer_tol: threshold for deciding integrality (default 1.0e-8). See mip_integer_tol.

  • mip_integral_gap_abs: absolute integrality gap stop tolerance (default 1.0e-6). See mip_integral_gap_abs.

  • mip_integral_gap_rel: relative integrality gap stop tolerance (default 1.0e-6). See mip_integral_gap_rel.

  • mip_intvar_strategy: treatment of integer variables (default 0). See mip_intvar_strategy.

Value

Description

0

no special treatment

1

relax all integer variables

2

convert all binary variables to complementarity constraints

  • mip_knapsack: add knapsack cuts (default 1). See mip_knapsack.

Value

Description

0

do not add knapsack cuts

1

add knapsack inequality cuts at root node

2

add knapsack lifted cuts

3

add both inequality and lifted cuts

  • mip_lpalg: LP subproblem algorithm (default 0). See mip_lpalg.

Value

Description

0

let Knitro decide the LP algorithm

1

Interior/Direct (barrier) algorithm

2

Interior/CG (barrier) algorithm

3

Active Set (simplex) algorithm

  • mip_maxnodes: maximum nodes explored (default 0). See mip_maxnodes.

  • mip_maxsolves: maximum subproblem solves (default 0). See mip_maxsolves.

  • mip_maxtime_cpu: maximum CPU time in seconds for MIP (default 1.0e8). See mip_maxtime_cpu.

  • mip_maxtime_real: maximum real time in seconds for MIP (default 1.0e8). See mip_maxtime_real.

  • mip_method: MIP method (default 0). See mip_method.

Value

Description

0

let Knitro choose the method

1

branch and bound method

2

hybrid method for convex nonlinear models

3

mixed-integer SQP method

  • mip_mir: enable mixed-integer rounding cuts (default -1). See mip_mir.

Value

Description

-1

let Knitro decide whether to add mixed-integer rounding cuts

0

do not add mixed-integer rounding cuts

1

add mixed-integer rounding cuts derived at every node

2

add these cuts at the root and for nonlinear constraints

  • mip_nodealg: standard node relaxation algorithm (default 0). See mip_nodealg.

Value

Description

0

let Knitro decide the node algorithm

1

Interior/Direct (barrier) algorithm

2

Interior/CG (barrier) algorithm

3

Active Set algorithm

4

SQP algorithm

5

Run multiple algorithms

  • mip_outinterval: MIP node output interval (default 10). See mip_outinterval.

  • mip_outlevel: MIP output level (default 1). See mip_outlevel.

  • mip_outsub: enable MIP subproblem debug output (default 0). See mip_outsub.

  • mip_pseudoinit: method to initialize pseudo-costs (default 0). See mip_pseudoinit.

Value

Description

0

let Knitro choose the method

1

use average value

2

use strong branching

  • mip_relaxable: are integer variables relaxable? (default 1). See mip_relaxable.

Value

Description

0

integer variables are not relaxable

1

all integer variables are relaxable

  • mip_rootalg: root node relaxation algorithm (default 0). See mip_rootalg.

Value

Description

0

let Knitro decide the root algorithm

1

Interior/Direct (barrier) algorithm

2

Interior/CG (barrier) algorithm

3

Active Set algorithm

4

SQP algorithm

5

Run multiple algorithms

  • mip_rounding: MIP rounding rule (default -1). See mip_rounding.

Value

Description

-1

let Knitro choose the rounding rule

0

do not attempt rounding

2

use fast heuristic

3

apply rounding solve selectively

4

apply rounding solve always

  • mip_selectdir: MIP node selection direction (default 0). See mip_selectdir.

Value

Description

0

choose down (i.e. <=) node first

1

choose up (i.e. >=) node first

  • mip_selectrule: MIP node selection rule (default 0). See mip_selectrule.

Value

Description

0

let Knitro choose the node select rule

1

use depth first search

2

use best bound node selection

3

use a combination of depth first and best bound

  • mip_strong_candlim: strong branching candidate limit (default 10). See mip_strong_candlim.

  • mip_strong_level: strong branching level limit (default 10). See mip_strong_level.

  • mip_strong_maxit: strong branching subproblem iteration limit (default 1000). See mip_strong_maxit.

  • mip_terminate: termination condition for MIP (default 0). See mip_terminate.

Value

Description

0

terminate at optimal solution

1

terminate at first integer feasible solution

  • mip_zerohalf: enable zero-half cuts (default 0). See mip_zerohalf.

Value

Description

0

do not add zero-half cuts

1

add zero-half cuts derived from root node

2

add zero-half cuts derived at every node

3

add zero-half cuts derived from combining root and tree

  • ms_deterministic: whether to use a deterministic version of multi-start (default 1). See ms_deterministic.

Value

Description

0

multithreaded multi-start is non-deterministic

1

multithreaded multi-start is deterministic (when ms_terminate = 0)

  • ms_enable: multi-start feature (default 0). See ms_enable.

Value

Description

0

multi-start disabled

1

multi-start enabled

  • ms_maxbndrange: maximum range to vary unbounded x when generating start points (default 1.0e3). See ms_maxbndrange.

  • ms_maxsolves: maximum number of start points to try during multi-start (default 0). See ms_maxsolves.

Value

Description

0

let Knitro set the number based on problem size

n

try exactly n > 0 start points

  • ms_maxtime_cpu: maximum CPU time for multi-start, in seconds (default 1.0e8). See ms_maxtime_cpu.

  • ms_maxtime_real: maximum real time for multi-start, in seconds (default 1.0e8). See ms_maxtime_real.

  • ms_num_to_save: number of feasible points to save in knitro_mspoints.log (default 0). See ms_num_to_save.

  • ms_outsub: enable writing output from subproblem solves to files for parallel multi-start (default 0). See ms_outsub.

Value

Description

0

do not write subproblem output to files

1

write detailed subproblem output to files named knitro_ms_*.log

  • ms_savetol: tolerance for feasible points to be considered distinct (default 1.0e-6). See ms_savetol.

  • ms_seed: seed value used to generate random initial points in multi-start; should be a non-negative integer (default 0). See ms_seed.

  • ms_startptrange: maximum range to vary all x when generating start points (default 1.0e20). See ms_startptrange.

  • ms_terminate: termination condition for multi-start (default 0). See ms_terminate.

Value

Description

0

terminate after ms_maxsolves

1

terminate at first local optimum (if before ms_maxsolves)

2

terminate at first feasible solution (if before ms_maxsolves)

3

terminate after first completed optimization (any termination status)

  • newpoint: how to save new points found by the solver. (default 0). See newpoint.

Value

Description

0

no action

1

save the latest new point to file knitro_newpoint.log

2

append all new points to file knitro_newpoint.log

  • objrange: maximum allowable objective function magnitude (default 1.0e20). See objrange.

  • optionsfile: path that specifies the location of a Knitro options file if used.

  • opttol: optimality termination tolerance (relative) (default 1.0e-6). See opttol.

  • opttol_abs: optimality termination tolerance (absolute) (default 1.0e-3). See opttol_abs.

  • out_csvinfo: create knitro_solve.csv information file (default 0). See out_csvinfo.

Value

Description

0

do not create solve information file

1

create solve information file

  • out_csvname: custom name for csv information file (default knitro_solve.csv). See out_csvname.

  • out_hints: print diagnostic hints at the end of the solve (default 1). See out_hints.

Value

Description

0

do not print hints

1

print hints

  • outappend: append output to existing files (default 0). See outappend.

Value

Description

0

do not append

1

do append

  • outdir: directory where output files are created. See outdir.

  • outlev: printing output level (default 2). See outlev.

Value

Description

0

no printing

1

just print summary information

2

print basic information every 10 iterations

3

print basic information at each iteration

4

print all information at each iteration

5

also print final (primal) variables

6

also print final Lagrange multipliers (sensitivies)

  • outmode: Knitro output redirection (default 0). See outmode.

Value

Description

0

direct Knitro output to standard out (e.g., screen)

1

direct Knitro output to the file knitro.log

2

print to both the screen and file knitro.log

  • outname: custom name for Knitro log file (default knitro.log). See outname.

  • par_blasnumthreads: specify the number of threads to use for BLAS (default 0). See par_blasnumthreads.

Value

Description

0

let Knitro choose the number of threads

n

use n > 0 threads

  • par_lsnumthreads: specify the number of threads to use for linear system solves (default 0). See par_lsnumthreads.

Value

Description

0

let Knitro choose the number of threads

n

use n > 0 threads

  • par_msnumthreads: specify the number of threads to use for multistart (default 0). See par_msnumthreads.

Value

Description

0

let Knitro choose the number of threads

n

use n > 0 threads

  • par_numthreads: specify the number of threads to use for all parallel features (default -1). See par_numthreads.

Value

Description

-1

let Knitro choose the number of threads

0

determine by environment variable $OMP_NUM_THREADS

n

use n > 0 threads

  • presolve: enable Knitro presolver (default 1). See presolve.

Value

Description

0

do not use the Knitro presolver

1

use the Knitro presolver

  • presolve_dbg: presolve debug output (default 0).

Value

Description

0

no debugging information

2

print the Knitro problem with AMPL model names

  • presolve_initpt: controls presolver shifting of initial point (default -1). See presolve_initpt.

Value

Description

-1

let Knitro choose automatically

0

do not allow presolver to shift user-supplied initial point

1

allow presolver to shift user-supplied initial point if it only appears in linear constraints

2

allow presolver to shift any user-supplied initial point

  • presolve_level: Knitro presolve level (default -1). See presolve_level.

Value

Description

-1

let Knitro choose the presolve level

1

enable basic presolve operatins

2

enable more advanced presolve operatins

  • presolve_passes: limit on the number of passes through the Knitro presolver (default 10). See presolve_passes.

  • presolve_tol: tolerance used by Knitro presolver to remove variables and constraints (default 1.0e-6). See presolve_tol.

  • presolveop_tighten: Knitro presolve tightening operations (default -1). See presolveop_tighten.

Value

Description

-1

let Knitro choose whether to apply tightening

0

do not apply tightening

1

apply tightening on variable bounds

  • restarts: enable automatic restarts (default 0). See restarts.

Value

Description

0

do not enable automatic restarts

n

maximum of n > 0 restarts allowed

  • restarts_maxit: maximum number of iterations before enforcing a restart (default 0). See restarts_maxit.

  • scale: automatic scaling (default 1). See scale.

Value

Description

0

do not scale the problem

1

perform automatic scaling of functions

  • soc: 2nd order corrections (default 1). See soc.

Value

Description

0

do not allow second order correction steps

1

selectively try second order correction steps

2

always try second order correction steps

  • storequadcoefs: store quadratic coefficients for QCQP (default 1).

Value

Description

0

do not store quadratic coefficients

1

store quadratic coefficients

  • strat_warm_start: enable warm-start strategy (default 0). See strat_warm_start.

Value

Description

0

do not enable warm-start strategy

1

enable warm-start strategy (currently just for barrier algorithms)

  • tuner: invoke Knitro-Tuner (default 0). See tuner.

Value

Description

0

tuner disabled

1

tuner enabled

  • tuner_maxtime_cpu: maximum CPU time in seconds before terminating the Knitro-Tuner (tuner=1) procedure (default 1.0e8). See tuner_maxtime_cpu.

  • tuner_maxtime_real: maximum real time in seconds before terminating the Knitro-Tuner (tuner=1) procedure (default 1.0e8). See tuner_maxtime_real.

  • tuner_optionsfile: path that specifies the location of a Knitro-Tuner (tuner=1) options file if used.

  • tuner_outsub: enable writing additional Tuner subproblem solve output to files for the Knitro-Tuner (tuner=1) procedure (default 0). See tuner_outsub.

Value

Description

0

do not write detailed algorithm output to files

1

write summary solve output to a file named knitro_tuner_summary.log

2

write detailed algorithm output to files named knitro_tuner_*.log

  • tuner_terminate: termination condition for Knitro-Tuner (tuner=1) procedure (default 0). See tuner_terminate.

Value

Description

0

terminate after all solves have completed

1

terminate at first local optimum

2

terminate at first feasible solution

3

terminate after first completed optimization (any termination status)

  • xtol: stepsize termination tolerance (default 1.0e-15). See xtol.

  • xtol_iters: stop based on small changes in the solution estimate. See xtol_iters.

Return codes

Upon completion, Knitro displays a message and returns an exit code to AMPL. If Knitro found a solution, it displays the message:

Locally optimal or satisfactory solution

with exit code of zero; the exit code can be seen by typing:

ampl: display solve_result_num;

If a solution is not found, then Knitro returns a non-zero return code from the table below:

Value

Description

0

Locally optimal or satisfactory solution.

100

Current feasible solution estimate cannot be improved. Nearly optimal.

101

Relative change in feasible solution estimate < xtol.

102

Current feasible solution estimate cannot be improved.

103

Relative change in feasible objective < ftol for ftol_iters.

200

Convergence to an infeasible point. Problem may be locally infeasible.

201

Relative change in infeasible solution estimate < xtol.

202

Current infeasible solution estimate cannot be improved.

203

Multistart: No primal feasible point found.

204

Problem determined to be infeasible with respect to constraint bounds.

205

Problem determined to be infeasible with respect to variable bounds.

300

Problem appears to be unbounded.

400

Iteration limit reached. Current point is feasible.

401

Time limit reached. Current point is feasible.

402

Function evaluation limit reached. Current point is feasible.

403

MIP: All nodes have been explored. Integer feasible point found.

404

MIP: Integer feasible point found.

405

MIP: Subproblem solve limit reached. Integer feasible point found.

406

MIP: Node limit reached. Integer feasible point found.

410

Iteration limit reached. Current point is infeasible.

411

Time limit reached. Current point is infeasible.

412

Function evaluation limit reached. Current point is infeasible.

413

MIP: All nodes have been explored. No integer feasible point found.

415

MIP: Subproblem solve limit reached. No integer feasible point found.

416

MIP: Node limit reached. No integer feasible point found.

501

LP solver error.

502

Evaluation error.

503

Not enough memory.

504

Terminated by user.

505

Terminated after derivative check.

506

Input or other API error.

507

Internal Knitro error.

508

Unknown termination.

509

Illegal objno value.

For more information on return codes, see Return codes.

AMPL suffixes defined for Knitro

To represent values associated with a model component, AMPL employs various qualifiers or suffixes appended to component names. A suffix consists of a period or “dot” (.) followed by a short identifier (ex: x1.lb returns the current lower bound of the variable x1).

A lot of built-in suffixes are available in AMPL, you may find the list at http://www.ampl.com/NEW/suffbuiltin.html.

To allow more solver-specific results of optimization, AMPL permits solver drivers to define new suffixes and to associate solution result information with them. Below is the list of the suffixes defined specifically for Knitro.

Suffix Name

Description

Model component

honorbnd

Specify variables that must always satisfy bounds; see honorbnds (input)

variable

intvarstrategy

Treatment of integer variables; see mip_intvar_strategy (input)

variable

cfeastol

Specify individual constraint feasibility tolerances (input)

constraint

xfeastol

Specify individual variable bound feasibility tolerances (input)

variable

xscalefactor

Specify custom variable scaling factors (input)

variable

xscalecenter

Specify custom variable scaling centers (input)

variable

cscalefactor

Specify custom constraint scaling factors (input)

constraint

objscalefactor

Specify custom objective scaling factor (input)

objective

relaxbnd

Retrieve the best relaxation bound for MIP (output)

objective

incumbent

Retrieve the incumbent solution for MIP (output)

objective

priority

Specify branch priorities for MIP (input)

variable

numiters

Retrieve the number of iterations (output)

objective

numfcevals

Retrieve the number of function evaluations (output)

objective

opterror

Retrieve the final optimality error (output)

objective, variable, constraint

feaserror

Retrieve the final feasibility error (output)

objective, variable, constraint

Below is an example on how to use the specific Knitro suffixes in AMPL:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var x{j in 1..3} >= 0;

minimize obj: 1000 - x[1]^2 - 2*x[2]^2 - x[3]^2 - x[1]*x[2] - x[1]*x[3];

s.t. c1: 8*x[1] + 14*x[2] + 7*x[3] - 56 = 0;

s.t. c2: x[1]^2 + x[2]^2 + x[3]^2 -25 >= 0;

suffix xfeastol IN, >=0, <=1e6;
suffix cfeastol IN, >=0, <=1e6;
suffix objscalefactor IN, >=1e-6, <=1e6;

let x[1].xfeastol := 1e-1;
let c1.cfeastol := 1e-2;
let obj.objscalefactor := 2;

solve;

display x[1].feaserror;
display c1.opterror;
display obj.numfcevals;
display obj.feaserror;
display obj.opterror;

Below is the corresponding output:

Final Statistics
----------------
Final objective value               =  9.51000000020162e+002
Final feasibility error (abs / rel) =   7.11e-015 / 4.55e-016
Final optimality error  (abs / rel) =   3.84e-009 / 1.37e-010
# of iterations                     =          9
# of CG iterations                  =          2
# of function evaluations           =         12
# of gradient evaluations           =         11
# of Hessian evaluations            =          9
Total program time (secs)           =       0.035 (     0.000 CPU time)
Time spent in evaluations (secs)    =       0.000

===============================================================================

Locally optimal or satisfactory solution.
objective 951; feasibility error 7.11e-15
9 iterations; 12 function evaluations

suffix feaserror OUT;
suffix opterror OUT;
suffix numfcevals OUT;
suffix numiters OUT;
x[1].feaserror = 0

c1.opterror = 0

obj.numfcevals = 12

obj.feaserror = 7.10543e-15

obj.opterror = 3.84018e-09

Nonlinear Least Squares

In some cases it may be more efficient to use the specialized Knitro API for nonlinear least-squares (see Least squares problems), which internally applies the Gauss-Newton Hessian, to solve a least-squares model formulated in AMPL. In particular this may be useful if the exact Hessian computed by AMPL is expensive. You can apply this specialized interface through AMPL by following these steps:

  • Set the objective function to 0

  • Specify each residual function as an equality constraint

  • Turn the AMPL presolver off by setting

option presolve 0;
  • Tell Knitro to apply the least-squares interface and disable presolve by setting

option knitro_options "leastsquares=1 presolve=0";

Below is an example of how to solve nonlinear least-squares problems in AMPL:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
###########################################################
####              LSQ in AMPL with Knitro              ####
####                                                   ####
#### This example illustrates how to optimize least    ####
#### squares problems in AMPL by formulating it using  ####
#### AMPL syntax and also using Knitro least squares   ####
#### dedicated API.                                    ####
###########################################################

# Reset AMPL
reset;

# Reset initial guesses between consecutive runs
option reset_initial_guesses 1;

# Reinitialize random seed for generating same values over runs
option randseed 1;

### The first part of the example will demonstrate how to formulate a
### least squares problem in AMPL using usual AMPL syntax.
### Also, we will illustrate an AMPL trick to improve performances.

# We use a large number to demonstrate the AMPL expansion trick
param M := 1000000;

# Create random values for the "estimates"
param alpha{1..M};
let{i in 1..M} alpha[i] := Uniform01();

# Variable: minimize the sum of squares of the distance between var_alpha
# and the "estimates"
var var_alpha;

### 1. Straightforward least squares formulation with no expansion ###

## Straightforward least square problem.
## The objective is expressed directly, without expanding the square terms.
minimize obj_no_expand:
    0.5 * sum{i in 1..M} (alpha[i]-var_alpha)^2;

# Optimize non-expanded problem
solve obj_no_expand;


### 2. Least squares with square terms expansion ###

## Same problem but this time the objective is expanded.
## Notice that, using this trick, the runtime decreases significantly.
minimize obj_expanded:
    0.5 * (
        M * var_alpha^2 -
        2 * var_alpha * ( sum{i in 1..M} alpha[i] ) +
        sum{i in 1..M} alpha[i]^2
    );

# Optimize expanded problem
solve obj_expanded;

# Check objective value
display obj_expanded - obj_no_expand;


### 3. Least squares using Knitro LSQ API ###

# Set Ampl and Knitro options
option presolve 0; # disable AMPL presolve, this is mandatory!
option knitro_options "leastsquares=1 presolve=0"; # Enable Knitro LSQ

## Same problem but this time based on Knitro's least-squares API.
# Objective must be constant
minimize obj_lsq: 0;

# Each residual is a constraint: residual = 0
# s.t. res{i in 1..M}:(alpha[i]-var_alpha)^2 = 0;
s.t. res{i in 1..M}:
    alpha[i] - var_alpha = 0;

# Optimize problem using on Knitro LSQ API
solve obj_lsq;

Below is the corresponding (filtered) output:

[...]

  Iter      Objective      FeasError   OptError    ||Step||    CGits
--------  --------------  ----------  ----------  ----------  -------
       0   1.665516e+005  0.000e+000
       1   4.168899e+004  0.000e+000  2.754e-013  4.997e-001        0

EXIT: Locally optimal solution found.

Final Statistics
----------------
Final objective value               =  4.16889869527361e+004
Final feasibility error (abs / rel) =   0.00e+000 / 0.00e+000
Final optimality error  (abs / rel) =   2.75e-013 / 3.30e-014
# of iterations                     =          1
# of CG iterations                  =          0
# of function evaluations           =          4
# of gradient evaluations           =          3
# of Hessian evaluations            =          1
Total program time (secs)           =       0.452 (     0.453 CPU time)
Time spent in evaluations (secs)    =       0.274

===============================================================================

[...]

  Iter      Objective      FeasError   OptError    ||Step||    CGits
--------  --------------  ----------  ----------  ----------  -------
       0   1.665516e+005  0.000e+000
       1   4.168899e+004  0.000e+000  0.000e+000  4.997e-001        0

EXIT: Locally optimal solution found.

Final Statistics
----------------
Final objective value               =  4.16889869527314e+004
Final feasibility error (abs / rel) =   0.00e+000 / 0.00e+000
Final optimality error  (abs / rel) =   0.00e+000 / 0.00e+000
# of iterations                     =          1
# of CG iterations                  =          0
# of function evaluations           =          4
# of gradient evaluations           =          3
# of Hessian evaluations            =          1
Total program time (secs)           =       0.002 (     0.000 CPU time)
Time spent in evaluations (secs)    =       0.000

===============================================================================

[...]

  Iter      Objective      FeasError   OptError    ||Step||    CGits
--------  --------------  ----------  ----------  ----------  -------
       0   1.665516e+005  0.000e+000
       1   4.168899e+004  0.000e+000  1.376e-009  4.997e-001        0

EXIT: Locally optimal solution found.

Final Statistics
----------------
Final objective value               =  4.16889869527361e+004
Final feasibility error (abs / rel) =   0.00e+000 / 0.00e+000
Final optimality error  (abs / rel) =   1.38e-009 / 3.30e-014
# of iterations                     =          1
# of CG iterations                  =          0
# of residual evaluations           =          4
# of Jacobian evaluations           =          2
Total program time (secs)           =       0.301 (     0.500 CPU time)
Time spent in evaluations (secs)    =       0.163