Skip to content

Commit

Permalink
Bumped version to 0.1.1.
Browse files Browse the repository at this point in the history
Component limits now can be None to specify no limit.
  • Loading branch information
MtCelesteMa committed May 26, 2024
1 parent 36b1088 commit 42d23bb
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ pip install reiuji-nuclearcraft
## Usage

Reiuji has a command line interface that can be found [here](https://github.com/MtCelesteMa/reiuji-cli).

There is also a web app in the works.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "reiuji_nuclearcraft"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"pydantic",
"ortools",
Expand Down Expand Up @@ -33,4 +33,5 @@ namespaces = false

[project.urls]
Homepage = "https://github.com/MtCelesteMa/reiuji"
Repository = "https://github.com/MtCelesteMa/reiuji"
"Bug Tracker" = "https://github.com/MtCelesteMa/reiuji/issues"
12 changes: 8 additions & 4 deletions src/reiuji/designer/base/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ def to_model(

class QuantityConstraint(Constraint):
"""Limits the number of a specific component type in the sequence."""
def __init__(self, component_full_name: str, max_quantity: int, min_quantity: int = 0) -> None:
def __init__(self, component_full_name: str, max_quantity: int | None = None, min_quantity: int | None = None) -> None:
self.component_full_name = component_full_name
self.max_quantity = max_quantity
self.min_quantity = min_quantity
self.min_quantity = min_quantity if isinstance(min_quantity, int) else 0

def is_satisfied(self, seq: core.multi_sequence.MultiSequence[Component]) -> bool:
return sum([1 for component in seq if component.full_name == self.component_full_name]) <= self.max_quantity
count = sum([1 for component in seq if component.full_name == self.component_full_name])
if count < self.min_quantity or (isinstance(self.max_quantity, int) and count > self.max_quantity):
return False
return True

def to_model(
self,
Expand All @@ -159,4 +162,5 @@ def to_model(
model.Add(component == component_id).OnlyEnforceIf(is_equal[i])
model.Add(component != component_id).OnlyEnforceIf(is_equal[i].Not())
model.Add(sum(is_equal) >= self.min_quantity)
model.Add(sum(is_equal) <= self.max_quantity)
if isinstance(self.max_quantity, int):
model.Add(sum(is_equal) <= self.max_quantity)
2 changes: 1 addition & 1 deletion src/reiuji/designer/overhauled/turbine_dynamo/designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(
x_symmetry: bool = False,
y_symmetry: bool = False,
components: list[Component] | None = None,
component_limits: dict[str, tuple[int, int]] | None = None
component_limits: dict[str, tuple[int | None, int | None]] | None = None
) -> None:
super().__init__(components=components if not isinstance(components, type(None)) else OVERHAULED_TURBINE_DYNAMO_COMPONENTS)
self.side_length = side_length
Expand Down
2 changes: 1 addition & 1 deletion src/reiuji/designer/overhauled/turbine_rotor/designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(
optimal_expansion: float,
*,
components: list[Component] | None = None,
component_limits: dict[str, tuple[int, int]] | None = None
component_limits: dict[str, tuple[int | None, int | None]] | None = None
) -> None:
super().__init__(components=components if not isinstance(components, type(None)) else OVERHAULED_TURBINE_ROTOR_COMPONENTS)
self.length = length
Expand Down
2 changes: 1 addition & 1 deletion src/reiuji/designer/qmd/decelerator/designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(
heat_neutral: bool = True,
internal_symmetry: bool = False,
components: list[Component] | None = None,
component_limits: dict[str, tuple[int, int]] | None = None
component_limits: dict[str, tuple[int | None, int | None]] | None = None
) -> None:
super().__init__(components=components if not isinstance(components, type(None)) else QMD_ACCELERATOR_COMPONENTS)
self.side_length = side_length
Expand Down
2 changes: 1 addition & 1 deletion src/reiuji/designer/qmd/linear/designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(
y_symmetry: bool = False,
z_symmetry: bool = False,
components: list[Component] | None = None,
component_limits: dict[str, tuple[int, int]] | None = None
component_limits: dict[str, tuple[int | None, int | None]] | None = None
) -> None:
super().__init__(components=components if not isinstance(components, type(None)) else QMD_LINEAR_ACCELERATOR_COMPONENTS)
self.length = length
Expand Down
2 changes: 1 addition & 1 deletion src/reiuji/designer/qmd/nucleosynthesis/designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(
x_symmetry: bool = False,
z_symmetry: bool = False,
components: list[Component] | None = None,
component_limits: dict[str, tuple[int, int]] | None = None
component_limits: dict[str, tuple[int | None, int | None]] | None = None
) -> None:
super().__init__(components=components if not isinstance(components, type(None)) else QMD_NUCLEOSYNTHESIS_COMPONENTS)
self.recipe_heat = recipe_heat
Expand Down
2 changes: 1 addition & 1 deletion src/reiuji/designer/qmd/synchrotron/designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(
heat_neutral: bool = True,
internal_symmetry: bool = False,
components: list[Component] | None = None,
component_limits: dict[str, tuple[int, int]] | None = None
component_limits: dict[str, tuple[int | None, int | None]] | None = None
) -> None:
super().__init__(components=components if not isinstance(components, type(None)) else QMD_ACCELERATOR_COMPONENTS)
self.side_length = side_length
Expand Down

0 comments on commit 42d23bb

Please sign in to comment.