diff --git a/src/energia/components/operations/operation.py b/src/energia/components/operations/operation.py index 46c3b5b6..b73d55a5 100644 --- a/src/energia/components/operations/operation.py +++ b/src/energia/components/operations/operation.py @@ -147,7 +147,7 @@ def _check_capacity_bound(self, space: Location | Linkage): if space not in self.capacity_aspect.bound_spaces[self]["ub"]: # check if operational capacity has been bound # this is not a check, this generates a constraint - _ = self.capacity_sample(space, self.horizon) == True + _ = self.capacity_sample(space, self.horizon) >= 0 return self, space, self.horizon diff --git a/src/energia/components/operations/storage.py b/src/energia/components/operations/storage.py index ec8cc629..b21c71a5 100644 --- a/src/energia/components/operations/storage.py +++ b/src/energia/components/operations/storage.py @@ -193,7 +193,7 @@ def _check_capacity_bound(self, space: Location) -> bool: if space not in self.capacity_aspect.bound_spaces[self.stored]["ub"]: # check if the storage capacity has been bound at that location # Note: this is not a check, this generates a constraint - _ = self.capacity(space, self.horizon) == True + _ = self.capacity(space, self.horizon) >= 0 return self, space, self.horizon @@ -203,7 +203,7 @@ def _init_inventory_aspect(self): """Initializes the inventory aspect bound spaces for the stored resource""" if self.stored not in self.inventory_aspect.bound_spaces: - _ = self.inventory_aspect(self.stored) == True + _ = self.inventory_aspect(self.stored) >= 0 def _get_times(self, space: Location) -> list[Periods]: """Gets times where inventory is defined""" diff --git a/src/energia/library/examples/energy.py b/src/energia/library/examples/energy.py index 2352f138..9b8b6dd4 100644 --- a/src/energia/library/examples/energy.py +++ b/src/energia/library/examples/energy.py @@ -265,8 +265,8 @@ def design_scheduling_material_modes(): ) m.declare(Resource, ["power", "wind", "solar"]) - _ = m.solar.consume == True - _ = m.wind.consume == True + _ = m.solar.consume >= 0 + _ = m.wind.consume >= 0 _ = m.power.release.prep(180) >= [0.6, 0.7, 0.8, 0.3] _ = m.gwp.emit(m.lir.consume) == 9600 diff --git a/src/energia/modeling/constraints/balance.py b/src/energia/modeling/constraints/balance.py index eec3fdfc..3949964b 100644 --- a/src/energia/modeling/constraints/balance.py +++ b/src/energia/modeling/constraints/balance.py @@ -228,7 +228,7 @@ def _init_sample(self): lower_times = [t for t in _balances if t > self.time] if _balances else False if lower_times: - _ = self.aspect(self.commodity, self.space, lower_times[0]) == True + _ = self.aspect(self.commodity, self.space, lower_times[0]) >= 0 def __eq__(self, other: Self): return is_(self.aspect, other.aspect) and self.domain == other.domain diff --git a/src/energia/modeling/constraints/bind.py b/src/energia/modeling/constraints/bind.py index 652650db..4dd278bf 100644 --- a/src/energia/modeling/constraints/bind.py +++ b/src/energia/modeling/constraints/bind.py @@ -5,6 +5,7 @@ import logging from functools import cached_property from typing import TYPE_CHECKING + from gana import V from gana.sets.function import F diff --git a/src/energia/modeling/indices/sample.py b/src/energia/modeling/indices/sample.py index 3ab3b415..11911b53 100644 --- a/src/energia/modeling/indices/sample.py +++ b/src/energia/modeling/indices/sample.py @@ -481,7 +481,7 @@ def Vlag(self): return getattr(self.program, self.aspect.name)(*self.domain.I) except AttributeError: - _ = self == True + _ = self >= 0 return getattr(self.program, self.aspect.name)(*self.domain.I) except KeyError: @@ -659,7 +659,15 @@ def __le__(self, other): Bind(sample=self, parameter=other, leq=True, forall=self._forall) def __ge__(self, other): - Bind(sample=self, parameter=other, geq=True, forall=self._forall) + + if self.aspect.nn and isinstance(other, (int, float)) and other == 0: + # if a zero lower bound is given + # just declare the variable + # it will be non-negative by default + # and will begin a commodity balance + self.V() + else: + Bind(sample=self, parameter=other, geq=True, forall=self._forall) def __eq__(self, other): @@ -678,7 +686,7 @@ def __eq__(self, other): else: if callable(self.of): - _ = self.of(*self.domain.index_primary[1:]) == True + _ = self.of(*self.domain.index_primary[1:]) >= 0 Bind(sample=self, parameter=other, eq=True, forall=self._forall) def __gt__(self, other):