Skip to content

Proposal: change API for modifications #360

@odow

Description

@odow

To date, I'm not sure if anyone has dug into the modification API yet. I was about to start writing tests (#354) and had some thoughts.


In addition to some function modifications, we currently have two modifyconstraint! methods:

modifyconstraint!(m, c::ConstraintIndex{F,S}, new_set::S)
modifyconstraint!(m, c::ConstraintIndex{F,S}, new_function::F)

Considering the rest of the API, doesn't it make more sense to make these set! methods?

set!(m::ModelLike, ::ConstraintFunction, c::ConstraintIndex{F,S}, new_function::F)
set!(m::ModelLike, ::ConstraintSet, c::ConstraintIndex{F,S}, new_set::S)

Furthermore, instead of modifyconstraint! and modifyobjective!, we could have

canmodify(m, ::ConstraintFunction, c::Type{ConstraintIndex{F,S}}, change::Type{AbstractFunctionModification})
modify!(m, ::ConstraintFunction, c::ConstraintIndex{F,S}, change::AbstractFunctionModification)

canmodify(m, ::ObjectiveFunction, change::Type{AbstractFunctionModification})
modify!(m, ::ObjectiveFunction, change::AbstractFunctionModification)

Edit: we could also change the transformconstraint to

canmodify(m, ::ConstraintSet, c::Type{ConstraintIndex{F,S1}}, ::Type{S2})
c2 = modify!(m, ::ConstraintSet, c::ConstraintIndex{F,S1}, new_set::S2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions