Skip to content

Inconsistent indexing for initial variable bounds #192

@emunsing

Description

@emunsing

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions