Extracts the dual value (shadow cost) of a constraint.

dual(m, constr)

dual(m, constr)

Arguments

m

The model object.

constr

The constraint in question.

Value

The dual value (shadow cost) of a constraint. Returns NA if there are integer or binary variables in the model.

Examples

m <- Model() m$var(x >= 0) m$objective(x)
#> Found more than one class "ramlVariable" in cache; using the first, from namespace 'raml'
#> Also defined by ‘.GlobalEnv’
#> Found more than one class "ramlVariable" in cache; using the first, from namespace 'raml'
#> Also defined by ‘.GlobalEnv’
#> Error in e2 * e1: invalid object (non-function) used as method
m$constraint(x >= 0.1)
#> Found more than one class "ramlVariable" in cache; using the first, from namespace 'raml'
#> Also defined by ‘.GlobalEnv’
#> Found more than one class "ramlVariable" in cache; using the first, from namespace 'raml'
#> Also defined by ‘.GlobalEnv’
#> Error in e2 * e1: invalid object (non-function) used as method
m$solve()
#> Error in dimnames(x) <- dn: length of 'dimnames' [1] not equal to array extent
dual(m, x >= 0.1) # 1.0
#> Error in e2 * e1: invalid object (non-function) used as method