gamspy 1.19.1__tar.gz → 1.19.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. {gamspy-1.19.1/src/gamspy.egg-info → gamspy-1.19.3}/PKG-INFO +1 -1
  2. {gamspy-1.19.1 → gamspy-1.19.3}/pyproject.toml +1 -1
  3. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_backend/backend.py +1 -3
  4. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/show.py +3 -3
  5. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_container.py +11 -53
  6. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_miro.py +2 -6
  7. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_validation.py +2 -1
  8. {gamspy-1.19.1 → gamspy-1.19.3/src/gamspy.egg-info}/PKG-INFO +1 -1
  9. {gamspy-1.19.1 → gamspy-1.19.3}/tests/test_gamspy.py +5 -5
  10. {gamspy-1.19.1 → gamspy-1.19.3}/LICENSE +0 -0
  11. {gamspy-1.19.1 → gamspy-1.19.3}/README.md +0 -0
  12. {gamspy-1.19.1 → gamspy-1.19.3}/README_PYPI.md +0 -0
  13. {gamspy-1.19.1 → gamspy-1.19.3}/setup.cfg +0 -0
  14. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/__init__.py +0 -0
  15. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/__main__.py +0 -0
  16. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_algebra/__init__.py +0 -0
  17. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_algebra/condition.py +0 -0
  18. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_algebra/domain.py +0 -0
  19. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_algebra/expression.py +0 -0
  20. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_algebra/number.py +0 -0
  21. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_algebra/operable.py +0 -0
  22. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_algebra/operation.py +0 -0
  23. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_backend/__init__.py +0 -0
  24. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_backend/engine.py +0 -0
  25. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_backend/local.py +0 -0
  26. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_backend/neos.py +0 -0
  27. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/__init__.py +0 -0
  28. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/cli.py +0 -0
  29. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/gdx.py +0 -0
  30. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/install.py +0 -0
  31. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/list.py +0 -0
  32. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/mps2gms.py +0 -0
  33. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/probe.py +0 -0
  34. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/retrieve.py +0 -0
  35. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/run.py +0 -0
  36. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/uninstall.py +0 -0
  37. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_cli/util.py +0 -0
  38. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_communication.py +0 -0
  39. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_config.py +0 -0
  40. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_convert.py +0 -0
  41. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_database.py +0 -0
  42. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_extrinsic.py +0 -0
  43. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_model.py +0 -0
  44. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_model_instance.py +0 -0
  45. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_options.py +0 -0
  46. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_serialization.py +0 -0
  47. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/__init__.py +0 -0
  48. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/alias.py +0 -0
  49. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/equation.py +0 -0
  50. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/implicits/__init__.py +0 -0
  51. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/implicits/implicit_equation.py +0 -0
  52. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/implicits/implicit_parameter.py +0 -0
  53. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/implicits/implicit_set.py +0 -0
  54. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/implicits/implicit_symbol.py +0 -0
  55. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/implicits/implicit_variable.py +0 -0
  56. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/parameter.py +0 -0
  57. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/set.py +0 -0
  58. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/symbol.py +0 -0
  59. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/universe_alias.py +0 -0
  60. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_symbols/variable.py +0 -0
  61. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_types.py +0 -0
  62. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/_workspace.py +0 -0
  63. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/exceptions.py +0 -0
  64. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/__init__.py +0 -0
  65. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/ml/__init__.py +0 -0
  66. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/ml/decision_tree_struct.py +0 -0
  67. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/ml/gradient_boosting.py +0 -0
  68. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/ml/random_forest.py +0 -0
  69. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/ml/regression_tree.py +0 -0
  70. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/nn/__init__.py +0 -0
  71. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/nn/avgpool2d.py +0 -0
  72. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/nn/conv1d.py +0 -0
  73. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/nn/conv2d.py +0 -0
  74. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/nn/linear.py +0 -0
  75. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/nn/maxpool2d.py +0 -0
  76. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/nn/minpool2d.py +0 -0
  77. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/nn/mpool2d.py +0 -0
  78. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/nn/torch_sequential.py +0 -0
  79. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/piecewise.py +0 -0
  80. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/result.py +0 -0
  81. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/shape.py +0 -0
  82. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/formulations/utils.py +0 -0
  83. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/math/__init__.py +0 -0
  84. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/math/activation.py +0 -0
  85. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/math/log_power.py +0 -0
  86. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/math/matrix.py +0 -0
  87. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/math/misc.py +0 -0
  88. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/math/probability.py +0 -0
  89. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/math/trigonometric.py +0 -0
  90. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/py.typed +0 -0
  91. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/utils.py +0 -0
  92. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy/version.py +0 -0
  93. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy.egg-info/SOURCES.txt +0 -0
  94. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy.egg-info/dependency_links.txt +0 -0
  95. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy.egg-info/entry_points.txt +0 -0
  96. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy.egg-info/requires.txt +0 -0
  97. {gamspy-1.19.1 → gamspy-1.19.3}/src/gamspy.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gamspy
