From 269df96330105b319d9dd1e77ad3a850b0fe22bc Mon Sep 17 00:00:00 2001
From: Manuel Da Pena <65864237+mdapena@users.noreply.github.com>
Date: Sat, 2 Mar 2024 17:56:21 -0400
Subject: [PATCH 1/6] Update badge colors
---
README.md | 4 ++--
docs/index.md | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index a185664..3d1302c 100644
--- a/README.md
+++ b/README.md
@@ -21,11 +21,11 @@
-
+
-
+
diff --git a/docs/index.md b/docs/index.md
index 3257aab..9924f0c 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -31,11 +31,11 @@ hide:
-
+
-
+
From 1c3abbd2debd086ee6c1d4336719f2a62418e6f3 Mon Sep 17 00:00:00 2001
From: Manuel Da Pena <65864237+mdapena@users.noreply.github.com>
Date: Sat, 2 Mar 2024 17:58:58 -0400
Subject: [PATCH 2/6] Update git-comitters config in the mkdocs.yml
---
mkdocs.yml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mkdocs.yml b/mkdocs.yml
index 4c5a35a..5146161 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -63,6 +63,10 @@ plugins:
- git-committers:
repository: dapensoft/pyorlib
branch: master
+ exclude:
+ - examples/index.md
+ - api/index.md
+ - index.md
- git-revision-date-localized:
type: timeago
enable_creation_date: true
@@ -126,7 +130,7 @@ extra_javascript:
nav:
- PyORlib: index.md
- Getting Started: getting-started.md
- - Examples:
+ - Examples:
- examples/index.md
- A Transportation Model: examples/a-transportation-problem.md
- API Reference:
From a871cb760fba6e7adae79f6bda8ad3f1ce1a1088 Mon Sep 17 00:00:00 2001
From: Manuel Da Pena <65864237+mdapena@users.noreply.github.com>
Date: Sat, 2 Mar 2024 18:27:43 -0400
Subject: [PATCH 3/6] Refactor get_pretty_string method in Term class for
subclass customization
---
.../algebra/terms/constants/constant.py | 14 +++++++++++++
src/pyorlib/algebra/terms/term.py | 20 +++----------------
.../algebra/terms/variables/variable.py | 18 +++++++++++++++++
tests/algebra/terms/test_term.py | 2 +-
4 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/src/pyorlib/algebra/terms/constants/constant.py b/src/pyorlib/algebra/terms/constants/constant.py
index 2478748..c2ece54 100644
--- a/src/pyorlib/algebra/terms/constants/constant.py
+++ b/src/pyorlib/algebra/terms/constants/constant.py
@@ -2,6 +2,7 @@
from typing import Any
from ..term import Term
+from ....core.constants import StdOutColors
from ....enums import ValueType, TermType
from ....exceptions import TermException
from ....validators import ValueTypeValidator
@@ -66,3 +67,16 @@ def __init__(self, name: str, value_type: ValueType, value: float):
self._value: float = value
""" The internal value of the constant. """
+
+ def get_pretty_string(self, float_precision: int = 6) -> str: # pragma: no cover
+ default, debug = StdOutColors.DEFAULT, StdOutColors.PURPLE
+ return "".join(
+ [
+ f"Name: {debug}{self.name}{default} | ",
+ f"Type: {debug}{self.term_type.name.capitalize()}{default} | ",
+ f"Value type: {debug}{self.value_type.name.capitalize()}{default} | ",
+ f"val:{debug} ",
+ "{0:.{prec}g} ".format(self.value, prec=float_precision),
+ f"{default}",
+ ]
+ )
diff --git a/src/pyorlib/algebra/terms/term.py b/src/pyorlib/algebra/terms/term.py
index a9f59a7..d7776c6 100644
--- a/src/pyorlib/algebra/terms/term.py
+++ b/src/pyorlib/algebra/terms/term.py
@@ -4,7 +4,6 @@
from ..element import Element
from ..expressions import Expression
-from ...core.constants import StdOutColors
from ...enums import TermType, ValueType
from ...exceptions import TermException
@@ -121,27 +120,14 @@ def __init__(self, term_type: TermType, value_type: ValueType):
def _build_expression(self, expression: Any) -> Element:
return Expression(expression=expression)
- def get_pretty_string(self, float_precision: int = 6) -> str: # pragma: no cover
+ @abstractmethod
+ def get_pretty_string(self, float_precision: int = 6) -> str:
"""
Returns a formatted string representation of the term.
:param float_precision: It represents the number of digits used in printing the solution and objective.
:return: A formatted string representing the term.
"""
- default, debug = StdOutColors.DEFAULT, StdOutColors.PURPLE
- return "".join(
- [
- f"Name: {debug}{self.name}{default} | ",
- f"Type: {debug}{self.term_type.name.capitalize()}{default} | ",
- f"Value type: {debug}{self.value_type.name.capitalize()}{default} | ",
- f"lb:{debug} ",
- "{0:.{prec}g} ".format(self.lower_bound, prec=float_precision),
- f"{default}| ub:{debug} ",
- "{0:.{prec}g} ".format(self.upper_bound, prec=float_precision),
- f"{default}| val:{debug} ",
- "{0:.{prec}g} ".format(self.value, prec=float_precision),
- f"{default}",
- ]
- )
+ pass
def __str__(self) -> str: # pragma: no cover
return "".join(
diff --git a/src/pyorlib/algebra/terms/variables/variable.py b/src/pyorlib/algebra/terms/variables/variable.py
index b22815e..e9717ed 100644
--- a/src/pyorlib/algebra/terms/variables/variable.py
+++ b/src/pyorlib/algebra/terms/variables/variable.py
@@ -2,6 +2,7 @@
from math import inf
from ..term import Term
+from ....core.constants import StdOutColors
from ....enums import ValueType, TermType
from ....exceptions import TermException
@@ -44,3 +45,20 @@ def __init__(self, name: str, value_type: ValueType, lower_bound: float = 0, upp
raise TermException("Invalid lower bound for an integer variable term.")
if value_type == ValueType.INTEGER and not upper_bound == inf and not float(upper_bound).is_integer():
raise TermException("Invalid upper bound for an integer variable term.")
+
+ def get_pretty_string(self, float_precision: int = 6) -> str: # pragma: no cover
+ default, debug = StdOutColors.DEFAULT, StdOutColors.PURPLE
+ return "".join(
+ [
+ f"Name: {debug}{self.name}{default} | ",
+ f"Type: {debug}{self.term_type.name.capitalize()}{default} | ",
+ f"Value type: {debug}{self.value_type.name.capitalize()}{default} | ",
+ f"lb:{debug} ",
+ "{0:.{prec}g} ".format(self.lower_bound, prec=float_precision),
+ f"{default}| ub:{debug} ",
+ "{0:.{prec}g} ".format(self.upper_bound, prec=float_precision),
+ f"{default}| val:{debug} ",
+ "{0:.{prec}g} ".format(self.value, prec=float_precision),
+ f"{default}",
+ ]
+ )
diff --git a/tests/algebra/terms/test_term.py b/tests/algebra/terms/test_term.py
index 045b42e..1c95fce 100644
--- a/tests/algebra/terms/test_term.py
+++ b/tests/algebra/terms/test_term.py
@@ -36,7 +36,7 @@ def value(self) -> float:
def raw(self) -> Any:
pass
- def validate(self) -> None:
+ def get_pretty_string(self, float_precision: int = 6) -> str:
pass
def __init__(self):
From 84ff32e3d790f10a794b42c477d4486318109ef7 Mon Sep 17 00:00:00 2001
From: Manuel Da Pena <65864237+mdapena@users.noreply.github.com>
Date: Sat, 2 Mar 2024 19:09:51 -0400
Subject: [PATCH 4/6] Enhance model's print info and solution method
---
.../algebra/terms/constants/constant.py | 2 +-
.../algebra/terms/variables/variable.py | 8 ++---
src/pyorlib/model/model.py | 34 ++++++++++---------
3 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/pyorlib/algebra/terms/constants/constant.py b/src/pyorlib/algebra/terms/constants/constant.py
index c2ece54..97a1f63 100644
--- a/src/pyorlib/algebra/terms/constants/constant.py
+++ b/src/pyorlib/algebra/terms/constants/constant.py
@@ -75,7 +75,7 @@ def get_pretty_string(self, float_precision: int = 6) -> str: # pragma: no cove
f"Name: {debug}{self.name}{default} | ",
f"Type: {debug}{self.term_type.name.capitalize()}{default} | ",
f"Value type: {debug}{self.value_type.name.capitalize()}{default} | ",
- f"val:{debug} ",
+ f"Val:{debug} ",
"{0:.{prec}g} ".format(self.value, prec=float_precision),
f"{default}",
]
diff --git a/src/pyorlib/algebra/terms/variables/variable.py b/src/pyorlib/algebra/terms/variables/variable.py
index e9717ed..e826792 100644
--- a/src/pyorlib/algebra/terms/variables/variable.py
+++ b/src/pyorlib/algebra/terms/variables/variable.py
@@ -53,12 +53,12 @@ def get_pretty_string(self, float_precision: int = 6) -> str: # pragma: no cove
f"Name: {debug}{self.name}{default} | ",
f"Type: {debug}{self.term_type.name.capitalize()}{default} | ",
f"Value type: {debug}{self.value_type.name.capitalize()}{default} | ",
- f"lb:{debug} ",
+ f"Lb:{debug} ",
"{0:.{prec}g} ".format(self.lower_bound, prec=float_precision),
- f"{default}| ub:{debug} ",
+ f"{default}| Ub:{debug} ",
"{0:.{prec}g} ".format(self.upper_bound, prec=float_precision),
- f"{default}| val:{debug} ",
+ f"{default}| Val:{debug} ",
"{0:.{prec}g} ".format(self.value, prec=float_precision),
- f"{default}",
+ f"{'(N/A) ' if self.value == -0.0 else ''}{default}",
]
)
diff --git a/src/pyorlib/model/model.py b/src/pyorlib/model/model.py
index 4d00cb7..05acfcd 100644
--- a/src/pyorlib/model/model.py
+++ b/src/pyorlib/model/model.py
@@ -445,49 +445,50 @@ def print_info(self, display_term_sets: bool = False) -> None: # pragma: no cov
:param display_term_sets: Whether to display information about term sets. Defaults to False.
:return: None.
"""
+ default, debug = StdOutColors.DEFAULT, StdOutColors.PURPLE
print(f"\n------ MODEL INFORMATION ------\n")
print("Model properties:")
- print(f"\tName: {StdOutColors.PURPLE}{self.name}{StdOutColors.DEFAULT}")
+ print(f"\tName: {debug}{self.name}{default}")
print("Objective function:")
print(f"\tExpression: {self.objective_expr}")
- print(f"\tStatus: {StdOutColors.PURPLE}{self.solution_status.name}{StdOutColors.DEFAULT}")
+ print(f"\tStatus: {debug}{self.solution_status.name}{default}")
print(
- f"\tValue: {StdOutColors.PURPLE}",
+ f"\tValue: {debug}",
(
"{0:.{prec}g}".format(self.objective_value, prec=self.float_precision)
if self.objective_value is not None
else "--"
),
- f"{StdOutColors.DEFAULT}",
+ f"{default}",
)
- print("Dimensions:")
+ print(f"Dimensions: {debug}{len(self.dimensions)}{default}")
for name, size in self.dimensions.items():
print(
- f"\tName: {StdOutColors.PURPLE}{name}{StdOutColors.DEFAULT} | ",
- f"Val: {StdOutColors.PURPLE}{size}{StdOutColors.DEFAULT}",
+ f"\tName: {debug}{name}{default} | ",
+ f"Val: {debug}{size}{default}",
)
- print("Terms:")
+ print(f"Terms: {debug}{len(self.terms)}{default}")
for name, term in self.terms.items():
print(f"\t{term.get_pretty_string(float_precision=self.float_precision)}")
if display_term_sets:
- print("Terms Sets:")
+ print(f"Terms Sets: {debug}{len(self.term_sets)}{default}")
for name, terms in self.term_sets.items():
- print(f"\tTerm: {StdOutColors.PURPLE}{name}{StdOutColors.DEFAULT}")
+ print(f"\tTerm: {debug}{name}{default}")
for index, term in terms.items():
print(
- f"\t\tIndex: {StdOutColors.PURPLE}{index}{StdOutColors.DEFAULT} | ",
+ f"\t\tIndex: {debug}{index}{default} | ",
f"{term.get_pretty_string(float_precision=self.float_precision)}",
)
- print("Constraints:")
constraints = self.constraints
+ print(f"Constraints: {debug}{len(constraints)}{default}")
for exp in constraints:
try:
print(f"\tExpression: {exp}")
except RecursionError:
- print("\tExpression: Unprintable expression")
+ print("\tExpression: Print Error")
print()
def print_solution(self) -> None: # pragma: no cover
@@ -495,17 +496,18 @@ def print_solution(self) -> None: # pragma: no cover
Prints the solution of the optimization problem.
:return: None.
"""
+ default, debug = StdOutColors.DEFAULT, StdOutColors.PURPLE
print(f"\n------ MODEL SOLUTION ------\n")
print("Objective function:")
- print(f"\tStatus: {StdOutColors.PURPLE}{self.solution_status.name}{StdOutColors.DEFAULT}")
+ print(f"\tStatus: {debug}{self.solution_status.name}{default}")
print(
- f"\tValue: {StdOutColors.PURPLE}",
+ f"\tValue: {debug}",
(
"{0:.{prec}g}".format(self.objective_value, prec=self.float_precision)
if self.objective_value is not None
else "--"
),
- f"{StdOutColors.DEFAULT}",
+ f"{default}",
)
solution_variables: Dict[str, Term] = {
From 4eefe4d0f6cafdecf3895b4ce4316d9ebf006e7c Mon Sep 17 00:00:00 2001
From: Manuel Da Pena <65864237+mdapena@users.noreply.github.com>
Date: Sat, 2 Mar 2024 19:34:50 -0400
Subject: [PATCH 5/6] Release version 0.1.1
---
docs/release-notes.md | 17 +++++++++++++++++
src/pyorlib/__init__.py | 2 +-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/docs/release-notes.md b/docs/release-notes.md
index f2ae557..ca6a900 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -12,6 +12,23 @@ hide:
[//]: # (--------------------------------------------------------------------------------------------------------------)
+## [v0.1.1](https://github.com/dapensoft/pyorlib/releases/tag/0.1.1) March 2, 2024 { id="0.1.1" }
+
+
+
+##### Changed
+
+- The `print_info` and `print_solution` methods in the `Model` class have been enhanced to improve visibility and
+ provide deeper insights.
+- The `get_pretty_string` method in the `Term` class has been refactored as an `@abstractmethod` for subclass
+ customization and delegation based on specific term needs.
+- Badges on the main page of the documentation and the readme file have been updated to improve visibility and align
+ with the package's color palette.
+- The `git-committers` plugin in the `mkdocs.yml` file has been updated to exclude the `index.md`, `examples/index.md`,
+ and `api/index.md` files for consistency in the current configuration with the `git-revision-date-localized` plugin.
+
+[//]: # (--------------------------------------------------------------------------------------------------------------)
+
## [v0.1.0](https://github.com/dapensoft/pyorlib/releases/tag/0.1.0) March 2, 2024 { id="0.1.0" }
diff --git a/src/pyorlib/__init__.py b/src/pyorlib/__init__.py
index ce58a19..7a24112 100644
--- a/src/pyorlib/__init__.py
+++ b/src/pyorlib/__init__.py
@@ -3,7 +3,7 @@
mathematical models in a standardized manner across different optimization packages.
"""
-__version__ = "0.1.0"
+__version__ = "0.1.1"
from .engines import Engine
from .model import Model
From b8b03ecd6c6844c2d7d6877082e118df7a9eb4e1 Mon Sep 17 00:00:00 2001
From: Manuel Da Pena <65864237+mdapena@users.noreply.github.com>
Date: Sat, 2 Mar 2024 19:44:46 -0400
Subject: [PATCH 6/6] Update release-notes.md
---
docs/release-notes.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/release-notes.md b/docs/release-notes.md
index ca6a900..1f4f4da 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -21,7 +21,7 @@ hide:
- The `print_info` and `print_solution` methods in the `Model` class have been enhanced to improve visibility and
provide deeper insights.
- The `get_pretty_string` method in the `Term` class has been refactored as an `@abstractmethod` for subclass
- customization and delegation based on specific term needs.
+ customization.
- Badges on the main page of the documentation and the readme file have been updated to improve visibility and align
with the package's color palette.
- The `git-committers` plugin in the `mkdocs.yml` file has been updated to exclude the `index.md`, `examples/index.md`,