Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

Model: canget objective function of the wrong type #97

Closed
tkoolen opened this issue Feb 13, 2018 · 4 comments
Closed

Model: canget objective function of the wrong type #97

tkoolen opened this issue Feb 13, 2018 · 4 comments

Comments

@tkoolen
Copy link

tkoolen commented Feb 13, 2018

Because of

https://github.com/JuliaOpt/MathOptInterfaceUtilities.jl/blob/532ebec78b8b8e35dbf7e7443ddcdb663ff279cf/src/model.jl#L225-L231

and
https://github.com/JuliaOpt/MathOptInterfaceUtilities.jl/blob/532ebec78b8b8e35dbf7e7443ddcdb663ff279cf/src/model.jl#L171

you can set a quadratic objective, ask if you can get a SingleVariable objective (why yes you can!) and then when you call get with ObjectiveFunction{SingleVariable} you receive a ScalarQuadraticFunction.

By the way, I was expecting this to be implemented with three different fields, not just one field with Union type; I guess this is a temporary solution?

@mlubin
Copy link
Member

mlubin commented Feb 13, 2018

This is a bug, holdover from before ObjectiveFunction had a type parameter.

tkoolen added a commit to tkoolen/OSQP.jl that referenced this issue Feb 13, 2018
Also work around
JuliaOpt/MathOptInterfaceBridges.jl#97.

Relevant contquadratic tests now pass!
tkoolen added a commit to tkoolen/OSQP.jl that referenced this issue Feb 13, 2018
Also work around
JuliaOpt/MathOptInterfaceBridges.jl#97.

Relevant contquadratic tests now pass!
@blegat
Copy link
Member

blegat commented Feb 13, 2018

By the way, I was expecting this to be implemented with three different fields, not just one field with Union type; I guess this is a temporary solution?

Why using three different fields ? There should be only one objective function.

@tkoolen
Copy link
Author

tkoolen commented Feb 13, 2018

Just like there are separate fields for e.g. SingleVariable and ScalarAffineFunction constraints. Sure, there can be multiple of those and only one objective function, but you're losing type stability with the Union type, which makes me ask why the ObjectiveFunction attribute should be parameterized at all. But come to think of it, I guess a better approach would probably be to use use return type annotations in the get functions to regain type stability. However, that's currently not the case.

@blegat
Copy link
Member

blegat commented Feb 13, 2018

If several fields are used, we need to check each time which of them is not nothing, I am not sure that would be faster. Since there is only one objective, performance is less critical than for constraints where a small performance loss at each function can become significant with thousands of constraints.

I guess a better approach would probably be to use use return type annotations in the get functions to regain type stability. However, that's currently not the case.

That's a good idea

tkoolen added a commit to tkoolen/OSQP.jl that referenced this issue Feb 16, 2018
Also work around
JuliaOpt/MathOptInterfaceBridges.jl#97.

Relevant contquadratic tests now pass!
tkoolen added a commit to tkoolen/OSQP.jl that referenced this issue Feb 16, 2018
Also work around
JuliaOpt/MathOptInterfaceBridges.jl#97.

Relevant contquadratic tests now pass!
tkoolen added a commit to tkoolen/OSQP.jl that referenced this issue Feb 16, 2018
Also work around
JuliaOpt/MathOptInterfaceBridges.jl#97.

Relevant contquadratic tests now pass!
tkoolen added a commit to tkoolen/OSQP.jl that referenced this issue Apr 27, 2018
Also work around
JuliaOpt/MathOptInterfaceBridges.jl#97.

Relevant contquadratic tests now pass!
tkoolen added a commit to tkoolen/OSQP.jl that referenced this issue Apr 27, 2018
Also work around
JuliaOpt/MathOptInterfaceBridges.jl#97.

Relevant contquadratic tests now pass!
tkoolen added a commit to tkoolen/OSQP.jl that referenced this issue Apr 27, 2018
* Implement MathOptInterface methods and types.

* Add test.

* Bug fixes. Now works through JuMP (with just Interval constraints)

* Support warm start in copy

* Adapt to MOI name changes.

* Address comments regarding termination status.

* Add support for LessThan, GreaterThan, and EqualTo.

* Add support for more constraints.

* Add support for settings. Bug fixes.

* Add support for MaxSense objectives.

* Hack to get constraint primals.

* Status fixes and infeasibility certificates.

* Support for constant in objective function.

Also work around
JuliaOpt/MathOptInterfaceBridges.jl#97.

Relevant contquadratic tests now pass!

* Be more careful about accessing infeasibility certificates.

* Adapt to MOI osqp#97 fix.

* Fix bug in processconstraints!

Coefficients should be summed together!

* Cleanup.

* Temporary .travis.yml changes to get code coverage.

* More cleanup.

* Add data structures for problem modification

* Function rename.

* More plumbing for problem modification.

* Test ProblemModificationCache.

* Add setindex with colon, tests.

* Support for objective modification.

* Support for objective function changes.

* Make MatrixModificationCache more efficient.

* Bug fix.

* boundschecks, cleanup.

* canget discipline, ifelse optimization

* Switch to MathOptInterface.Test.

* Random cleanup and fixes.

* Adapt to MOIU migration.

* Test unsupported objective.

* Temporary .travis.yml changes.

* Add UnsupportedConstraintError.

* Fix processobjective for SingleVariable.

* Move OSQPModel to src.

* Problem modification tests. Bug fixes.

* Deal with strange OSQP warm start functionality.

* RawSolver test, remove free! method.

* Test SolveTime.

* Disable CheckTermination; seems to make random test failures go away.

* Get rid of unused isassigned.

* Get rid of ObjectBound and RelativeGap methods.

* Test objective ScalarConstantChange, fix bug.

* Test ScalarCoefficientChange.

* Test updating settings.

* Test and fix standard attributes.

* Test and fix partial function modification

* Make defaultoptimizer deterministic.

* Switch to setting AdaptiveRhoInterval but leaving AdaptiveRho true.

* Refine warm start behavior.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants