Reference

The AbstractVariable interface:

Convex.AbstractVariableType
abstract type AbstractVariable <: AbstractExpr end

An AbstractVariable should have head field, an id_hash field and a size field to conform to the AbstractExpr interface, and implement methods (or use the field-access fallbacks) for

  • _value, set_value!: get or set the numeric value of the variable. _value should return nothing when no numeric value is set. Note: evaluate is the user-facing method to access the value of x.
  • vexity, vexity!: get or set the vexity of the variable. The vexity should be AffineVexity() unless the variable has been fix!'d, in which case it is ConstVexity().
  • sign, vartype, and constraints: get the Sign, VarType, numeric type, and a (possibly empty) vector of constraints which are to be applied to any problem in which the variable is used.

Optionally, also implement sign!, vartype!, and add_constraint! to allow users to modify those values or add a constraint.

source
Convex._valueFunction
_value(x::AbstractVariable)

Raw access to the current value of x; used internally by Convex.jl.

source
Convex.vexity!Function
vexity!(x::AbstractVariable, v::Vexity)

Sets the current vexity of x to v. Should only be called by fix! and free!.

source
Base.signFunction
sign(x)

Return zero if x==0 and $x/|x|$ otherwise (i.e., ±1 for real x).

source
sign(x::AbstractVariable)

Returns the current sign of x.

source
Convex.sign!Function
sign!(x::AbstractVariable, s::Sign)

Sets the current sign of x to s.

source

Functions:

Convex.fix!Function
fix!(x::AbstractVariable, v = value(x))

Fixes x to v. It is subsequently treated as a constant in future optimization problems. See also free!.

source
Convex.free!Function
free!(x::AbstractVariable)

Frees a previously fix!'d variable x, to treat it once again as a variable to optimize over.

source
Convex.evaluateFunction
evaluate(x::AbstractExpr)

Returns the current value of x if assigned; errors otherwise.

source
Convex.solve!Function
solve!(problem::Problem{T}, optimizer::MOI.ModelLike;
    check_vexity::Bool = true,
    verbose::Bool = true,
    warmstart::Bool = false,
    silent_solver::Bool = false) where {T}

Solves the problem, populating problem.optval with the optimal value, as well as the values of the variables (accessed by evaluate) and constraint duals (accessed by cons.dual), where applicable.

Optional keyword arguments:

  • check_vexity (default: true): emits a warning if the problem is not DCP
  • verbose (default: true): emits a warning if the problem was not solved optimally or warmstart=true but is not supported by the solver.
  • warmstart (default: false): whether the solver should start the optimization from a previous optimal value (according to the current value of the variables in the problem, which can be set by set_value! and accessed by evaluate).
  • silent_solver: whether the solver should be silent (and not emit output or logs) during the solution process.
source
Convex.emit_dcp_warningsFunction
emit_dcp_warnings

Controls whether or not warnings are emitted for when an expression fails to be of disciplined convex form. To turn warnings off, override the method via

Convex.emit_dcp_warnings() = false

This will cause Julia's method invalidation to recompile any functions emitting DCP warnings and remove them. This should be run from top-level (not within a function).

source