# Reference

The `AbstractVariable`

interface:

`Convex.AbstractVariable`

— Type`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.

`Convex._value`

— Function`_value(x::AbstractVariable)`

Raw access to the current value of `x`

; used internally by Convex.jl.

`Convex.set_value!`

— Function`set_value!(x::AbstractVariable, v)`

Sets the current value of `x`

to `v`

.

`Convex.constraints`

— Function`constraints(x::AbstractVariable)`

Returns the current constraints carried by `x`

.

`Convex.add_constraint!`

— Function`add_constraint!(x::AbstractVariable, C::Constraint)`

Adds an constraint to those carried by `x`

.

`Convex.vexity`

— Function`vexity(x::AbstractVariable)`

Returns the current vexity of `x`

.

`Convex.vexity!`

— Function`vexity!(x::AbstractVariable, v::Vexity)`

Sets the current vexity of `x`

to `v`

. Should only be called by `fix!`

and `free!`

.

`Base.sign`

— Function`sign(x)`

Return zero if `x==0`

and $x/|x|$ otherwise (i.e., ±1 for real `x`

).

`sign(x::AbstractVariable)`

Returns the current sign of `x`

.

`Convex.sign!`

— Function`sign!(x::AbstractVariable, s::Sign)`

Sets the current sign of `x`

to `s`

.

`Convex.VarType`

— Type`VarType`

Describe the type of a `AbstractVariable`

: either continuous (`ContVar`

), integer-valued (`IntVar`

), or binary (`BinVar`

).

`Convex.vartype`

— Function`vartype(x::AbstractVariable)`

Returns the current `VarType`

of `x`

.

`Convex.vartype!`

— Function`vartype!(x::AbstractVariable, vt::VarType)`

Sets the current `VarType`

of `x`

to `vt`

.

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!`

.

`Convex.free!`

— Function`free!(x::AbstractVariable)`

Frees a previously `fix!`

'd variable `x`

, to treat it once again as a variable to optimize over.

`Convex.evaluate`

— Function`evaluate(x::AbstractExpr)`

Returns the current value of `x`

if assigned; errors otherwise.

`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.

`Convex.emit_dcp_warnings`

— Function`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).