Common Definitions

Header: mp/common.h

enum mp::var::Type

Variable type.

Values:

CONTINUOUS

A continuous variable.

INTEGER

An integer variable.

enum mp::obj::Type

Objective type.

Values:

MIN = 0

A minimization objective.

MAX = 1

A maximization objective.

enum mp::func::Type

Function type.

Values:

NUMERIC = 0

A numeric function.

SYMBOLIC = 1

A symbolic function accepting numeric and string arguments.

class mp::ComplInfo

Complementarity constraint information.

Public Functions

ComplInfo(int flags)

Constructs a ComplInfo object.

double con_lb() const

Constraint lower bound.

double con_ub() const

Constraint upper bound.

enum mp::suf::Kind

Suffix kind.

Values:

VAR = 0

Applies to variables.

CON = 1

Applies to constraints.

OBJ = 2

Applies to objectives.

PROBLEM = 3

Applies to problems.

enum mp::sol::Status

Solution status.

Values:

UNKNOWN = -1

Unknown status.

SOLVED = 0

An optimal solution found for an optimization problem or a feasible solution found for a satisfaction problem.

UNCERTAIN = 100

Solution returned but it can be non-optimal or even infeasible.

INFEASIBLE = 200

Problem is infeasible.

UNBOUNDED = 300

Problem is unbounded.

LIMIT = 400

Stopped by a limit, e.g.

on iterations or time.

FAILURE = 500

A solver error.

INTERRUPTED = 600

Interrupted by the user.

enum mp::expr::Kind

Expression kind. Both AMPL-like and mathematical notation is given for each expression in the descriptions below as in \(\mathrm{abs}(x) = |x|\), unless they are identical such as \(\mathrm{sin}(x)\) or there is no standard mathematical notation.

Values:

UNKNOWN = 0

An unknown expression.

FIRST_EXPR

The first expression kind other than the unknown expression kind.

FIRST_NUMERIC = FIRST_EXPR

The first numeric expression kind. Numeric expression kinds are in the range [FIRST_NUMERIC, LAST_NUMERIC].

NUMBER = FIRST_NUMERIC

A number such as 42 or -1.23e-4.

FIRST_REFERENCE

The first reference expression kind. Reference expression kinds are in the range [FIRST_REFERENCE, LAST_REFERENCE].

VARIABLE = FIRST_REFERENCE

A reference to a variable.

COMMON_EXPR

A reference to a common expression.

LAST_REFERENCE = COMMON_EXPR

The last reference expression kind.

FIRST_UNARY

The first unary numeric expression kind. Unary numeric expression kinds are in the range [FIRST_UNARY, LAST_UNARY].

MINUS = FIRST_UNARY

A unary minus, \(-x\).

ABS

The absolute value function, \(\mathrm{abs}(x) = |x|\).

FLOOR

The floor function, \(\mathrm{floor}(x) = \lfloor x \rfloor\).

CEIL

The ceiling function, \(\mathrm{ceil}(x) = \lceil x \rceil\).

SQRT

The square root function, \(\mathrm{sqrt}(x) = \sqrt{x}\).

POW2

Squaring: \(x \mathop{\verb!^!} 2 = x^2\).

EXP

The natural exponential function, \(\mathrm{exp}(x) = e^x\).

LOG

The natural logarithmic function, \(\mathrm{log}(x) = \mathrm{ln}(x)\).

LOG10

The base 10 logarithmic function, \(\mathrm{log10}(x) = \mathrm{log}_{10}(x)\).

SIN

Sine, \(\mathrm{sin}(x)\).

SINH

Hyperbolic sine, \(\mathrm{sinh}(x)\).

COS

Cosine, \(\mathrm{cos}(x)\).

COSH

Hyperbolic cosine, \(\mathrm{cosh}(x)\).

TAN

Tangent, \(\mathrm{tan}(x)\).

TANH

Hyperbolic tangent, \(\mathrm{tan}(x)\).

ASIN

Inverse sine, \(\mathrm{asin}(x) = \mathrm{sin}^{-1}(x)\).

ASINH

Inverse hyperbolic sine, \(\mathrm{asinh}(x) = \mathrm{sinh}^{-1}(x)\).

ACOS

Inverse cosine, \(\mathrm{acos}(x) = \mathrm{cos}^{-1}(x)\).

ACOSH

Inverse hyperbolic cosine, \(\mathrm{acosh}(x) = \mathrm{cosh}^{-1}(x)\).

