Skip to content

Removing can... functions #423

Closed
Closed
@blegat

Description

@blegat

After a long discussion with @odow and @mlubin . We plan to remove the canset, canaddconstraint, canaddvariable, canmodify, cantransform, candelete functions in favor of throwing an error during set!, addconstraint!, ...
The CachingOptimizer is using these methods in Automatic mode to see if it should change from the AttachedOptimizer state to the EmptyOptimizer state automatically because the optimizer cannot do the modification in its currently state even it supports it (so by being emptied and then having the model recopied before optimization, it could work).
Instead of using these can... functions, the CachingOptimizer will do the set!, addconstraint!, ... in a try-catch and detach the optimizer automatically if it throws an error mentioning it cannot handle the operation in its current state.
This try catch seems to have a fixed 10 ns cost in our benchmark so it shouldn't be noticeable for most usage.
The Manual mode won't do any try-catch so it can be used if someonce needs to use the CachingOptimizer but do not want this 10 ns penalty for every operation.

This would resolve #295, #218, #357 (comment)

The CopyResult will also disappear and will be replaced by the exceptions thrown by the set!, addconstraint!, ... calls

This would resolve #243

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