Knitro attributes

Knitro exposes a set of read-only attributes that can be queried after a solve to inspect model properties and solution statistics. See Querying attributes programmatically for how to query attributes in each interface.

Model

Name

API constant

ID

Type

Description

numvars

KN_ATTR_NUM_VARS

100

integer

Number of variables in the model.

numcons

KN_ATTR_NUM_CONS

101

integer

Number of constraints in the model.

numcompcons

KN_ATTR_NUM_COMPCONS

102

integer

Number of complementarity constraints in the model.

numrsds

KN_ATTR_NUM_RSDS

103

integer

Number of residuals in the model (for least-squares problems).

objgoal

KN_ATTR_OBJ_GOAL

110

integer

Objective goal: 0 for minimize, 1 for maximize.

objtype

KN_ATTR_OBJ_TYPE

111

integer

Type of objective function: -1 for constant, 0 for general, 1 for linear, 2 for quadratic.

objgradnnz

KN_ATTR_OBJ_GRAD_NNZ

200

long integer

Number of nonzeros in the objective gradient.

jacnnz

KN_ATTR_JAC_NNZ

201

long integer

Number of nonzeros in the constraint Jacobian.

hessnnz

KN_ATTR_HESS_NNZ

202

long integer

Number of nonzeros in the Hessian of the Lagrangian.

General

Name

API constant

ID

Type

Description

numiters

KN_ATTR_NUM_ITERS

120

integer

Number of iterations performed by the solver for continuous solves.

numcgiters

KN_ATTR_NUM_CG_ITERS

121

integer

Number of conjugate gradient iterations performed.

numfcevals

KN_ATTR_NUM_FC_EVALS

122

integer

Number of function/constraint evaluations.

numgaevals

KN_ATTR_NUM_GA_EVALS

123

integer

Number of gradient evaluations.

numhevals

KN_ATTR_NUM_H_EVALS

124

integer

Number of Hessian evaluations.

numhvevals

KN_ATTR_NUM_HV_EVALS

125

integer

Number of Hessian-vector product evaluations.

objvalue

KN_ATTR_OBJ_VALUE

300

double

Final objective function value.

absfeaserror

KN_ATTR_ABS_FEAS_ERROR

301

double

Absolute feasibility error at the solution.

relfeaserror

KN_ATTR_REL_FEAS_ERROR

302

double

Relative feasibility error at the solution.

absopterror

KN_ATTR_ABS_OPT_ERROR

303

double

Absolute optimality error at the solution.

relopterror

KN_ATTR_REL_OPT_ERROR

304

double

Relative optimality error at the solution.

solvetimecpu

KN_ATTR_SOLVE_TIME_CPU

310

double

CPU time spent in the solve (in seconds).

solvetimereal

KN_ATTR_SOLVE_TIME_REAL

311

double

Real/wall-clock time spent in the solve (in seconds).

MIP

Name

API constant

ID

Type

Description

mipnumnodes

KN_ATTR_MIP_NUM_NODES

140

integer

Number of nodes explored in the MIP branch-and-bound tree.

mipnumsolves

KN_ATTR_MIP_NUM_SOLVES

141

integer

Number of subproblem solves in the MIP algorithm.

mipabsgap

KN_ATTR_MIP_ABS_GAP

340

double

Absolute gap between incumbent and relaxation bound in MIP.

miprelgap

KN_ATTR_MIP_REL_GAP

341

double

Relative gap between incumbent and relaxation bound in MIP.

mipincumbentobj

KN_ATTR_MIP_INCUMBENT_OBJ

342

double

Objective value of the current best integer solution in MIP.

miprelaxationbnd

KN_ATTR_MIP_RELAXATION_BND

343

double

Best relaxation bound in MIP.