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,321 @@
|
|
|
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
|
+
import weakref
|
|
28
|
+
from gams.core import gdx
|
|
29
|
+
from gams.transfer._abcs import ABCVariable, ABCSet, ABCContainer
|
|
30
|
+
from gams.transfer.syms._mixins import (
|
|
31
|
+
PVEMixin,
|
|
32
|
+
SAPVEMixin,
|
|
33
|
+
SAUAPVEMixin,
|
|
34
|
+
SPVEMixin,
|
|
35
|
+
VEMixin,
|
|
36
|
+
)
|
|
37
|
+
from gams.transfer._internals import (
|
|
38
|
+
VAR_DEFAULT_VALUES,
|
|
39
|
+
TRANSFER_TO_GAMS_VARIABLE_SUBTYPES,
|
|
40
|
+
)
|
|
41
|
+
from gams.transfer.syms._mixins.pivot import PivotVariableMixin
|
|
42
|
+
from gams.transfer.syms._mixins.generateRecords import GenerateRecordsVariableMixin
|
|
43
|
+
from gams.transfer.syms._mixins.equals import EqualsVariableMixin
|
|
44
|
+
from typing import Any, List, Optional, Union, TYPE_CHECKING
|
|
45
|
+
|
|
46
|
+
if TYPE_CHECKING:
|
|
47
|
+
from gams.transfer import Container
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class Variable(
|
|
51
|
+
PVEMixin,
|
|
52
|
+
SAPVEMixin,
|
|
53
|
+
SAUAPVEMixin,
|
|
54
|
+
SPVEMixin,
|
|
55
|
+
VEMixin,
|
|
56
|
+
PivotVariableMixin,
|
|
57
|
+
GenerateRecordsVariableMixin,
|
|
58
|
+
EqualsVariableMixin,
|
|
59
|
+
ABCVariable,
|
|
60
|
+
):
|
|
61
|
+
"""
|
|
62
|
+
Represents a variable symbol in GAMS. https://www.gams.com/latest/docs/UG_Variables.html
|
|
63
|
+
|
|
64
|
+
Parameters
|
|
65
|
+
----------
|
|
66
|
+
container : Container
|
|
67
|
+
name : str
|
|
68
|
+
type : str, optional
|
|
69
|
+
domain : list, optional
|
|
70
|
+
records : DataFrame, optional
|
|
71
|
+
domain_forwarding : bool, optional
|
|
72
|
+
description : str, optional
|
|
73
|
+
|
|
74
|
+
Examples
|
|
75
|
+
--------
|
|
76
|
+
>>> import gams.transfer as gt
|
|
77
|
+
>>> m = gt.Container()
|
|
78
|
+
>>> i = gt.Set(m, "i", records=['i1','i2'])
|
|
79
|
+
>>> v = gt.Variable(m, "a", domain=i)
|
|
80
|
+
|
|
81
|
+
Attributes
|
|
82
|
+
----------
|
|
83
|
+
container
|
|
84
|
+
Container where the symbol exists
|
|
85
|
+
description : str
|
|
86
|
+
description of symbol
|
|
87
|
+
dimension : int
|
|
88
|
+
The dimension of symbol
|
|
89
|
+
domain : List[Set | Alias | str]
|
|
90
|
+
List of domains given either as string (* for universe set) or as reference to the Set/Alias object
|
|
91
|
+
domain_forwarding : bool
|
|
92
|
+
Flag that identifies if domain forwarding is enabled for the symbol
|
|
93
|
+
domain_labels : List[str]
|
|
94
|
+
The column headings for the records DataFrame
|
|
95
|
+
domain_names : List[str]
|
|
96
|
+
String version of domain names
|
|
97
|
+
domain_type : str
|
|
98
|
+
The state of domain links
|
|
99
|
+
is_scalar : bool
|
|
100
|
+
Flag that identifies if the Variable is scalar
|
|
101
|
+
modified: bool
|
|
102
|
+
Flag that identifies if the symbol has been modified
|
|
103
|
+
name : str
|
|
104
|
+
Name of the symbol
|
|
105
|
+
number_records : int
|
|
106
|
+
The number of symbol records
|
|
107
|
+
records : DataFrame
|
|
108
|
+
The main symbol records
|
|
109
|
+
shape : tuple
|
|
110
|
+
Shape of symbol records
|
|
111
|
+
summary : dict
|
|
112
|
+
A dict of only the metadata
|
|
113
|
+
type : str
|
|
114
|
+
Type of the variable
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
@classmethod
|
|
118
|
+
def _from_gams(cls, container, name, type, domain, records=None, description=""):
|
|
119
|
+
# create new symbol object
|
|
120
|
+
obj = Variable.__new__(cls)
|
|
121
|
+
|
|
122
|
+
# set private properties directly
|
|
123
|
+
obj._type = type
|
|
124
|
+
obj._gams_type = gdx.GMS_DT_VAR
|
|
125
|
+
obj._gams_subtype = TRANSFER_TO_GAMS_VARIABLE_SUBTYPES[type]
|
|
126
|
+
|
|
127
|
+
obj._requires_state_check = False
|
|
128
|
+
obj._container = weakref.proxy(container)
|
|
129
|
+
obj._name = name
|
|
130
|
+
obj._domain = domain
|
|
131
|
+
obj._domain_forwarding = False
|
|
132
|
+
obj._description = description
|
|
133
|
+
obj._records = records
|
|
134
|
+
obj._modified = True
|
|
135
|
+
|
|
136
|
+
# add to container
|
|
137
|
+
obj._container.data.update({name: obj})
|
|
138
|
+
obj._container._requires_state_check = True
|
|
139
|
+
|
|
140
|
+
return obj
|
|
141
|
+
|
|
142
|
+
def __new__(cls, *args, **kwargs):
|
|
143
|
+
# fastpath
|
|
144
|
+
if len(args) == len(kwargs) == 0:
|
|
145
|
+
return object.__new__(cls)
|
|
146
|
+
|
|
147
|
+
try:
|
|
148
|
+
container = args[0]
|
|
149
|
+
except IndexError:
|
|
150
|
+
container = kwargs.get("container", None)
|
|
151
|
+
|
|
152
|
+
try:
|
|
153
|
+
name = args[1]
|
|
154
|
+
except IndexError:
|
|
155
|
+
name = kwargs.get("name", None)
|
|
156
|
+
|
|
157
|
+
try:
|
|
158
|
+
symobj = container[name]
|
|
159
|
+
except (KeyError, IndexError, TypeError):
|
|
160
|
+
symobj = None
|
|
161
|
+
|
|
162
|
+
if symobj is None:
|
|
163
|
+
return object.__new__(cls)
|
|
164
|
+
else:
|
|
165
|
+
if isinstance(symobj, cls):
|
|
166
|
+
return symobj
|
|
167
|
+
else:
|
|
168
|
+
raise TypeError(
|
|
169
|
+
f"Cannot overwrite symbol '{symobj.name}' in container because it is not a {cls.__name__} object"
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
def __init__(
|
|
173
|
+
self,
|
|
174
|
+
container: "Container",
|
|
175
|
+
name: str,
|
|
176
|
+
type: str = "free",
|
|
177
|
+
domain: Optional[List[Union[str, ABCSet]]] = None,
|
|
178
|
+
records: Optional[Any] = None,
|
|
179
|
+
domain_forwarding: bool = False,
|
|
180
|
+
description: str = "",
|
|
181
|
+
uels_on_axes: bool = False,
|
|
182
|
+
):
|
|
183
|
+
# domain handling
|
|
184
|
+
if domain is None:
|
|
185
|
+
domain = []
|
|
186
|
+
|
|
187
|
+
if isinstance(domain, (ABCSet, str)):
|
|
188
|
+
domain = [domain]
|
|
189
|
+
|
|
190
|
+
# does symbol exist
|
|
191
|
+
has_symbol = False
|
|
192
|
+
if isinstance(getattr(self, "container", None), ABCContainer):
|
|
193
|
+
has_symbol = True
|
|
194
|
+
|
|
195
|
+
if has_symbol:
|
|
196
|
+
try:
|
|
197
|
+
if self.type != type.casefold():
|
|
198
|
+
raise TypeError(
|
|
199
|
+
f"Cannot overwrite symbol in container unless variable types are equal: `{self.type}` != `{type.casefold()}`"
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
if any(
|
|
203
|
+
d1 != d2 for d1, d2 in itertools.zip_longest(self.domain, domain)
|
|
204
|
+
):
|
|
205
|
+
raise ValueError(
|
|
206
|
+
"Cannot overwrite symbol in container unless symbol domains are equal"
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
if self.domain_forwarding != domain_forwarding:
|
|
210
|
+
raise ValueError(
|
|
211
|
+
"Cannot overwrite symbol in container unless 'domain_forwarding' is left unchanged"
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
except ValueError as err:
|
|
215
|
+
raise ValueError(err)
|
|
216
|
+
|
|
217
|
+
except TypeError as err:
|
|
218
|
+
raise TypeError(err)
|
|
219
|
+
|
|
220
|
+
# reset some properties
|
|
221
|
+
self._requires_state_check = True
|
|
222
|
+
self.container._requires_state_check = True
|
|
223
|
+
if description != "":
|
|
224
|
+
self.description = description
|
|
225
|
+
self.records = None
|
|
226
|
+
self.modified = True
|
|
227
|
+
|
|
228
|
+
# only set records if records are provided
|
|
229
|
+
if records is not None:
|
|
230
|
+
self.setRecords(records, uels_on_axes=uels_on_axes)
|
|
231
|
+
|
|
232
|
+
else:
|
|
233
|
+
# populate new symbol properties
|
|
234
|
+
self.type = type
|
|
235
|
+
self._gams_type = gdx.GMS_DT_VAR
|
|
236
|
+
self._gams_subtype = TRANSFER_TO_GAMS_VARIABLE_SUBTYPES[type]
|
|
237
|
+
self._requires_state_check = True
|
|
238
|
+
self.container = container
|
|
239
|
+
self.container._requires_state_check = True
|
|
240
|
+
self.name = name
|
|
241
|
+
self.domain = domain
|
|
242
|
+
self.domain_forwarding = domain_forwarding
|
|
243
|
+
self.description = description
|
|
244
|
+
self.records = None
|
|
245
|
+
self.modified = True
|
|
246
|
+
|
|
247
|
+
# only set records if records are provided
|
|
248
|
+
if records is not None:
|
|
249
|
+
self.setRecords(records, uels_on_axes=uels_on_axes)
|
|
250
|
+
|
|
251
|
+
# add to container
|
|
252
|
+
container.data.update({name: self})
|
|
253
|
+
|
|
254
|
+
def __repr__(self):
|
|
255
|
+
return f"<{self.type.capitalize()} Variable `{self.name}` ({hex(id(self))})>"
|
|
256
|
+
|
|
257
|
+
def __delitem__(self):
|
|
258
|
+
del self.container.data[self.name]
|
|
259
|
+
|
|
260
|
+
@property
|
|
261
|
+
def default_records(self):
|
|
262
|
+
"""Default records of a variable"""
|
|
263
|
+
return VAR_DEFAULT_VALUES[self._type]
|
|
264
|
+
|
|
265
|
+
@property
|
|
266
|
+
def type(self) -> str:
|
|
267
|
+
"""
|
|
268
|
+
The type of variable; [binary, integer, positive, negative, free, sos1, sos2, semicont, semiintn]
|
|
269
|
+
|
|
270
|
+
Returns
|
|
271
|
+
-------
|
|
272
|
+
str
|
|
273
|
+
The type of variable
|
|
274
|
+
"""
|
|
275
|
+
return self._type
|
|
276
|
+
|
|
277
|
+
@type.setter
|
|
278
|
+
def type(self, typ: str) -> None:
|
|
279
|
+
"""
|
|
280
|
+
The type of variable; [binary, integer, positive, negative, free, sos1, sos2, semicont, semiintn]
|
|
281
|
+
|
|
282
|
+
Parameters
|
|
283
|
+
----------
|
|
284
|
+
typ : str
|
|
285
|
+
The type of variable
|
|
286
|
+
"""
|
|
287
|
+
if not isinstance(typ, str):
|
|
288
|
+
raise TypeError(f"Argument 'type' must be type str")
|
|
289
|
+
|
|
290
|
+
typ = typ.casefold()
|
|
291
|
+
|
|
292
|
+
if typ not in TRANSFER_TO_GAMS_VARIABLE_SUBTYPES.keys():
|
|
293
|
+
raise ValueError(
|
|
294
|
+
"Argument 'type' must be one of the following (mixed-case OK): \n\n"
|
|
295
|
+
" 1. 'binary' \n"
|
|
296
|
+
" 2. 'integer' \n"
|
|
297
|
+
" 3. 'positive' \n"
|
|
298
|
+
" 4. 'negative' \n"
|
|
299
|
+
" 5. 'free' \n"
|
|
300
|
+
" 6. 'sos1' \n"
|
|
301
|
+
" 7. 'sos2' \n"
|
|
302
|
+
" 8. 'semicont' \n"
|
|
303
|
+
" 9. 'semiint' \n\n"
|
|
304
|
+
f"User passed: `{typ}`"
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
# check to see if _type is being changed
|
|
308
|
+
if getattr(self, "type", None) is not None:
|
|
309
|
+
if self._type is not typ:
|
|
310
|
+
self._requires_state_check = True
|
|
311
|
+
|
|
312
|
+
self.container._requires_state_check = True
|
|
313
|
+
self.container.modified = True
|
|
314
|
+
|
|
315
|
+
# set the symbol type
|
|
316
|
+
self._type = typ
|
|
317
|
+
self.modified = True
|
|
318
|
+
else:
|
|
319
|
+
# set the symbol type
|
|
320
|
+
self._type = typ
|
|
321
|
+
self.modified = True
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gamsapi
|
|
3
|
+
Version: 52.5.0
|
|
4
|
+
Summary: GAMS Python API
|
|
5
|
+
Home-page: https://www.gams.com/
|
|
6
|
+
Author: GAMS Development Corporation
|
|
7
|
+
Author-email: support@gams.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Documentation, https://www.gams.com/latest/docs/API_PY_OVERVIEW.html
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Provides-Extra: connect
|
|
27
|
+
Requires-Dist: pandas<2.4,>=2.2.2; extra == "connect"
|
|
28
|
+
Requires-Dist: pyyaml; extra == "connect"
|
|
29
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "connect"
|
|
30
|
+
Requires-Dist: sqlalchemy; extra == "connect"
|
|
31
|
+
Requires-Dist: cerberus; extra == "connect"
|
|
32
|
+
Requires-Dist: pyodbc; extra == "connect"
|
|
33
|
+
Requires-Dist: psycopg2-binary; extra == "connect"
|
|
34
|
+
Requires-Dist: pymysql; extra == "connect"
|
|
35
|
+
Requires-Dist: pymssql; extra == "connect"
|
|
36
|
+
Provides-Extra: control
|
|
37
|
+
Requires-Dist: certifi; extra == "control"
|
|
38
|
+
Requires-Dist: urllib3; extra == "control"
|
|
39
|
+
Provides-Extra: core
|
|
40
|
+
Requires-Dist: ply; extra == "core"
|
|
41
|
+
Requires-Dist: numpy; extra == "core"
|
|
42
|
+
Provides-Extra: engine
|
|
43
|
+
Requires-Dist: pydantic; extra == "engine"
|
|
44
|
+
Requires-Dist: python_dateutil; extra == "engine"
|
|
45
|
+
Requires-Dist: urllib3; extra == "engine"
|
|
46
|
+
Provides-Extra: magic
|
|
47
|
+
Requires-Dist: ipython; extra == "magic"
|
|
48
|
+
Requires-Dist: pandas<2.4,>=2.2.2; extra == "magic"
|
|
49
|
+
Provides-Extra: tools
|
|
50
|
+
Requires-Dist: pandas<2.4,>=2.2.2; extra == "tools"
|
|
51
|
+
Provides-Extra: transfer
|
|
52
|
+
Requires-Dist: pandas<2.4,>=2.2.2; extra == "transfer"
|
|
53
|
+
Requires-Dist: scipy; extra == "transfer"
|
|
54
|
+
Provides-Extra: all
|
|
55
|
+
Requires-Dist: pyodbc; extra == "all"
|
|
56
|
+
Requires-Dist: certifi; extra == "all"
|
|
57
|
+
Requires-Dist: urllib3; extra == "all"
|
|
58
|
+
Requires-Dist: numpy; extra == "all"
|
|
59
|
+
Requires-Dist: pymssql; extra == "all"
|
|
60
|
+
Requires-Dist: pydantic; extra == "all"
|
|
61
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "all"
|
|
62
|
+
Requires-Dist: pyyaml; extra == "all"
|
|
63
|
+
Requires-Dist: cerberus; extra == "all"
|
|
64
|
+
Requires-Dist: psycopg2-binary; extra == "all"
|
|
65
|
+
Requires-Dist: pymysql; extra == "all"
|
|
66
|
+
Requires-Dist: ply; extra == "all"
|
|
67
|
+
Requires-Dist: python_dateutil; extra == "all"
|
|
68
|
+
Requires-Dist: ipython; extra == "all"
|
|
69
|
+
Requires-Dist: scipy; extra == "all"
|
|
70
|
+
Requires-Dist: pandas<2.4,>=2.2.2; extra == "all"
|
|
71
|
+
Requires-Dist: sqlalchemy; extra == "all"
|
|
72
|
+
Dynamic: author
|
|
73
|
+
Dynamic: author-email
|
|
74
|
+
Dynamic: classifier
|
|
75
|
+
Dynamic: description
|
|
76
|
+
Dynamic: description-content-type
|
|
77
|
+
Dynamic: home-page
|
|
78
|
+
Dynamic: license
|
|
79
|
+
Dynamic: license-file
|
|
80
|
+
Dynamic: project-url
|
|
81
|
+
Dynamic: provides-extra
|
|
82
|
+
Dynamic: requires-python
|
|
83
|
+
Dynamic: summary
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
<div align="center">
|
|
87
|
+
<img src="https://www.gams.com/img/gams_logo.svg"><br>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
-----------------
|
|
91
|
+
|
|
92
|
+
# gamsapi: powerful Python toolkit to manage GAMS (i.e., sparse) data and control GAMS solves
|
|
93
|
+
|
|
94
|
+
## What is it?
|
|
95
|
+
|
|
96
|
+
**gamsapi** is a Python package that includes submodules to control GAMS, manipulate and
|
|
97
|
+
transfer data to/from the GAMS modeling system (through GDX files or in-memory objects).
|
|
98
|
+
This functionality is available from a variety of different Python interfaces including
|
|
99
|
+
standard Python scripts and Jupyter Notebooks. We strive to make it as **simple** as
|
|
100
|
+
possible for users to generate, debug, customize, and ultimately use data to solve
|
|
101
|
+
optimization problems -- all while maintaining high performance.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## Main Features
|
|
105
|
+
Here are just a few of the things that **gamsapi** does well:
|
|
106
|
+
|
|
107
|
+
- Seamlessly integrates GAMS data requirements into standard data pipelines (i.e., Pandas, Numpy)
|
|
108
|
+
- Link and harmonize data sets across different symbols
|
|
109
|
+
- Clean/debug data **before** it enters the modeling environment
|
|
110
|
+
- Customize the look and feel of the data (i.e., labeling conventions)
|
|
111
|
+
- Bring data to GAMS from a variety of different starting points
|
|
112
|
+
- Send model output to a variety of different data endpoints (SQL, CSV, Excel, etc.)
|
|
113
|
+
- Automatic data reshaping and standardization -- will work to translate your data formats into the Pandas DataFrame standard
|
|
114
|
+
- Control GAMS model solves and model specification
|
|
115
|
+
|
|
116
|
+
## Where to get it
|
|
117
|
+
The source code is currently available with any typical [GAMS system](https://www.gams.com/download/).
|
|
118
|
+
No license is needed in order to use **gamsapi**. A license is necessary in order to solve GAMS models.
|
|
119
|
+
|
|
120
|
+
A free [demo license](https://www.gams.com/try_gams/) is available!
|
|
121
|
+
|
|
122
|
+
## Dependencies
|
|
123
|
+
Installing **gamsapi** will not install any third-party dependencies, as such, it only contains basic functionality.
|
|
124
|
+
Users should modify this base installation by choosing **extras** to install -- extras are described in the [documentation](https://www.gams.com/latest/docs/API_PY_GETTING_STARTED.html#PY_PIP_INSTALL_BDIST).
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
# from PyPI (with extra "transfer")
|
|
128
|
+
pip install gamsapi[transfer]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
# from PyPI (with extras "transfer" and "magic")
|
|
133
|
+
pip install gamsapi[transfer,magic]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
# from PyPI (include all dependencies)
|
|
138
|
+
pip install gamsapi[all]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Documentation
|
|
142
|
+
The official documentation is hosted on [gams.com](https://www.gams.com/latest/docs/API_PY_GETTING_STARTED.html).
|
|
143
|
+
|
|
144
|
+
## Getting Help
|
|
145
|
+
|
|
146
|
+
For usage questions, the best place to go to is [GAMS](https://www.gams.com/latest/docs/API_PY_GETTING_STARTED.html).
|
|
147
|
+
General questions and discussions can also take place on the [GAMS World Forum](https://forum.gamsworld.org).
|
|
148
|
+
|
|
149
|
+
## Discussion and Development
|
|
150
|
+
If you have a design request or concern, please write to support@gams.com.
|