coin-or / coin-or/CyLP

Inconsistent indexing for initial variable bounds

Open
#192 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JetBrains MPS
Stars
192
Forks
70
PR merge metrics
No merged PRs in 30d

Description

It appears that the `s.variables[i].toInd` value is computed differently for the first variable created (i==0) than it is treated for variable created later.

The indexing for the i=0 variable goes from `fromInd==0` to `toInd==len(var)-1`, while for a subsequent variable where the indexing goes from `fromInd=j` to `toind==j + len(var)`

Example:

```
import numpy as np
from cylp.cy import CyClpSimplex

s = CyClpSimplex()
x = s.addVariable('x', 3)
y = s.addVariable('y', 2)
s += 1 <= x <= 2
s += 3 <= y <= 4

print(s.variablesLower[s.variables[0].fromInd: s.variables[0].toInd])
print(s.variablesLower[s.variables[1].fromInd: s.variables[1].toInd])

[Out:]
[1. 1.]
[3. 3.]
```

Even more succinctly, this behavior is immediately visible on initializing the initial variable:
```
s = CyClpSimplex()
x = s.addVariable('x', 3)
print(s.variablesLower[s.variables[0].fromInd: s.variables[0].toInd])
```

I would expect there to be three entries for the bounds on x.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.