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.
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
totoInd==len(var)-1
, while for a subsequent variable where the indexing goes fromfromInd=j
totoind==j + len(var)
Example:
Even more succinctly, this behavior is immediately visible on initializing the initial variable:
I would expect there to be three entries for the bounds on x.