Source code for gamspy._algebra.number
#
# GAMS - General Algebraic Modeling System Python API
#
# Copyright (c) 2023 GAMS Development Corp. <support@gams.com>
# Copyright (c) 2023 GAMS Software GmbH <support@gams.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
from __future__ import annotations
import gamspy._algebra.condition as condition
import gamspy._algebra.operable as operable
[docs]
class Number(operable.Operable):
"""
Needed for conditions on numbers.
Parameters
----------
value : int | float
Examples
--------
>>> import gamspy as gp
>>> m = gp.Container()
>>> k = gp.Set(m, "k", records=["1964-i","1964-ii","1964-iii","1964-iv"])
>>> ki = gp.Set(m, name="ki", domain=[k], description="initial period")
>>> ki[k] = gp.Number(1).where[gp.Ord(k) == 1]
"""
def __init__(self, value: int | float):
self._value = value
self.where = condition.Condition(self)
[docs]
def gamsRepr(self) -> str:
"""
Representation of this Number in GAMS language.
Returns
-------
str
"""
return f"{self._value}"