Skip to content

Constraints do not match RHS based on coordinates #586

@thomgeo

Description

@thomgeo

Version Checks (indicate both or one)

  • I have confirmed this bug exists on the lastest release of Linopy.

  • I have confirmed this bug exists on the current master branch of Linopy.

Issue Description

When constants are supplied to a linopy model, the model appears to introduce these only based on order, not match them based on the relevant coordinates.

Reproducible Example

import linopy

m = linopy.Model()

idx = ["A1", "A5", "A11", "A100"]

x = m.add_variables(coords=[idx], name="x")

idx2 = ["A100", "A1", "A5", "A11"]

coef = pd.Series({i: int(i[1:]) for i in idx2})
m.add_constraints(x >= coef)

Expected Behavior

linopy should build the constraint so that the variables are matched with the constant of the same index.

[A1]: +1 x[A1]     ≥ 100.0

[A5]: +1 x[A5]     ≥ 1.0

[A11]: +1 x[A11]   ≥ 11.0

[A100]: +1 x[A100] ≥ 5.0

Instead, it returns a constraint of the form:

[A1]: +1 x[A1]     ≥ 1.0

[A5]: +1 x[A5]     ≥ 5.0

[A11]: +1 x[A11]   ≥ 11.0

[A100]: +1 x[A100] ≥ 100.0

Installed Versions

Details 0.5.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions