Problem#
- Problem(p_struct)
Problem is a class that defines an optimization problem.
Problem describes an optimization problem with the following structure:
where fun is the objective function, x is the variable to optimize, xl and xu are the lower and upper bounds, aub and bub are the coefficient matrix and right-hand side vector of the linear inequality constraints, aeq and beq are the coefficient matrix and right-hand side vector of the linear equality constraints, cub is the function of nonlinear inequality constraints, ceq is the function of nonlinear equality constraints.
Problem should be initialized by the following signature:
P = Problem(p_struct) creates an instance of the class Problem and the input p_struct is a struct.
The input struct p_struct should contain the following fields:
Compulsory fields:
fun: The objective function to be minimized. It should accept a vector and return a real number:
fun(x) -> float, wherexis a vector.x0: the initial guess.
Optional fields:
name: the name of the problem. It should be a string scalar or a char row. Default is
'Unnamed Problem'.xl: the lower bounds on the variable
xin the form ofxl <= x. It should be a vector of the same size asx. Default is-Inf, which means no bound.NaNandInfare rejected.xu: the upper bounds on the variable
xin the form ofxl >= x. It should be a vector of the same size asx. Default isInf, which means no bound.NaNand-Infare rejected.aub, bub: the coefficient matrix and right-hand side vector of the linear inequality constraints
aub * x <= bub. The default setting ofaubandbubare empty matrix and vector. The entries ofaubmust be finite. An entryInfofbubmeans that the row imposes no constraint;NaNand-Infare rejected.aeq, beq: the coefficient matrix and right-hand side vector of the linear equality constraints
aeq * x = beq. The default setting of aeq and beq are empty matrix and vector. Their entries must be finite.cub: the function of nonlinearly inequality constraints
cub(x) <= 0, wherecub(x) -> float vector. By default,cub(x)will return an empty vector.ceq: the function of nonlinear equality constraints
ceq(x) = 0, whereceq(x) -> float vector. By default,ceq(x)will return an empty vector.grad: the gradient of the objective function
grad(x) -> float vector. By default,grad(x)will return an empty vector.hess: the Hessian of the objective function
hess(x) -> float matrix. By default,hess(x)will return an empty matrix.jcub: the Jacobian of the nonlinearly inequality constraints
jcub(x) -> float matrix. Note that the column size ofjcub(x)should be the same as the length ofxwhile the row size should be the same as the length ofcub(x). By default,jcub(x)will return an empty matrix.jceq: the Jacobian of the nonlinearly equality constraints
jceq(x) -> float matrix. Note that the column size ofjceq(x)should be the same as the length ofxwhile the row size should be the same as the length ofceq(x). By default,jceq(x)will return an empty matrix.hcub: the Hessian of the nonlinearly inequality constraints
hcub(x) -> cell array of float matrices. The i-th element ofhcub(x)should be the Hessian of the i-th function incub. By default,hcub(x)will return an empty cell.hceq: the Hessian of the nonlinearly equality constraints
hceq(x) -> cell array of float matrices. The i-th element ofhceq(x)should be the Hessian of the i-th function inceq. By default,hceq(x)will return an empty cell.reference: an optional author/provider fact with four required fields:
fun(finite objective),maxcv(finite nonnegative total violation),kindandsource(non-empty provenance text).kind='feasible'requiresmaxcv=0;kind='merit'permits nonzero violation, with the user responsible for the chosen merit function and target. Optionalx_refis source metadata in original problem coordinates. Features do not transport it or query the oracle to maintain it. Earlier kinds and known mapping tokens remain readable as compatibility inputs; new records need no mapping token. Validation evaluates no objective or constraint.Standard profiles convert a retained reference using
merit_fun(fun,maxcv,maxcv_init)for each run and on load. Missing or invalidated references keep the V1 minimum over selected solver histories, initial values and the optional plain run. This default is not a third kind or a certified optimum. Actual observations are never clamped. Every custom stage and ground-truth quantization uses the default target in this release. Other supported built-ins retain raw values, including nonzero violation under affine changes. See FeaturedProblem for feature propagation.
The output P contains following properties:
Properties inherited from the input struct:
name, x0, xl, xu, aub, bub, aeq, beq, reference
(
referenceis[]when unknown, otherwise a struct withfun,maxcv,kind,sourceand optional original-coordinatex_ref. It is set at construction only and cannot be assigned. Rejected stored records read as[]with a warning; supported legacy records are normalized explicitly.)
Properties dependent on the input struct:
ptype: type of the problem. It should be
'u'(unconstrained),'b'(bound-constrained),'l'(linearly constrained), or'n'(nonlinearly constrained).n: dimension of the problem, which is the length of the variable
x.mb: number of the bound constraints, which is the length of finite elements in
xlandxu.m_linear_ub: number of the linear inequality constraints, which is the number of entries of
bubthat are notInf. A row with the right-hand sideInfstays inaubandbub.m_linear_eq: number of the linear equality constraints, which is the length of
beq.m_nonlinear_ub: number of the nonlinear inequality constraints, which is the length of
cub(x).m_nonlinear_eq: number of the nonlinear equality constraints, which is the length of
ceq(x).mlcon: number of the linear constraints, which is the sum of
m_linear_ubandm_linear_eq.mnlcon: number of the nonlinear constraints, which is the sum of
m_nonlinear_ubandm_nonlinear_eq.mcon: number of the constraints, which is the sum of
mlconandmnlcon.
The output P contains following methods:
Methods inherited from the input struct:
fun, grad, hess, cub, ceq, jcub, jceq, hcub, hceq
Other methods:
maxcv: the maximum constraint violation
maxcv(x) -> float, which is defined as the maximum of the infinity norms ofmax(xl - x, 0),max(x - xu, 0),max(aub * x - bub, 0),aeq * x - beq,max(cub(x), 0),ceq(x).project_x0: trying to project the initial guess
x0onto the feasible region if it is not feasible (but it may fail).
The constructor refuses malformed constraint data. Data assigned to an existing object, as in p.xl = [Inf; Inf], are not checked at the assignment, because a setter that raises would make load drop the data of a saved object without an error. They are checked when a trial is built: benchmark and FeaturedProblem refuse them. In a library run this costs only that problem, which the report lists as problem_load_failed. The object itself does not check them, so p.maxcv(x) measures what it holds and can return 0.