gamsapi 52.5.0__cp312-cp312-win_amd64.whl
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.
- gams/__init__.py +27 -0
- gams/_version.py +1 -0
- gams/connect/__init__.py +28 -0
- gams/connect/agents/__init__.py +24 -0
- gams/connect/agents/_excel/__init__.py +32 -0
- gams/connect/agents/_excel/excelagent.py +312 -0
- gams/connect/agents/_excel/workbook.py +155 -0
- gams/connect/agents/_sqlconnectors/__init__.py +42 -0
- gams/connect/agents/_sqlconnectors/_accesshandler.py +211 -0
- gams/connect/agents/_sqlconnectors/_databasehandler.py +250 -0
- gams/connect/agents/_sqlconnectors/_mysqlhandler.py +168 -0
- gams/connect/agents/_sqlconnectors/_postgreshandler.py +131 -0
- gams/connect/agents/_sqlconnectors/_pyodbchandler.py +112 -0
- gams/connect/agents/_sqlconnectors/_sqlalchemyhandler.py +74 -0
- gams/connect/agents/_sqlconnectors/_sqlitehandler.py +262 -0
- gams/connect/agents/_sqlconnectors/_sqlserverhandler.py +179 -0
- gams/connect/agents/concatenate.py +440 -0
- gams/connect/agents/connectagent.py +743 -0
- gams/connect/agents/csvreader.py +675 -0
- gams/connect/agents/csvwriter.py +151 -0
- gams/connect/agents/domainwriter.py +143 -0
- gams/connect/agents/excelreader.py +756 -0
- gams/connect/agents/excelwriter.py +467 -0
- gams/connect/agents/filter.py +223 -0
- gams/connect/agents/gamsreader.py +112 -0
- gams/connect/agents/gamswriter.py +239 -0
- gams/connect/agents/gdxreader.py +109 -0
- gams/connect/agents/gdxwriter.py +146 -0
- gams/connect/agents/labelmanipulator.py +303 -0
- gams/connect/agents/projection.py +539 -0
- gams/connect/agents/pythoncode.py +71 -0
- gams/connect/agents/rawcsvreader.py +248 -0
- gams/connect/agents/rawexcelreader.py +312 -0
- gams/connect/agents/schema/CSVReader.yaml +92 -0
- gams/connect/agents/schema/CSVWriter.yaml +44 -0
- gams/connect/agents/schema/Concatenate.yaml +52 -0
- gams/connect/agents/schema/DomainWriter.yaml +25 -0
- gams/connect/agents/schema/ExcelReader.yaml +121 -0
- gams/connect/agents/schema/ExcelWriter.yaml +78 -0
- gams/connect/agents/schema/Filter.yaml +74 -0
- gams/connect/agents/schema/GAMSReader.yaml +20 -0
- gams/connect/agents/schema/GAMSWriter.yaml +47 -0
- gams/connect/agents/schema/GDXReader.yaml +23 -0
- gams/connect/agents/schema/GDXWriter.yaml +32 -0
- gams/connect/agents/schema/LabelManipulator.yaml +99 -0
- gams/connect/agents/schema/Projection.yaml +24 -0
- gams/connect/agents/schema/PythonCode.yaml +6 -0
- gams/connect/agents/schema/RawCSVReader.yaml +34 -0
- gams/connect/agents/schema/RawExcelReader.yaml +42 -0
- gams/connect/agents/schema/SQLReader.yaml +75 -0
- gams/connect/agents/schema/SQLWriter.yaml +103 -0
- gams/connect/agents/sqlreader.py +301 -0
- gams/connect/agents/sqlwriter.py +276 -0
- gams/connect/connectdatabase.py +275 -0
- gams/connect/connectvalidator.py +93 -0
- gams/connect/errors.py +34 -0
- gams/control/__init__.py +136 -0
- gams/control/database.py +2231 -0
- gams/control/execution.py +1900 -0
- gams/control/options.py +2792 -0
- gams/control/workspace.py +1198 -0
- gams/core/__init__.py +24 -0
- gams/core/cfg/__init__.py +26 -0
- gams/core/cfg/_cfgmcc.cp312-win_amd64.pyd +0 -0
- gams/core/cfg/cfgmcc.py +519 -0
- gams/core/dct/__init__.py +26 -0
- gams/core/dct/_dctmcc.cp312-win_amd64.pyd +0 -0
- gams/core/dct/dctmcc.py +574 -0
- gams/core/embedded/__init__.py +26 -0
- gams/core/embedded/gamsemb.py +1024 -0
- gams/core/emp/__init__.py +24 -0
- gams/core/emp/emplexer.py +89 -0
- gams/core/emp/empyacc.py +281 -0
- gams/core/gdx/__init__.py +26 -0
- gams/core/gdx/_gdxcc.cp312-win_amd64.pyd +0 -0
- gams/core/gdx/gdxcc.py +866 -0
- gams/core/gev/__init__.py +26 -0
- gams/core/gev/_gevmcc.cp312-win_amd64.pyd +0 -0
- gams/core/gev/gevmcc.py +855 -0
- gams/core/gmd/__init__.py +26 -0
- gams/core/gmd/_gmdcc.cp312-win_amd64.pyd +0 -0
- gams/core/gmd/gmdcc.py +917 -0
- gams/core/gmo/__init__.py +26 -0
- gams/core/gmo/_gmomcc.cp312-win_amd64.pyd +0 -0
- gams/core/gmo/gmomcc.py +2046 -0
- gams/core/idx/__init__.py +26 -0
- gams/core/idx/_idxcc.cp312-win_amd64.pyd +0 -0
- gams/core/idx/idxcc.py +510 -0
- gams/core/numpy/__init__.py +29 -0
- gams/core/numpy/_gams2numpy.cp312-win_amd64.pyd +0 -0
- gams/core/numpy/gams2numpy.py +1048 -0
- gams/core/opt/__init__.py +26 -0
- gams/core/opt/_optcc.cp312-win_amd64.pyd +0 -0
- gams/core/opt/optcc.py +840 -0
- gams/engine/__init__.py +204 -0
- gams/engine/api/__init__.py +13 -0
- gams/engine/api/auth_api.py +7653 -0
- gams/engine/api/cleanup_api.py +751 -0
- gams/engine/api/default_api.py +887 -0
- gams/engine/api/hypercube_api.py +2629 -0
- gams/engine/api/jobs_api.py +5229 -0
- gams/engine/api/licenses_api.py +2220 -0
- gams/engine/api/namespaces_api.py +7783 -0
- gams/engine/api/usage_api.py +5627 -0
- gams/engine/api/users_api.py +5931 -0
- gams/engine/api_client.py +804 -0
- gams/engine/api_response.py +21 -0
- gams/engine/configuration.py +601 -0
- gams/engine/exceptions.py +216 -0
- gams/engine/models/__init__.py +86 -0
- gams/engine/models/bad_input.py +89 -0
- gams/engine/models/cleanable_job_result.py +104 -0
- gams/engine/models/cleanable_job_result_page.py +113 -0
- gams/engine/models/engine_license.py +107 -0
- gams/engine/models/files_not_found.py +93 -0
- gams/engine/models/forwarded_token_response.py +112 -0
- gams/engine/models/generic_key_value_pair.py +89 -0
- gams/engine/models/hypercube.py +160 -0
- gams/engine/models/hypercube_page.py +111 -0
- gams/engine/models/hypercube_summary.py +91 -0
- gams/engine/models/hypercube_token.py +97 -0
- gams/engine/models/identity_provider.py +107 -0
- gams/engine/models/identity_provider_ldap.py +121 -0
- gams/engine/models/identity_provider_oauth2.py +146 -0
- gams/engine/models/identity_provider_oauth2_scope.py +89 -0
- gams/engine/models/identity_provider_oauth2_with_secret.py +152 -0
- gams/engine/models/identity_provider_oidc.py +133 -0
- gams/engine/models/identity_provider_oidc_with_secret.py +143 -0
- gams/engine/models/inex.py +91 -0
- gams/engine/models/invitation.py +136 -0
- gams/engine/models/invitation_quota.py +106 -0
- gams/engine/models/invitation_token.py +87 -0
- gams/engine/models/job.py +165 -0
- gams/engine/models/job_no_text_entry.py +138 -0
- gams/engine/models/job_no_text_entry_page.py +111 -0
- gams/engine/models/license.py +91 -0
- gams/engine/models/log_piece.py +96 -0
- gams/engine/models/message.py +87 -0
- gams/engine/models/message_and_token.py +99 -0
- gams/engine/models/message_with_webhook_id.py +89 -0
- gams/engine/models/model_auth_token.py +87 -0
- gams/engine/models/model_configuration.py +125 -0
- gams/engine/models/model_default_instance.py +99 -0
- gams/engine/models/model_default_user_instance.py +98 -0
- gams/engine/models/model_hypercube_job.py +106 -0
- gams/engine/models/model_hypercube_usage.py +130 -0
- gams/engine/models/model_instance_info.py +116 -0
- gams/engine/models/model_instance_info_full.py +123 -0
- gams/engine/models/model_instance_pool_info.py +112 -0
- gams/engine/models/model_job_labels.py +179 -0
- gams/engine/models/model_job_usage.py +133 -0
- gams/engine/models/model_pool_usage.py +124 -0
- gams/engine/models/model_usage.py +115 -0
- gams/engine/models/model_user.py +96 -0
- gams/engine/models/model_userinstance_info.py +119 -0
- gams/engine/models/model_userinstancepool_info.py +95 -0
- gams/engine/models/model_version.py +91 -0
- gams/engine/models/models.py +120 -0
- gams/engine/models/namespace.py +104 -0
- gams/engine/models/namespace_quota.py +96 -0
- gams/engine/models/namespace_with_permission.py +96 -0
- gams/engine/models/not_found.py +91 -0
- gams/engine/models/password_policy.py +97 -0
- gams/engine/models/perm_and_username.py +89 -0
- gams/engine/models/quota.py +117 -0
- gams/engine/models/quota_exceeded.py +97 -0
- gams/engine/models/status_code_meaning.py +89 -0
- gams/engine/models/stream_entry.py +89 -0
- gams/engine/models/system_wide_license.py +92 -0
- gams/engine/models/text_entries.py +87 -0
- gams/engine/models/text_entry.py +101 -0
- gams/engine/models/time_span.py +95 -0
- gams/engine/models/time_span_pool_worker.py +99 -0
- gams/engine/models/token_forward_error.py +87 -0
- gams/engine/models/user.py +127 -0
- gams/engine/models/user_group_member.py +96 -0
- gams/engine/models/user_groups.py +108 -0
- gams/engine/models/vapid_info.py +87 -0
- gams/engine/models/webhook.py +138 -0
- gams/engine/models/webhook_parameterized_event.py +99 -0
- gams/engine/py.typed +0 -0
- gams/engine/rest.py +258 -0
- gams/magic/__init__.py +32 -0
- gams/magic/gams_magic.py +142 -0
- gams/magic/interactive.py +402 -0
- gams/tools/__init__.py +30 -0
- gams/tools/errors.py +34 -0
- gams/tools/toolcollection/__init__.py +24 -0
- gams/tools/toolcollection/alg/__init__.py +24 -0
- gams/tools/toolcollection/alg/rank.py +51 -0
- gams/tools/toolcollection/data/__init__.py +24 -0
- gams/tools/toolcollection/data/csvread.py +444 -0
- gams/tools/toolcollection/data/csvwrite.py +311 -0
- gams/tools/toolcollection/data/exceldump.py +47 -0
- gams/tools/toolcollection/data/sqlitewrite.py +276 -0
- gams/tools/toolcollection/gdxservice/__init__.py +24 -0
- gams/tools/toolcollection/gdxservice/gdxencoding.py +104 -0
- gams/tools/toolcollection/gdxservice/gdxrename.py +94 -0
- gams/tools/toolcollection/linalg/__init__.py +24 -0
- gams/tools/toolcollection/linalg/cholesky.py +57 -0
- gams/tools/toolcollection/linalg/eigenvalue.py +56 -0
- gams/tools/toolcollection/linalg/eigenvector.py +58 -0
- gams/tools/toolcollection/linalg/invert.py +55 -0
- gams/tools/toolcollection/linalg/ols.py +138 -0
- gams/tools/toolcollection/tooltemplate.py +321 -0
- gams/tools/toolcollection/win32/__init__.py +24 -0
- gams/tools/toolcollection/win32/excelmerge.py +93 -0
- gams/tools/toolcollection/win32/exceltalk.py +76 -0
- gams/tools/toolcollection/win32/msappavail.py +49 -0
- gams/tools/toolcollection/win32/shellexecute.py +54 -0
- gams/tools/tools.py +116 -0
- gams/transfer/__init__.py +35 -0
- gams/transfer/_abcs/__init__.py +37 -0
- gams/transfer/_abcs/container_abcs.py +433 -0
- gams/transfer/_internals/__init__.py +63 -0
- gams/transfer/_internals/algorithms.py +436 -0
- gams/transfer/_internals/casepreservingdict.py +124 -0
- gams/transfer/_internals/constants.py +270 -0
- gams/transfer/_internals/domainviolation.py +103 -0
- gams/transfer/_internals/specialvalues.py +172 -0
- gams/transfer/containers/__init__.py +26 -0
- gams/transfer/containers/_container.py +1794 -0
- gams/transfer/containers/_io/__init__.py +28 -0
- gams/transfer/containers/_io/containers.py +164 -0
- gams/transfer/containers/_io/gdx.py +1029 -0
- gams/transfer/containers/_io/gmd.py +872 -0
- gams/transfer/containers/_mixins/__init__.py +26 -0
- gams/transfer/containers/_mixins/ccc.py +1274 -0
- gams/transfer/syms/__init__.py +33 -0
- gams/transfer/syms/_methods/__init__.py +24 -0
- gams/transfer/syms/_methods/tables.py +120 -0
- gams/transfer/syms/_methods/toDict.py +115 -0
- gams/transfer/syms/_methods/toList.py +83 -0
- gams/transfer/syms/_methods/toValue.py +60 -0
- gams/transfer/syms/_mixins/__init__.py +32 -0
- gams/transfer/syms/_mixins/equals.py +626 -0
- gams/transfer/syms/_mixins/generateRecords.py +499 -0
- gams/transfer/syms/_mixins/pivot.py +313 -0
- gams/transfer/syms/_mixins/pve.py +627 -0
- gams/transfer/syms/_mixins/sa.py +27 -0
- gams/transfer/syms/_mixins/sapve.py +27 -0
- gams/transfer/syms/_mixins/saua.py +27 -0
- gams/transfer/syms/_mixins/sauapve.py +199 -0
- gams/transfer/syms/_mixins/spve.py +1528 -0
- gams/transfer/syms/_mixins/ve.py +936 -0
- gams/transfer/syms/container_syms/__init__.py +31 -0
- gams/transfer/syms/container_syms/_alias.py +984 -0
- gams/transfer/syms/container_syms/_equation.py +333 -0
- gams/transfer/syms/container_syms/_parameter.py +973 -0
- gams/transfer/syms/container_syms/_set.py +604 -0
- gams/transfer/syms/container_syms/_universe_alias.py +461 -0
- gams/transfer/syms/container_syms/_variable.py +321 -0
- gamsapi-52.5.0.dist-info/METADATA +150 -0
- gamsapi-52.5.0.dist-info/RECORD +257 -0
- gamsapi-52.5.0.dist-info/WHEEL +5 -0
- gamsapi-52.5.0.dist-info/licenses/LICENSE +22 -0
- gamsapi-52.5.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
#
|
|
2
|
+
# GAMS - General Algebraic Modeling System Python API
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2026 GAMS Development Corp. <support@gams.com>
|
|
5
|
+
# Copyright (c) 2017-2026 GAMS Software GmbH <support@gams.com>
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
# copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
# SOFTWARE.
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
import itertools
|
|
27
|
+
from enum import Enum
|
|
28
|
+
from gams.core.gdx import GMS_UEL_IDENT_SIZE, GMS_SSSIZE, GMS_MAX_INDEX_DIM
|
|
29
|
+
from gams.core.gdx import GMS_DT_SET, GMS_DT_ALIAS, GMS_DT_PAR, GMS_DT_VAR, GMS_DT_EQU
|
|
30
|
+
from gams.core.gdx import (
|
|
31
|
+
GMS_VARTYPE_FREE,
|
|
32
|
+
GMS_VARTYPE_BINARY,
|
|
33
|
+
GMS_VARTYPE_INTEGER,
|
|
34
|
+
GMS_VARTYPE_NEGATIVE,
|
|
35
|
+
GMS_VARTYPE_POSITIVE,
|
|
36
|
+
GMS_VARTYPE_SEMICONT,
|
|
37
|
+
GMS_VARTYPE_SEMIINT,
|
|
38
|
+
GMS_VARTYPE_SOS1,
|
|
39
|
+
GMS_VARTYPE_SOS2,
|
|
40
|
+
)
|
|
41
|
+
from gams.core.gdx import (
|
|
42
|
+
GMS_EQUTYPE_B,
|
|
43
|
+
GMS_EQUTYPE_E,
|
|
44
|
+
GMS_EQUTYPE_G,
|
|
45
|
+
GMS_EQUTYPE_L,
|
|
46
|
+
GMS_EQUTYPE_N,
|
|
47
|
+
GMS_EQUTYPE_X,
|
|
48
|
+
)
|
|
49
|
+
from gams.transfer._internals import SpecialValues
|
|
50
|
+
|
|
51
|
+
GAMS_SYMBOL_MAX_LENGTH = GMS_UEL_IDENT_SIZE - 1
|
|
52
|
+
GAMS_UEL_MAX_LENGTH = GMS_UEL_IDENT_SIZE - 1
|
|
53
|
+
GAMS_DESCRIPTION_MAX_LENGTH = GMS_SSSIZE - 1
|
|
54
|
+
GAMS_MAX_INDEX_DIM = GMS_MAX_INDEX_DIM
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class DictFormat(Enum):
|
|
58
|
+
UNKNOWN = -1
|
|
59
|
+
COLUMNS = 0
|
|
60
|
+
NATURAL = 1
|
|
61
|
+
|
|
62
|
+
@classmethod
|
|
63
|
+
def _missing_(cls, value):
|
|
64
|
+
return DictFormat.UNKNOWN
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
DICT_FORMAT = {
|
|
68
|
+
"natural": DictFormat.NATURAL,
|
|
69
|
+
"columns": DictFormat.COLUMNS,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class SourceType(Enum):
|
|
74
|
+
UNKNOWN = -1
|
|
75
|
+
GDX = 0
|
|
76
|
+
GMD = 1
|
|
77
|
+
CONTAINER = 2
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def _missing_(cls, value):
|
|
81
|
+
return SourceType.UNKNOWN
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class DestinationType(Enum):
|
|
85
|
+
UNKNOWN = -1
|
|
86
|
+
GDX = 0
|
|
87
|
+
GMD = 1
|
|
88
|
+
|
|
89
|
+
@classmethod
|
|
90
|
+
def _missing_(cls, value):
|
|
91
|
+
return DestinationType.UNKNOWN
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class DomainStatus(Enum):
|
|
95
|
+
UNKNOWN = 0
|
|
96
|
+
none = 1
|
|
97
|
+
relaxed = 2
|
|
98
|
+
regular = 3
|
|
99
|
+
|
|
100
|
+
@classmethod
|
|
101
|
+
def _missing_(cls, value):
|
|
102
|
+
return DomainStatus.UNKNOWN
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
GAMS_DOMAIN_STATUS = {1: "none", 2: "relaxed", 3: "regular"}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
GAMS_VARIABLE_SUBTYPES = {
|
|
109
|
+
GMS_VARTYPE_BINARY: "binary",
|
|
110
|
+
GMS_VARTYPE_INTEGER: "integer",
|
|
111
|
+
GMS_VARTYPE_POSITIVE: "positive",
|
|
112
|
+
GMS_VARTYPE_NEGATIVE: "negative",
|
|
113
|
+
GMS_VARTYPE_FREE: "free",
|
|
114
|
+
GMS_VARTYPE_SOS1: "sos1",
|
|
115
|
+
GMS_VARTYPE_SOS2: "sos2",
|
|
116
|
+
GMS_VARTYPE_SEMICONT: "semicont",
|
|
117
|
+
GMS_VARTYPE_SEMIINT: "semiint",
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
TRANSFER_TO_GAMS_VARIABLE_SUBTYPES = {v: k for k, v in GAMS_VARIABLE_SUBTYPES.items()}
|
|
121
|
+
|
|
122
|
+
GAMS_EQUATION_SUBTYPES = {
|
|
123
|
+
GMS_EQUTYPE_E: "eq",
|
|
124
|
+
GMS_EQUTYPE_G: "geq",
|
|
125
|
+
GMS_EQUTYPE_L: "leq",
|
|
126
|
+
GMS_EQUTYPE_N: "nonbinding",
|
|
127
|
+
GMS_EQUTYPE_X: "external",
|
|
128
|
+
GMS_EQUTYPE_B: "boolean",
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
TRANSFER_TO_GAMS_EQUATION_SUBTYPES = {v: k for k, v in GAMS_EQUATION_SUBTYPES.items()}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
VAR_DEFAULT_VALUES = {
|
|
135
|
+
"binary": {
|
|
136
|
+
"level": 0.0,
|
|
137
|
+
"marginal": 0.0,
|
|
138
|
+
"lower": 0.0,
|
|
139
|
+
"upper": 1.0,
|
|
140
|
+
"scale": 1.0,
|
|
141
|
+
},
|
|
142
|
+
"integer": {
|
|
143
|
+
"level": 0.0,
|
|
144
|
+
"marginal": 0.0,
|
|
145
|
+
"lower": 0.0,
|
|
146
|
+
"upper": SpecialValues.POSINF,
|
|
147
|
+
"scale": 1.0,
|
|
148
|
+
},
|
|
149
|
+
"positive": {
|
|
150
|
+
"level": 0.0,
|
|
151
|
+
"marginal": 0.0,
|
|
152
|
+
"lower": 0.0,
|
|
153
|
+
"upper": SpecialValues.POSINF,
|
|
154
|
+
"scale": 1.0,
|
|
155
|
+
},
|
|
156
|
+
"negative": {
|
|
157
|
+
"level": 0.0,
|
|
158
|
+
"marginal": 0.0,
|
|
159
|
+
"lower": SpecialValues.NEGINF,
|
|
160
|
+
"upper": 0.0,
|
|
161
|
+
"scale": 1.0,
|
|
162
|
+
},
|
|
163
|
+
"free": {
|
|
164
|
+
"level": 0.0,
|
|
165
|
+
"marginal": 0.0,
|
|
166
|
+
"lower": SpecialValues.NEGINF,
|
|
167
|
+
"upper": SpecialValues.POSINF,
|
|
168
|
+
"scale": 1.0,
|
|
169
|
+
},
|
|
170
|
+
"sos1": {
|
|
171
|
+
"level": 0.0,
|
|
172
|
+
"marginal": 0.0,
|
|
173
|
+
"lower": 0.0,
|
|
174
|
+
"upper": SpecialValues.POSINF,
|
|
175
|
+
"scale": 1.0,
|
|
176
|
+
},
|
|
177
|
+
"sos2": {
|
|
178
|
+
"level": 0.0,
|
|
179
|
+
"marginal": 0.0,
|
|
180
|
+
"lower": 0.0,
|
|
181
|
+
"upper": SpecialValues.POSINF,
|
|
182
|
+
"scale": 1.0,
|
|
183
|
+
},
|
|
184
|
+
"semicont": {
|
|
185
|
+
"level": 0.0,
|
|
186
|
+
"marginal": 0.0,
|
|
187
|
+
"lower": 1.0,
|
|
188
|
+
"upper": SpecialValues.POSINF,
|
|
189
|
+
"scale": 1.0,
|
|
190
|
+
},
|
|
191
|
+
"semiint": {
|
|
192
|
+
"level": 0.0,
|
|
193
|
+
"marginal": 0.0,
|
|
194
|
+
"lower": 1.0,
|
|
195
|
+
"upper": SpecialValues.POSINF,
|
|
196
|
+
"scale": 1.0,
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
# equation types
|
|
201
|
+
EQU_TYPE = {
|
|
202
|
+
"eq": "eq",
|
|
203
|
+
"geq": "geq",
|
|
204
|
+
"leq": "leq",
|
|
205
|
+
"nonbinding": "nonbinding",
|
|
206
|
+
"external": "external",
|
|
207
|
+
"boolean": "boolean",
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
# additional user supported notation for defining equation types
|
|
211
|
+
EQU_TYPE.update({"=e=": "eq", "e": "eq"})
|
|
212
|
+
EQU_TYPE.update({"=g=": "geq", "g": "geq"})
|
|
213
|
+
EQU_TYPE.update({"=l=": "leq", "l": "leq"})
|
|
214
|
+
EQU_TYPE.update({"=n=": "nonbinding", "n": "nonbinding"})
|
|
215
|
+
EQU_TYPE.update({"=x=": "external", "x": "external"})
|
|
216
|
+
EQU_TYPE.update({"=b=": "boolean", "b": "boolean"})
|
|
217
|
+
|
|
218
|
+
EQU_DEFAULT_VALUES = {
|
|
219
|
+
"eq": {
|
|
220
|
+
"level": 0.0,
|
|
221
|
+
"marginal": 0.0,
|
|
222
|
+
"lower": 0.0,
|
|
223
|
+
"upper": 0.0,
|
|
224
|
+
"scale": 1.0,
|
|
225
|
+
},
|
|
226
|
+
"geq": {
|
|
227
|
+
"level": 0.0,
|
|
228
|
+
"marginal": 0.0,
|
|
229
|
+
"lower": 0.0,
|
|
230
|
+
"upper": SpecialValues.POSINF,
|
|
231
|
+
"scale": 1.0,
|
|
232
|
+
},
|
|
233
|
+
"leq": {
|
|
234
|
+
"level": 0.0,
|
|
235
|
+
"marginal": 0.0,
|
|
236
|
+
"lower": SpecialValues.NEGINF,
|
|
237
|
+
"upper": 0.0,
|
|
238
|
+
"scale": 1.0,
|
|
239
|
+
},
|
|
240
|
+
"nonbinding": {
|
|
241
|
+
"level": 0.0,
|
|
242
|
+
"marginal": 0.0,
|
|
243
|
+
"lower": SpecialValues.NEGINF,
|
|
244
|
+
"upper": SpecialValues.POSINF,
|
|
245
|
+
"scale": 1.0,
|
|
246
|
+
},
|
|
247
|
+
"external": {
|
|
248
|
+
"level": 0.0,
|
|
249
|
+
"marginal": 0.0,
|
|
250
|
+
"lower": 0.0,
|
|
251
|
+
"upper": 0.0,
|
|
252
|
+
"scale": 1.0,
|
|
253
|
+
},
|
|
254
|
+
"boolean": {
|
|
255
|
+
"level": 0.0,
|
|
256
|
+
"marginal": 0.0,
|
|
257
|
+
"lower": 0.0,
|
|
258
|
+
"upper": 0.0,
|
|
259
|
+
"scale": 1.0,
|
|
260
|
+
},
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
# equivalents
|
|
265
|
+
EPS = set(list(map("".join, itertools.product(*zip("EPS", "eps")))))
|
|
266
|
+
UNDEF = set(
|
|
267
|
+
list(map("".join, itertools.product(*zip("UNDEF", "undef"))))
|
|
268
|
+
+ list(map("".join, itertools.product(*zip("UNDF", "undf"))))
|
|
269
|
+
)
|
|
270
|
+
NA = set(list(map("".join, itertools.product(*zip("NA", "na")))))
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#
|
|
2
|
+
# GAMS - General Algebraic Modeling System Python API
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2026 GAMS Development Corp. <support@gams.com>
|
|
5
|
+
# Copyright (c) 2017-2026 GAMS Software GmbH <support@gams.com>
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
# copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
# SOFTWARE.
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
from gams.transfer._abcs import (
|
|
27
|
+
ABCSet,
|
|
28
|
+
ABCAlias,
|
|
29
|
+
ABCParameter,
|
|
30
|
+
ABCVariable,
|
|
31
|
+
ABCEquation,
|
|
32
|
+
AnyContainerDomainSymbol,
|
|
33
|
+
)
|
|
34
|
+
from typing import List, Union
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class DomainViolation:
|
|
38
|
+
def __init__(self, symbol, dimension, domain, violations):
|
|
39
|
+
self.symbol = symbol
|
|
40
|
+
self.dimension = dimension
|
|
41
|
+
self.domain = domain
|
|
42
|
+
self.violations = violations
|
|
43
|
+
|
|
44
|
+
def __repr__(self):
|
|
45
|
+
return f"<DomainViolation ({hex(id(self))})>"
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def symbol(self):
|
|
49
|
+
return self._symbol
|
|
50
|
+
|
|
51
|
+
@symbol.setter
|
|
52
|
+
def symbol(
|
|
53
|
+
self,
|
|
54
|
+
symbol: Union[
|
|
55
|
+
"ABCSet", "ABCAlias", "ABCParameter", "ABCVariable", "ABCEquation"
|
|
56
|
+
],
|
|
57
|
+
) -> None:
|
|
58
|
+
if not isinstance(
|
|
59
|
+
symbol, (ABCSet, ABCAlias, ABCParameter, ABCVariable, ABCEquation)
|
|
60
|
+
):
|
|
61
|
+
raise TypeError(
|
|
62
|
+
"Argument 'symbol' expects objects of the _Symbol parent "
|
|
63
|
+
"class (i.e., a Set, Alias, Parameter, Variable, Equation)"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
self._symbol = symbol
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def dimension(self):
|
|
70
|
+
return self._dimension
|
|
71
|
+
|
|
72
|
+
@dimension.setter
|
|
73
|
+
def dimension(self, dimension: int) -> None:
|
|
74
|
+
if not isinstance(dimension, int):
|
|
75
|
+
raise TypeError("Argument 'dimension' must be of type int")
|
|
76
|
+
|
|
77
|
+
self._dimension = dimension
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def domain(self):
|
|
81
|
+
return self._domain
|
|
82
|
+
|
|
83
|
+
@domain.setter
|
|
84
|
+
def domain(self, domain: "AnyContainerDomainSymbol") -> None:
|
|
85
|
+
if not isinstance(domain, AnyContainerDomainSymbol):
|
|
86
|
+
raise TypeError(
|
|
87
|
+
"Argument 'symbol' expects Set, Alias, or UniverseAlias objects"
|
|
88
|
+
)
|
|
89
|
+
self._domain = domain
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def violations(self):
|
|
93
|
+
return self._violations
|
|
94
|
+
|
|
95
|
+
@violations.setter
|
|
96
|
+
def violations(self, violations: List[str]) -> None:
|
|
97
|
+
if not isinstance(violations, list):
|
|
98
|
+
raise TypeError("Argument 'violations' must be type list")
|
|
99
|
+
|
|
100
|
+
if any(not isinstance(i, str) for i in violations):
|
|
101
|
+
raise TypeError("Argument 'violations' must only contain type str")
|
|
102
|
+
|
|
103
|
+
self._violations = violations
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#
|
|
2
|
+
# GAMS - General Algebraic Modeling System Python API
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2026 GAMS Development Corp. <support@gams.com>
|
|
5
|
+
# Copyright (c) 2017-2026 GAMS Software GmbH <support@gams.com>
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
# copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
# SOFTWARE.
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
import struct
|
|
27
|
+
import numpy as np
|
|
28
|
+
import pandas as pd
|
|
29
|
+
from typing import Union
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SpecialValues:
|
|
33
|
+
NA = struct.unpack(">d", bytes.fromhex("fffffffffffffffe"))[0]
|
|
34
|
+
_NA_INT64 = np.float64(NA).view(np.uint64)
|
|
35
|
+
EPS = -0.0
|
|
36
|
+
UNDEF = float("nan")
|
|
37
|
+
POSINF = float("inf")
|
|
38
|
+
NEGINF = float("-inf")
|
|
39
|
+
|
|
40
|
+
def _convertNPfloat64(records, sv_name):
|
|
41
|
+
if not (
|
|
42
|
+
isinstance(records, np.ndarray) and np.issubdtype(records.dtype, np.float64)
|
|
43
|
+
):
|
|
44
|
+
try:
|
|
45
|
+
records = np.array(records, dtype=np.float64)
|
|
46
|
+
except Exception as err:
|
|
47
|
+
raise Exception(
|
|
48
|
+
"Data structure passed in 'records' could not be "
|
|
49
|
+
"converted to a numpy array (dtype=np.float64) "
|
|
50
|
+
f"to test for GAMS {sv_name}, reason: {err}"
|
|
51
|
+
) from err
|
|
52
|
+
return records
|
|
53
|
+
|
|
54
|
+
def isEps(records: Union[int, float, str, pd.Series, pd.DataFrame]) -> bool:
|
|
55
|
+
"""
|
|
56
|
+
Check if the input records represent a value close to zero with specific considerations for different data types.
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
records: int | float | str | pd.Series | pd.DataFrame | array-like
|
|
61
|
+
The input records to be checked for proximity to zero.
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
bool
|
|
66
|
+
True if the input records represent a value close to zero according to the specified conditions, False otherwise.
|
|
67
|
+
|
|
68
|
+
Raises
|
|
69
|
+
------
|
|
70
|
+
Exception
|
|
71
|
+
If the input (string) records cannot be converted to a float.
|
|
72
|
+
Exception
|
|
73
|
+
If the data structure passed in 'records' could not be converted to a numpy array (dtype=float) for testing.
|
|
74
|
+
"""
|
|
75
|
+
records = SpecialValues._convertNPfloat64(records, "EPS")
|
|
76
|
+
return (records == 0) & (np.signbit(records))
|
|
77
|
+
|
|
78
|
+
def isNA(records: Union[int, float, str, pd.Series, pd.DataFrame]) -> bool:
|
|
79
|
+
"""
|
|
80
|
+
Check if values in records represent GAMS NA (Not Available) values.
|
|
81
|
+
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
records: int | float | str | pd.Series | pd.DataFrame | array-like
|
|
85
|
+
The input records to be checked for GAMS NA values.
|
|
86
|
+
|
|
87
|
+
Returns
|
|
88
|
+
-------
|
|
89
|
+
bool
|
|
90
|
+
True if the values in records represent GAMS NA values; otherwise, False.
|
|
91
|
+
|
|
92
|
+
Raises
|
|
93
|
+
------
|
|
94
|
+
Exception
|
|
95
|
+
If the input (string) records cannot be converted to a float.
|
|
96
|
+
Exception
|
|
97
|
+
If the data structure passed in 'records' could not be converted to a numpy array (dtype=float) for testing.
|
|
98
|
+
"""
|
|
99
|
+
records = SpecialValues._convertNPfloat64(records, "NA")
|
|
100
|
+
return records.view(np.uint64) == SpecialValues._NA_INT64
|
|
101
|
+
|
|
102
|
+
def isUndef(records: Union[int, float, str, pd.Series, pd.DataFrame]) -> bool:
|
|
103
|
+
"""
|
|
104
|
+
Determine if the given input(s) represent GAMS "undef" values.
|
|
105
|
+
|
|
106
|
+
Parameters
|
|
107
|
+
----------
|
|
108
|
+
records: int | float | str | pd.Series | pd.DataFrame | array-like
|
|
109
|
+
The input records to be checked for GAMS "undef" values.
|
|
110
|
+
|
|
111
|
+
Returns
|
|
112
|
+
-------
|
|
113
|
+
bool
|
|
114
|
+
True if the values in records represent GAMS "undef" values; otherwise, False.
|
|
115
|
+
|
|
116
|
+
Raises
|
|
117
|
+
------
|
|
118
|
+
Exception
|
|
119
|
+
If the input (string) records cannot be converted to a float.
|
|
120
|
+
Exception
|
|
121
|
+
If the data structure passed in 'records' could not be converted to a numpy array (dtype=float) for testing.
|
|
122
|
+
"""
|
|
123
|
+
records = SpecialValues._convertNPfloat64(records, "UNDEF")
|
|
124
|
+
return np.isnan(records) & (records.view(np.uint64) != SpecialValues._NA_INT64)
|
|
125
|
+
|
|
126
|
+
def isPosInf(records: Union[int, float, str, pd.Series, pd.DataFrame]) -> bool:
|
|
127
|
+
"""
|
|
128
|
+
Check if the input records represent positive infinity.
|
|
129
|
+
|
|
130
|
+
Parameters
|
|
131
|
+
----------
|
|
132
|
+
records: int | float | str | pd.Series | pd.DataFrame | array-like
|
|
133
|
+
The input records to be checked for positive infinity values.
|
|
134
|
+
|
|
135
|
+
Returns
|
|
136
|
+
-------
|
|
137
|
+
bool
|
|
138
|
+
True if the values in records represent positive infinity values; otherwise, False.
|
|
139
|
+
|
|
140
|
+
Raises
|
|
141
|
+
------
|
|
142
|
+
Exception
|
|
143
|
+
If the input (string) records cannot be converted to a float.
|
|
144
|
+
Exception
|
|
145
|
+
If the data structure passed in 'records' could not be converted to a numpy array (dtype=float) for testing.
|
|
146
|
+
"""
|
|
147
|
+
records = SpecialValues._convertNPfloat64(records, "POSINF")
|
|
148
|
+
return np.isposinf(records)
|
|
149
|
+
|
|
150
|
+
def isNegInf(records: Union[int, float, str, pd.Series, pd.DataFrame]) -> bool:
|
|
151
|
+
"""
|
|
152
|
+
Check if the input records represent negative infinity.
|
|
153
|
+
|
|
154
|
+
Parameters
|
|
155
|
+
----------
|
|
156
|
+
records: int | float | str | pd.Series | pd.DataFrame | array-like
|
|
157
|
+
The input records to be checked for negative infinity values.
|
|
158
|
+
|
|
159
|
+
Returns
|
|
160
|
+
-------
|
|
161
|
+
bool
|
|
162
|
+
True if the values in records represent negative infinity values; otherwise, False.
|
|
163
|
+
|
|
164
|
+
Raises
|
|
165
|
+
------
|
|
166
|
+
Exception
|
|
167
|
+
If the input (string) records cannot be converted to a float.
|
|
168
|
+
Exception
|
|
169
|
+
If the data structure passed in 'records' could not be converted to a numpy array (dtype=float) for testing.
|
|
170
|
+
"""
|
|
171
|
+
records = SpecialValues._convertNPfloat64(records, "NEGINF")
|
|
172
|
+
return np.isneginf(records)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#
|
|
2
|
+
# GAMS - General Algebraic Modeling System Python API
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2026 GAMS Development Corp. <support@gams.com>
|
|
5
|
+
# Copyright (c) 2017-2026 GAMS Software GmbH <support@gams.com>
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
# copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
# SOFTWARE.
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
from gams.transfer.containers._container import Container
|