Skip to content
Merged

Eq #320

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/energia/components/operations/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/energia/components/operations/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"""
Expand Down
4 changes: 2 additions & 2 deletions src/energia/library/examples/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/energia/modeling/constraints/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/energia/modeling/constraints/bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 11 additions & 3 deletions src/energia/modeling/indices/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
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:
Expand Down Expand Up @@ -659,7 +659,15 @@
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):

Expand All @@ -678,7 +686,7 @@

else:
if callable(self.of):
_ = self.of(*self.domain.index_primary[1:]) == True
_ = self.of(*self.domain.index_primary[1:]) >= 0

Check failure on line 689 in src/energia/modeling/indices/sample.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/energia/modeling/indices/sample.py#L689

self.of is not callable
Bind(sample=self, parameter=other, eq=True, forall=self._forall)

def __gt__(self, other):
Expand Down