Skip to content

Commit

Permalink
Update setvar! and setconstr! docstrings (#497)
Browse files Browse the repository at this point in the history
* update setvar! docstring

* describe each argument of setvar! and setconstr!

* fix docstrings

Co-authored-by: Guillaume Marques <[email protected]>

Co-authored-by: Guillaume Marques <[email protected]>
  • Loading branch information
laradicp and guimarqu authored Apr 7, 2021
1 parent 549ab01 commit 10157d5
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions src/MathProg/formulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,26 @@ set_matrix_coeff!(

"""
setvar!(
formulation::Formulation, name::String, duty::Duty{Variable};
cost::Float64 = 0.0,
lb::Float64 = 0.0,
ub::Float64 = Inf,
kind::VarKind = Continuous,
inc_val::Float64 = 0.0,
is_active::Bool = true,
is_explicit::Bool = true,
moi_index::MoiVarIndex = MoiVarIndex(),
formulation, name, duty;
cost = 0.0,
lb = 0.0,
ub = Inf,
kind = Continuous,
is_active = true,
is_explicit = true,
members = nothing,
id = generatevarid(duty, form)
)
Create a new variable in a formulation with given name and duties.
Other arguments are facultative.
Create a new variable that has name `name` and duty `duty` in the formulation `formulation`.
Following keyword arguments allow the user to set additional information about the new variable :
- `cost`: cost of the variable in the objective function
- `lb`: lower bound of the variable
- `ub`: upper bound of the variable
- `kind`: kind which can be `Continuous`, `Binary` or `Integ`
- `is_active`: `true` if the variable is used in the formulation, `false` otherwise
- `is_explicit`: `true` if the variable takes part to the formulation, `false` otherwise (e.g. a variable used as a shortcut for calculation purposes)
- `members`: a dictionary `Dict{ConstrId, Float64}` that contains the coefficients of the new variable in the constraints of the formulation (default coefficient is 0).
"""
function setvar!(
form::Formulation,
Expand Down Expand Up @@ -337,21 +342,25 @@ end

"""
setconstr!(
form::Formulation, name::String, duty::Duty{Constraint};
rhs::Float64 = 0.0,
kind::ConstrKind = Essential,
sense::ConstrSense = Greater,
inc_val::Float64 = 0.0,
is_active::Bool = true,
is_explicit::Bool = true,
moi_index::MoiConstrIndex = MoiConstrIndex(),
formulation, name, duty;
rhs = 0.0,
kind = Essential,
sense = Greater,
is_active = true,
is_explicit = true,
members = nothing,
loc_art_var_abs_cost = 0.0,
id = generateconstrid(duty, form)
)
Create a new constraint in a formulation with given name and duties.
Other arguments are facultative.
Create a new constraint that has name `name` and duty `duty` in the formulation `formulation`.
Following keyword arguments allow the user to set additional information about the new constraint :
- `rhs`: right-hand side of the constraint
- `kind`: kind which can be `Essential` or `Facultative`
- `sense`: sense which can be `Greater`, `Less`, or `Equal`
- `is_active`: `true` if the constraint is used in the formulation, `false` otherwise
- `is_explicit`: `true` if the constraint structures the formulation, `false` otherwise
- `members`: a dictionary `Dict{VarId, Float64}` that contains the coefficients of the variables of the formulation in the new constraint (default coefficient is 0).
- `loc_art_var_abs_cost`: absolute cost of the artificial variables of the constraint
"""
function setconstr!(
form::Formulation,
Expand Down Expand Up @@ -659,4 +668,4 @@ end
# end

# return PrimalSolution(spform, spvars, spvals, cost, FEASIBLE_SOL)
# end
# end

0 comments on commit 10157d5

Please sign in to comment.