ATAN

Inverse tangent, \(\mathrm{atan}(x) = \mathrm{tan}^{-1}(x)\).

ATANH

Inverse hyperbolic tangent, \(\mathrm{atanh}(x) = \mathrm{tanh}^{-1}(x)\).

LAST_UNARY = ATANH

The last unary numeric expression kind.

FIRST_BINARY

The first binary expression kind. Binary expression kinds are in the range [FIRST_BINARY, LAST_BINARY].

ADD = FIRST_BINARY

Addition, \(x + y\).

SUB

Subtraction, \(x - y\).

LESS

The \(\mathrm{less}\) operation, \(x \mathop{\rm less} y = \mathrm{max}(x - y, 0)\).

MUL

Multiplication, \(x * y = x y\).

DIV

Division, \(x / y\).

TRUNC_DIV

Truncated division, \(x \mathop{\rm div} y = \mathrm{trunc}(x / y)\).

MOD

The modulo operation, \(x \mathop{\rm mod} y\).

POW

Exponentiation, \(x \mathop{\verb!^!} y = x^y\).

POW_CONST_BASE

Exponentiation with a constant base, \(a^x\).

POW_CONST_EXP

Exponentiation with a constant exponent \(x^a\).

ATAN2

Inverse tangent, \(\mathrm{atan2}(y, x) = \mathrm{tan}^{-1}(y/x)\).

PRECISION

The function \(\mathrm{precision}(x, n)\) which returns \(x\) rounded to \(n\) significant decimal digits.

ROUND

The function \(\mathrm{round}(x, n)\) which returns \(x\) rounded to \(n\) digits past decimal point.

TRUNC

The function \(\mathrm{trunc}(x, n)\) which returns \(x\) truncated to \(n\) digits past decimal point.

LAST_BINARY = TRUNC

The last binary numeric expression kind.

IF

An if-then-else expression, \(\mathrm{if}\;c\;\mathrm{then}\;e_1\;[\mathrm{else}\;e_2]\), where \(c\) is a logical expression representing condition, while \(e_1\) and \(e_2\) are numeric expressions. The expression evaluates to \(e_1\) if \(c\) is true and to \(e_2\) otherwise. If the else clause is omitted, \(e_2\) is assumed to be zero.

PLTERM

A piecewise-linear term, \(\verb|<<|b_1, ..., b_n; s_1, ..., s_{n + 1}\verb|>> | r\), where \(b_i\) are breakpoints, \(s_i\) are slopes and \(r\) is a reference.

CALL

A function call, \(f(e_1, ..., e_n)\), where \(f\) is a function name and \(e_i\) are numeric or string expressions.

FIRST_ITERATED

The first iterated expression kind. Iterated expression kinds are in the range [FIRST_ITERATED, LAST_ITERATED].

The term “iterated” in the context of operators and expressions comes from the article AMPL: A Mathematical Programming Language and is used to denote operators indexed over sets.

FIRST_VARARG = FIRST_ITERATED

A vararg expression, \(\mathrm{min}\) or \(\mathrm{max}\). Vararg expression kinds are in the range [FIRST_VARARG, LAST_VARARG].

MIN = FIRST_VARARG

Minimum, \(\mathrm{min}(e_1, ..., e_n) = \min_{i=1,...,n} e_i\).

MAX

Maximum, \(\mathrm{max}(e_1, ..., e_n) = \max_{i=1,...,n} e_i\).

LAST_VARARG = MAX

The last vararg expression kind.

SUM

Summation, \(\mathrm{sum}(e_1, ..., e_n) = \sum_{i=1}^n e_i\).

NUMBEROF

A \(\mathrm{numberof}\) expression, \(\mathrm{numberof}\;e_0\;\mathrm{in}\;(e_1, ..., e_n)\), which evaluates to the number of times the value of \(e_0\) appears among the values of \(e_1, ..., e_n\).

LAST_ITERATED = NUMBEROF

The last iterated expression kind.

NUMBEROF_SYM

A symbolic \(\mathrm{numberof}\) expression. \(\mathrm{numberof}\;s_0\;\mathrm{in}\;(s_1, ..., s_n)\), which evaluates to the number of times the value of \(s_0\) appears among the values of \(s_1, ..., s_n\).

COUNT

A \(\mathrm{count}\) expression, \(\mathrm{count}(l_1, ..., l_n)\), where \(l_i\) are logical expressions. This expression evaluates to the number of \(l_i\) whose values are true.