3
- Version: 1.19.1
3
+ Version: 1.19.3
4
4
  Summary: Python-based algebraic modeling interface to GAMS
5
5
  Author-email: GAMS Development Corporation <support@gams.com>
6
6
  Project-URL: homepage, https://gams.com/sales/gamspy_facts/
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gamspy"
7
- version = "1.19.1"
7
+ version = "1.19.3"
8
8
  authors = [
9
9
  { name = "GAMS Development Corporation", email = "support@gams.com" },
10
10
  ]
@@ -222,9 +222,7 @@ class Backend(ABC):
222
222
  symbols = filtered_names
223
223
 
224
224
  if len(symbols) != 0:
225
- self.container._load_records_from_gdx(
226
- self.container._gdx_out, symbols, create_if_not_declared=True
227
- )
225
+ self.container._load_records_from_gdx(self.container._gdx_out, symbols)
228
226
  self.make_unmodified(symbols)
229
227
 
230
228
  if relaxed_domain_mapping:
@@ -67,9 +67,9 @@ SOLVER_PAGE_MAP = {
67
67
 
68
68
  # cm: component_map, ia: is_academic
69
69
  EVALUATIONS: dict[str, Callable[[dict[str, bool], bool], bool]] = {
70
- "ANTIGONE": lambda cm, ia: cm["AT"]
71
- and (cm["CP"] or cm["CL"])
72
- and (cm["CO"] or cm["SN"]),
70
+ "ANTIGONE": lambda cm, ia: (
71
+ cm["AT"] and (cm["CP"] or cm["CL"]) and (cm["CO"] or cm["SN"])
72
+ ),
73
73
  "BARON": lambda cm, ia: cm["BA"],
74
74
  "CBC": lambda cm, ia: True,
75
75
  "CONOPT": lambda cm, ia: cm["CO"],
@@ -588,7 +588,6 @@ class Container(gt.Container):
588
588
  def _filter_load_symbols(
589
589
  self,
590
590
  symbol_names: dict[str, str] | list[str],
591
- create_if_not_declared: bool = False,
592
591
  ) -> dict[str, str] | list[str]:
593
592
  if isinstance(symbol_names, list):
594
593
  names = []
@@ -598,12 +597,7 @@ class Container(gt.Container):
598
597
  if not isinstance(symbol, gt.Alias) and symbol.synchronize:
599
598
  names.append(name)
600
599
  else:
601
- if create_if_not_declared:
602
- names.append(name)
603
- else:
604
- raise ValidationError(
605
- f"Cannot load records of `{name}` because it does not exist in the container."
606
- )
600
+ names.append(name)
607
601
 
608
602
  return names
609
603
 
@@ -619,13 +613,7 @@ class Container(gt.Container):
619
613
 
620
614
  return mapping
621
615
 
622
- def _load_records_from_gdx(
623
- self,
624
- load_from: str,
625
- names: Iterable[str],
626
- *,
627
- create_if_not_declared: bool = False,
628
- ) -> None:
616
+ def _load_records_from_gdx(self, load_from: str, names: Iterable[str]) -> None:
629
617
  self._temp_container.read(load_from, names)
630
618
  original_state = self._options.miro_protect
631
619
  self._options.miro_protect = False
@@ -636,12 +624,7 @@ class Container(gt.Container):
636
624
  self[name].records = updated_records
637
625
  self[name].domain_labels = self[name].domain_names
638
626
  else:
639
- if create_if_not_declared:
640
- self._read(load_from, [name])
641
- else:
642
- raise ValidationError(
643
- f"Cannot load records of `{name}` because it does not exist in the container."
644
- )
627
+ self._read(load_from, [name])
645
628
 
646
629
  self._options.miro_protect = original_state
647
630
  self._temp_container.data = {}
@@ -989,53 +972,28 @@ class Container(gt.Container):
989
972
  if isinstance(load_from, Path):
990
973
  load_from = str(load_from.resolve())
991
974
 
992
- create_if_not_declared = symbol_names is None
993
975
  if symbol_names is None:
994
976
  # If no symbol names are given, all records in the gdx should be loaded
995
977
  symbol_names = utils._get_symbol_names_from_gdx(
996
978
  self.system_directory, load_from
997
979
  )
998
- symbol_names = self._filter_load_symbols(
999
- symbol_names, # type: ignore
1000
- create_if_not_declared,
1001
- )
1002
- self._load_records_from_gdx(
1003
- load_from, symbol_names, create_if_not_declared=create_if_not_declared
1004
- )
980
+ self._add_statement(f"$declareAndLoad {load_from}")
981
+ symbol_names = self._filter_load_symbols(symbol_names) # type: ignore
982
+ self._load_records_from_gdx(load_from, symbol_names)
1005
983
  self._synch_with_gams()
1006
984
  return
1007
985
 
1008
- if isinstance(symbol_names, list):
1009
- symbol_names = self._filter_load_symbols(
1010
- symbol_names, create_if_not_declared
1011
- )
1012
- self._add_statement(f"$gdxIn {load_from}")
1013
- symbols_str = " ".join(symbol_names)
1014
- self._add_statement(f"$loadDC {symbols_str}")
1015
- self._add_statement("$gdxIn")
1016
- elif isinstance(symbol_names, dict):
1017
- symbol_names = self._filter_load_symbols(
1018
- symbol_names, create_if_not_declared
1019
- )
1020
- self._add_statement(f"$gdxIn {load_from}")
1021
- symbols_str = " ".join(
1022
- [f"{value}={key}" for key, value in symbol_names.items()] # type: ignore
1023
- )
1024
- self._add_statement(f"$loadDC {symbols_str}")
1025
- self._add_statement("$gdxIn")
986
+ if isinstance(symbol_names, (list, dict)):
987
+ symbol_names = self._filter_load_symbols(symbol_names)
1026
988
  else:
1027
989
  raise TypeError("`symbol_names` must be either a list or a dictionary.")
1028
990
 
1029
- self._options._debug_options["gdx"] = self._gdx_out
1030
- self._options._debug_options["gdxSymbols"] = "newOrChanged"
1031
- self._synch_with_gams()
1032
-
1033
991
  if isinstance(symbol_names, dict):
1034
992
  self._load_records_with_rename(load_from, symbol_names)
1035
993
  else:
1036
- self._load_records_from_gdx(
1037
- load_from, symbol_names, create_if_not_declared=create_if_not_declared
1038
- )
994
+ self._load_records_from_gdx(load_from, symbol_names)
995
+
996
+ self._synch_with_gams()
1039
997
 
1040
998
  def addGamsCode(self, gams_code: str) -> None:
1041
999
  """
@@ -41,9 +41,7 @@ def load_miro_symbol_records(container: Container):
41
41
  for name in container._miro_input_symbols
42
42
  if not container[name]._already_loaded
43
43
  ]
44
- container._load_records_from_gdx(
45
- MIRO_GDX_IN, names, create_if_not_declared=True
46
- )
44
+ container._load_records_from_gdx(MIRO_GDX_IN, names)
47
45
  for name in names:
48
46
  symbol = container[name]
49
47
  symbol._already_loaded = True
@@ -56,9 +54,7 @@ def load_miro_symbol_records(container: Container):
56
54
 
57
55
  # Load records of miro output symbols
58
56
  if MIRO_GDX_OUT and container._miro_output_symbols:
59
- container._load_records_from_gdx(
60
- MIRO_GDX_OUT, container._miro_output_symbols, create_if_not_declared=True
61
- )
57
+ container._load_records_from_gdx(MIRO_GDX_OUT, container._miro_output_symbols)
62
58
 
63
59
  for name in container._miro_input_symbols + container._miro_output_symbols:
64
60
  container[name].modified = False
@@ -331,7 +331,8 @@ def validate_domain(
331
331
  try:
332
332
  if (
333
333
  given != "*"
334
- and len(actual.records) < 1000
334
+ and actual.records is not None
335
+ and len(actual.records) < 100
335
336
  and not actual.records.isin([given]).sum().any()
336
337
  ):
337
338
  raise ValidationError(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gamspy
3
- Version: 1.19.1
3
+ Version: 1.19.3
4
4
  Summary: Python-based algebraic modeling interface to GAMS
5
5
  Author-email: GAMS Development Corporation <support@gams.com>
6
6
  Project-URL: homepage, https://gams.com/sales/gamspy_facts/
@@ -18,7 +18,7 @@ from gamspy.exceptions import GamspyException, ValidationError
18
18
 
19
19
  @pytest.mark.unit
20
20
  def test_version():
21
- assert gp.__version__ == "1.19.1"
21
+ assert gp.__version__ == "1.19.3"
22
22
 
23
23
 
24
24
  @pytest.mark.unit
@@ -73,20 +73,20 @@ def test_config():
73
73
  def test_domain_checking_config_performance():
74
74
  gp.set_options({"DOMAIN_VALIDATION": 1})
75
75
  m = gp.Container()
76
- i = gp.Set(m, records=range(999))
76
+ i = gp.Set(m, records=range(99))
77
77
  a = gp.Parameter(m, domain=i)
78
78
  start = time.time()
79
- for idx in range(999):
79
+ for idx in range(99):
80
80
  _ = a[idx] + a[idx] + a[idx] + a[idx] + a[idx] + a[idx] + a[idx] + a[idx]
81
81
 
82
82
  timing_with_validation = time.time() - start
83
83
 
84
84
  gp.set_options({"DOMAIN_VALIDATION": 0})
85
85
  m = gp.Container()
86
- i = gp.Set(m, records=range(999))
86
+ i = gp.Set(m, records=range(99))
87
87
  a = gp.Parameter(m, domain=i)
88
88
  start = time.time()
89
- for idx in range(999):
89
+ for idx in range(99):
90
90
  _ = a[idx] + a[idx] + a[idx] + a[idx] + a[idx] + a[idx] + a[idx] + a[idx]
91
91
  timing_without_validation = time.time() - start
92
92
  gp.set_options({"DOMAIN_VALIDATION": 1})
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes