Solve fails on problem with only 1 variable
- Dominant language
- JetBrains MPS
- Stars
- 192
- Forks
- 70
- PR merge metrics
- No merged PRs in 30d
Description
The following code runs correctly for `count = 2`, but fails with `count = 1`.
```
#!/usr/bin/env python
from cylp.cy import CyClpSimplex
from cylp.py.modeling.CyLPModel import CyLPArray
count = 2
s = CyClpSimplex()
x = s.addVariable('x', count)
s += 0.0 <= x <= 10.0
s.objective = CyLPArray([20]*count) * x
s.optimizationDirection = 'max'
status = s.primal()
result = s.primalVariableSolution['x']
print(status)
print(result)
```
The error raised:
```
meh.py:9: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
x = s.addVariable('x', count)
meh.py:12: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
s += 0.0 <= x <= 10.0
Traceback (most recent call last):
File "meh.py", line 14, in
s.objective = CyLPArray([20]*count) * x
File "CyClpSimplex.pyx", line 141, in cylp.cy.CyClpSimplex.CyClpSimplex.objective.__set__ (cylp/cy/CyClpSimplex.cpp:4559)
File "CyClpSimplex.pyx", line 1192, in cylp.cy.CyClpSimplex.CyClpSimplex.setObjectiveArray (cylp/cy/CyClpSimplex.cpp:17461)
ValueError: Buffer has wrong number of dimensions (expected 1, got 0)
```
This can be worked around by adding another variable, which can be completely unconstrained and not included in the objective function definition. However, this shouldn't be required.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.