LAST_NUMERIC = COUNT

The last numeric expression kind.

FIRST_LOGICAL

The first logical expression kind. Logical expression kinds are in the range [FIRST_LOGICAL, LAST_LOGICAL].

BOOL = FIRST_LOGICAL

A Boolean (logical) constant, true or false.

NOT

A logical not, \(!l\), where \(l\) is a logical expression.

FIRST_BINARY_LOGICAL

The first binary logical expression kind. Binary logical expression kinds are in the range [FIRST_BINARY_LOGICAL, LAST_BINARY_LOGICAL].

OR = FIRST_BINARY_LOGICAL

Logical or, \(l_1\) || \(l_2\).

AND

Logical and, \(l_1\) && \(l_2\).

IFF

If and only if, \(l_1\) <==> \(l_2\).

LAST_BINARY_LOGICAL = IFF

The last binary logical expression kind.

FIRST_RELATIONAL

The first relational expression kind. Relational expression kinds are in the range [FIRST_RELATIONAL, LAST_RELATIONAL].

LT = FIRST_RELATIONAL

Less than, \(e_1\) < \(e_2\).

LE

Less or equal to, \(e_1\) <= \(e_2\).

EQ

Equal to, \(e_1\) = \(e_2\).

GE

Greater or equal to, \(e_1\) >= \(e_2\).

GT

Greater than, \(e_1\) > \(e_2\).

NE

Not equal to, \(e_1\) != \(e_2\).

LAST_RELATIONAL = NE

The last relational expression kind.

FIRST_LOGICAL_COUNT

The first logical count expression kind. Logical count expression kinds are in the range [FIRST_LOGICAL_COUNT, LAST_LOGICAL_COUNT].

ATLEAST = FIRST_LOGICAL_COUNT

An \(\mathrm{atleast}\) expression, \(\mathrm{atleast}\;e\;(l_1, ..., l_n)\), where \(e\) is a numeric expression and \(l_i\) are logical expressions. It evaluates to true if at least \(e\) expressions \(l_i\) are true.

ATMOST

An \(\mathrm{atmost}\) expression, \(\mathrm{atmost}\;e\;(l_1, ..., l_n)\), where \(e\) is a numeric expression and \(l_i\) are logical expressions. It evaluates to true if at most \(e\) expressions \(l_i\) are true.

EXACTLY

An \(\mathrm{exactly}\) expression, \(\mathrm{exactly}\;e\;(l_1, ..., l_n)\), where \(e\) is a numeric expression and \(l_i\) are logical expressions. It evaluates to true if exactly \(e\) expressions \(l_i\) are true.

NOT_ATLEAST

The negation of an \(\mathrm{atleast}\) expression, \(!\mathrm{atleast}\;e\;(l_1, ..., l_n)\).

NOT_ATMOST

The negation of an \(\mathrm{atmost}\) expression, \(!\mathrm{atmost}\;e\;(l_1, ..., l_n)\).

NOT_EXACTLY

The negation of an \(\mathrm{exactly}\) expression, \(!\mathrm{exactly}\;e\;(l_1, ..., l_n)\).

LAST_LOGICAL_COUNT = NOT_EXACTLY

The last logical count expression kind.

IMPLICATION

An implication expression, \(c\;\verb|==>|\;l_1\;[\mathrm{else}\;l_2]\), where \(c\) is a logical expression representing condition, while \(l_1\) and \(l_2\) are logical expressions. The expression evaluates to \(l_1\) if \(c\) is true and to \(l_2\) otherwise. If the else clause is omitted, \(l_2\) is assumed to be true.

FIRST_ITERATED_LOGICAL

The first iterated logical expression kind. Iterated logical expression kinds are in the range [FIRST_ITERATED_LOGICAL, LAST_ITERATED_LOGICAL].

EXISTS = FIRST_ITERATED_LOGICAL

An \(\mathrm{exists}\) expression, \(\mathrm{exists}(l_1, ..., l_n)\), where \(l_i\) are logical expressions. It evaluates to true if at least one \(l_i\) is true.

FORALL

A \(\mathrm{forall}\) expression, \(\mathrm{forall}(l_1, ..., l_n)\), where \(l_i\) are logical expressions. It evaluates to true if all \(l_i\) are true.

LAST_ITERATED_LOGICAL = FORALL

The last iterated logical expression kind.

FIRST_PAIRWISE

