Comments (3)
This is weird, as all the tests seem to be fine. Things like
m = linopy.Model()
lower = pd.Series(0, range(10))
x = m.add_variables(lower, name="x")
y = m.add_variables(lower, name="y")
m.add_constraints(x + y >= 10)
m.add_objective(- 2 * x + y + x * x)
m.solve(solver_name="highs")
yield the same result for highs and gurobi. and also the model definition seems totally fine when running test for pypsa networks (however it does not solve with highs). Did it explicitly say that it is trying to solve a LP in your case? and are the dual non-zero?
from linopy.
I think I understand this now.
Let's take a simple LP file with quadratic terms:
min
obj:
-4 x0 -6 x1 + [ + 4 x0 * x0 + 12 x1 * x1 ] / 2
s.t.
c0: +1 x0 +2 x1 >= +4
bounds
+0 <= x0 <= +4
+0 <= x1 <= +4
end
If we run
import highspy
h = highspy.Highs()
h.readModel("test-highs.lp")
h.run()
we get the correct solution:
Running HiGHS 1.5.3 [date: 2023-05-16, git hash: 594fa5a9d-dirty]
Copyright (c) 2023 HiGHS under MIT licence terms
<HighsStatus.kOk: 0>
0, 16.000001, 0, 0.000281, 0.000000, 0, 0.000000, 0.000000
4, -0.071428, 1, 0.000331, 0.000000, 0, 0.000000, 1.000000
Model status : Optimal
QP ASM iterations: 4
Objective value : -7.1428571429e-02
HiGHS run time : 0.00
However, if we specify "ipm" as solver:
import highspy
h = highspy.Highs()
h.readModel("test-highs.lp")
h.setOptionValue("solver", "ipm")
h.run()
we get a different result:
Running HiGHS 1.5.3 [date: 2023-05-16, git hash: 594fa5a9d-dirty]
Copyright (c) 2023 HiGHS under MIT licence terms
Presolving model
0 rows, 0 cols, 0 nonzeros
0 rows, 0 cols, 0 nonzeros
Presolve : Reductions: rows 0(-1); columns 0(-2); elements 0(-2) - Reduced to empty
Solving the original LP from the solution after postsolve
Model status : Optimal
Objective value : -4.0000000000e+01
HiGHS run time : 0.00
I always assumed that HiGHS would be using the same IPM solver for linear as for quadratic problems, but this does in fact not seem to be the case (ERGO-Code/HiGHS#766). The documentation of HiGHS also notes that implicitly:
Solver option: "simplex", "choose" or "ipm". If "simplex"/"ipm" is chosen then, for a MIP (QP) the integrality constraint (quadratic term) will be ignored
Type: string
Default: "choose"
So, no problem with linopy
.
from linopy.
Great that you cleared that up!
from linopy.
Related Issues (20)
- Wish to add model.interrupt()/terminate() to api HOT 2
- Optionally release memory during solving process
- [Feature] Support early stopping for solving such as allowing a relative optimality gap HOT 1
- Add solution values for linear expressions HOT 3
- Enable broadcasting when multiplying with pandas objects HOT 1
- How to add multi-objectives? HOT 6
- Support constant values in objective HOT 1
- Indicate applied masking in string representation of constraints HOT 3
- Change `dims` keyword of sum functions to `dim` HOT 1
- Support for sparse xarrays HOT 23
- show benchmark in readme
- Missing dimension when initializing variable with boundaries of lower dimensions HOT 2
- Improve documentation on overriding coordinates feature HOT 8
- Inconsistent coordinate override in arithmetic expressions HOT 3
- Docstring of `Model.solve()` has wrong return type
- `io_api="mps"` leads to memory overhead
- Error using scip
- Licensed CPLEX not detected HOT 3
- MPS IO changes with highspy >= 1.7
- Re-solving a changed model with "direct" api results in wrong model being solved HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linopy.