calliope-project / calliope

A multi-scale energy systems modelling framework

Home Page:https://www.callio.pe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent backend after adding constraint that applies nowhere

jnnr opened this issue · comments

Problem description

When adding constraints (m.backend.add_constraint) that do not apply anywhere because of the where, the backend is left in an inconsistent state:

The constraint does not appear in m.backend.constraints. But when you try to add a new version of the constraint with the same name, you will be notified that the constraint already exists. That's because it remains in the pyomo list created in _add_constraint_or_expression.

This list should be deleted if the constraint (/other optimisation problem element) does not apply anywhere.

Steps to reproduce the problem

Add a constraint with a where string does not apply anywhere.

Calliope version

v0.7dev

Closed by #437