The first pairwise expression kind. Pairwise expression kinds are in the range [FIRST_PAIRWISE, LAST_PAIRWISE].

ALLDIFF = FIRST_PAIRWISE

An alldifferent expression, \(\mathrm{alldiff}(e_1, ..., e_n)\), where \(e_i\) are numeric expressions. It evaluates to true if all \(e_i\) take different values.

NOT_ALLDIFF

The negation of an alldifferent expression, \(!\mathrm{alldiff}(e_1, ..., e_n)\).

LAST_PAIRWISE = NOT_ALLDIFF

The last pairwise expression kind.

LAST_LOGICAL = LAST_PAIRWISE

The last logical expression kind.

STRING

A string such as “abc”.

IFSYM

A symbolic if-then-else expression. \(\mathrm{if}\;c\;\mathrm{then}\;e_1\;[\mathrm{else}\;e_2]\), where \(c\) is a logical expression representing condition, while \(e_1\) and \(e_2\) are numeric or string expressions. The expression evaluates to \(e_1\) if \(c\) is true and to \(e_2\) otherwise. If \(e_2\) is omitted, it is assumed to be zero.

LAST_EXPR = IFSYM

The last expression kind.

const char *mp::expr::str(expr::Kind kind)

Returns the string representation of the given expression kind. Expressions of different kinds can have identical strings. For example, POW, POW_CONST_BASE and POW_CONST_EXP all have the same representation “^”.

int mp::expr::nl_opcode(expr::Kind kind)

Returns the NL opcode for the given expression kind.

struct mp::ProblemInfo

Information about an optimization problem.

Subclassed by mp::NLHeader

Public Functions

int num_integer_vars() const

Returns the number of integer variables (includes binary variable).

int num_continuous_vars() const

Returns the number of continuous variables.

int num_common_exprs() const

Returns the total number of common expressions.

Public Members

int num_vars

Total number of variables.

int num_algebraic_cons

Number of algebraic constraints including ranges and equality constraints.

It doesn’t include logical constraints.

int num_objs

Total number of objectives.

int num_ranges

Number of ranges (constraints with -Infinity < LHS < RHS < Infinity).

int num_eqns

Number of equality constraints or -1 if unknown (AMPL prior to 19970627).

int num_logical_cons

Number of logical constraints.

int num_nl_cons

Total number of nonlinear constraints.

int num_nl_objs

Total number of nonlinear objectives.

int num_compl_conds

Total number of complementarity conditions.

int num_nl_compl_conds

Number of nonlinear complementarity conditions.

int num_compl_dbl_ineqs

Number of complementarities involving double inequalities.

int num_compl_vars_with_nz_lb

Number of complemented variables with a nonzero lower bound.

int num_nl_net_cons

Number of nonlinear network constraints.

int num_linear_net_cons

Number of linear network constraints.

int num_nl_vars_in_cons

Number of nonlinear variables in constraints including nonlinear variables in both constraints and objectives.

int num_nl_vars_in_objs

Number of nonlinear variables in objectives including nonlinear variables in both constraints and objectives.

int num_nl_vars_in_both

Number of nonlinear variables in both constraints and objectives.

int num_linear_net_vars

Number of linear network variables (arcs).

int num_funcs

Number of functions.

int num_linear_binary_vars

Number of linear binary variables.

int num_linear_integer_vars

Number of linear non-binary integer variables.

int num_nl_integer_vars_in_both

Number of integer nonlinear variables in both constraints and objectives.

int num_nl_integer_vars_in_cons

Number of integer nonlinear variables just in constraints.

int num_nl_integer_vars_in_objs

Number of integer nonlinear variables just in objectives.

std::size_t num_con_nonzeros

Number of nonzeros in constraints’ Jacobian.

std::size_t num_obj_nonzeros

Number of nonzeros in all objective gradients.

int max_con_name_len

Length of longest constraint name if names are available.

int max_var_name_len

Length of longest variable name if names are available.

int num_common_exprs_in_both

Number of common expressions that appear both in constraints and objectives.

int num_common_exprs_in_cons

Number of common expressions that appear in multiple constraints and don’t appear in objectives.

int num_common_exprs_in_objs

Number of common expressions that appear in multiple objective and don’t appear in constraints.

int num_common_exprs_in_single_cons

Number of common expressions that only appear in a single constraint and don’t appear in objectives.

int num_common_exprs_in_single_objs

Number of common expressions that only appear in a single objective and don’t appear in constraints.