Equation#

class gamspy.Equation(container, name, type='regular', domain=None, definition=None, records=None, domain_forwarding=False, description='', uels_on_axes=False, is_miro_output=False, definition_domain=None)[source]#

Bases: Equation, Operable, Symbol

Represents an Equation symbol in GAMS. https://www.gams.com/latest/docs/UG_Equations.html

Parameters:
containerContainer
namestr
typestr
domainList[Set | str], optional
definition: Expression, optional
recordsAny, optional
domain_forwardingbool, optional
descriptionstr, optional
uels_on_axes: bool
definition_domain: list, optional
is_miro_outputbool
Parameters:
  • container (Container) –

  • name (str) –

  • type (str | EquationType) –

  • domain (list[Set | str] | None) –

  • definition (Variable | Operation | Expression | None) –

  • records (Any | None) –

  • domain_forwarding (bool) –

  • description (str) –

  • uels_on_axes (bool) –

  • is_miro_output (bool) –

  • definition_domain (list | None) –

Examples

>>> import gamspy as gp
>>> m = gp.Container()
>>> i = gp.Set(m, "i", records=['i1','i2'])
>>> a = gp.Parameter(m, "a", [i], records=[['i1',1],['i2',2]])
>>> v = gp.Variable(m, "v", domain=[i])
>>> e = gp.Equation(m, "e", domain=[i])
>>> e[i] = a[i] <= v[i]
Attributes:
container

Container of the symbol

default_records

Default records of an equation

description

Description of the symbol

dimension

The dimension of symbol

domain

List of domains given either as string (* for universe set) or as reference to the Set/Alias object

domain_forwarding

A boolean indicating whether domain forwarding is enabled

domain_labels

The column headings for the records DataFrame

domain_names

String version of domain names

domain_type

State of the domain links

infeas

Infeasability

is_scalar

Returns True if the len(self.domain) = 0

l

Level

lo

Lower bound

m

Marginal

modified

Flag that identifies if the symbol has been modified

name

Name of symbol

number_records

Number of records

range

Range

records

Records of the Equation

scale

Scale

shape

Returns a tuple describing the array dimensions if records were converted with .toDense()

slack

Slack

slacklo

Slack lower bound

slackup

Slack upper bound

stage

Stage

summary

Summary of the symbol

type

The type of equation; 3.

up

Upper bound

Parameters:
  • container (Container) –

  • name (str) –

  • type (str | EquationType) –

  • domain (list[Set | str] | None) –

  • definition (Variable | Operation | Expression | None) –

  • records (Any | None) –

  • domain_forwarding (bool) –

  • description (str) –

  • uels_on_axes (bool) –

  • is_miro_output (bool) –

  • definition_domain (list | None) –

Methods

addUELs(uels[, dimensions])

Adds UELs to the symbol dimensions.

capitalizeUELs([dimensions])

Will capitalize all UELs in the Container or a subset of specified symbols, can be chained with other *UELs string operations

casefoldUELs([dimensions])

Will casefold all UELs in the Container or a subset of specified symbols, can be chained with other *UELs string operations

countDomainViolations()

Returns the count of how many records contain at least one domain violation

countDuplicateRecords()

Returns the count of how many (case insensitive) duplicate records exist

countEps([columns])

Counts total number of SpecialValues.EPS across columns

countNA([columns])

Counts total number of SpecialValues.NA across columns

countNegInf([columns])

Counts total number of SpecialValues.NegInf across columns

countPosInf([columns])

Counts total number of SpecialValues.PosInf across columns

countUndef([columns])

Counts total number of SpecialValues.Undef across columns

dropDefaults()

Drop records that are set to GAMS default records (check .default_records property for values)

dropDomainViolations()

drop records from the symbol that contain a domain violation

dropDuplicateRecords([keep])

Drop records with (case insensitive) duplicate domains from the symbol

dropEps()

Drop records from the symbol that are GAMS EPS (zero 0.0 records will be retained)

dropMissing()

Drop records from the symbol that are NaN (includes both NA and Undef special values)

dropNA()

Drop records from the symbol that are GAMS NA

dropUndef()

Drop records from the symbol that are GAMS Undef

equals(other[, columns, check_uels, ...])

Used to compare the symbol to another symbol

findDomainViolations()

Get a view of the records DataFrame that contain any domain violations

findDuplicateRecords([keep])

Get a view of the records DataFrame that contain any (case insensitive) duplicate domains – keep argument can take values of "first" (finds all duplicates while keeping the first instance as unique), "last" (finds all duplicates while keeping the last instance as unique), or False (finds all duplicates)

findEps([column])

Find positions of SpecialValues.EPS in value column

findNA([column])

Find positions of SpecialValues.NA in value column

findNegInf([column])

Find positions of SpecialValues.NegInf in value column

findPosInf([column])

Find positions of SpecialValues.PosInf in value column

findSpecialValues(values[, column])

Find positions of specified values in records columns

findUndef([column])

Find positions of SpecialValues.Undef in value column

gamsRepr()

Representation of this Equation in GAMS language.

generateRecords([density, func, seed])

Convenience method to set standard pandas.DataFrame formatted records given domain set information.

getDomainViolations()

Returns a list of DomainViolation objects if any (None otherwise)

getMaxAbsValue([columns])

Get the maximum absolute value across chosen columns

getMaxValue([columns])

Get the maximum value across chosen columns

getMeanValue([columns])

Get the mean value across chosen columns

getMinValue([columns])

Get the minimum value across chosen columns

getSparsity()

Get the sparsity of the symbol w.r.t the cardinality

getStatement()

Statement of the Equation declaration

getUELs([dimensions, codes, ignore_unused, ...])

Gets UELs from symbol dimensions.

hasDomainViolations()

Returns True if there are domain violations in the records, returns False if not.

hasDuplicateRecords()

Returns True if there are (case insensitive) duplicate records in the symbol, returns False if not

isValid([verbose, force])

Checks if the symbol is in a valid format

ljustUELs(length[, fill_character, dimensions])

Will left justify all UELs in the symbol or a subset of specified dimensions, can be chained with other *UELs string operations

lowerUELs([dimensions])

Will lowercase all UELs in the parent symbol or a subset of specified dimensions in the parent symbol, can be chain with other *UELs string operations

lstripUELs([dimensions])

Will left strip whitespace from all UELs in the parent set or a subset of specified dimensions in the parent set, can be chain with other *UELs string operations

pivot([index, columns, value, fill_value])

Convenience function to pivot records into a new shape (only symbols with >1D can be pivoted)

removeUELs([uels, dimensions])

Removes UELs that appear in the symbol dimensions, If uels is None then remove all unused UELs (categories).

renameUELs(uels[, dimensions, allow_merge])

Renames UELs (case-sensitive) that appear in the symbol dimensions.

reorderUELs([uels, dimensions])

Reorders the UELs in the symbol dimensions.

rjustUELs(length[, fill_character, dimensions])

Will right justify all UELs in the symbol or a subset of specified dimensions, can be chained with other *UELs string operations

rstripUELs([dimensions])

Will right strip whitespace from all UELs in the parent set or a subset of specified dimensions in the parent set, can be chain with other *UELs string operations

setRecords(records[, uels_on_axes])

Main convenience method to set standard pandas.DataFrame formatted records

setUELs(uels[, dimensions, rename])

Set the UELs for symbol dimensions.

stripUELs([dimensions])

Will strip whitespace from all UELs in the parent set or a subset of specified dimensions in the parent set, can be chain with other *UELs string operations

titleUELs([dimensions])

Will title (capitalize all individual words) in all UELs in the Container or a subset of specified symbols, can be chained with other *UELs string operations

toDense([column])

Convert column to a dense numpy.array format

toDict([columns, orient])

Convenience method to return symbol records as a Python dictionary

toList([columns])

Convenience method to return symbol records as a Python list

toSparseCoo([column])

Convert column to a sparse COOrdinate numpy.array format

toValue([column])

Convenience method to return symbol records as a Python float.

upperUELs([dimensions])

Will uppercase all UELs in the parent symbol or a subset of specified dimensions in the parent symbol, can be chain with other *UELs string operations

whereMax([column])

Find the domain entry of records with a maximum value (return first instance only)

whereMaxAbs([column])

Find the domain entry of records with a maximum absolute value (return first instance only)

whereMin([column])

Find the domain entry of records with a minimum value (return first instance only)

property description#

Description of the symbol

property modified#

Flag that identifies if the symbol has been modified

property l#

Level

Returns:
ImplicitParameter
property m#

Marginal

Returns:
ImplicitParameter
property lo#

Lower bound

Returns:
ImplicitParameter
property up#

Upper bound

Returns:
ImplicitParameter
property scale#

Scale

Returns:
ImplicitParameter
property stage#

Stage

Returns:
ImplicitParameter
property range#

Range

Returns:
ImplicitParameter
property slacklo#

Slack lower bound

Returns:
ImplicitParameter
property slackup#

Slack upper bound

Returns:
ImplicitParameter
property slack#

Slack

Returns:
ImplicitParameter
addUELs(uels, dimensions=None)#

Adds UELs to the symbol dimensions. If dimensions is None then add UELs to all dimensions. ** All trailing whitespace is trimmed **

Parameters:
uelsstr | List[str]

List of UELs

dimensionsint | list, optional

Symbol dimensions, by default None

Parameters:
  • uels (str | List[str]) –

  • dimensions (int | list | None) –

Return type:

None

capitalizeUELs(dimensions=None)#

Will capitalize all UELs in the Container or a subset of specified symbols, can be chained with other *UELs string operations

Parameters:
dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:

dimensions (int | List[int] | None) –

casefoldUELs(dimensions=None)#

Will casefold all UELs in the Container or a subset of specified symbols, can be chained with other *UELs string operations

Parameters:
dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:

dimensions (int | List[int] | None) –

property container#

Container of the symbol

countDomainViolations()#

Returns the count of how many records contain at least one domain violation

Returns:
int

Count of how many records contain at least one domain violation

Return type:

int

countDuplicateRecords()#

Returns the count of how many (case insensitive) duplicate records exist

Returns:
int

Count of how many (case insensitive) duplicate records exist

Return type:

int

countEps(columns=None)#

Counts total number of SpecialValues.EPS across columns

Parameters:
columnsstr | List[str], optional

Columns to count special values in, by default None

Returns:
Total number of SpecialValues.EPS across columns
Parameters:

columns (str | List[str] | None) –

Return type:

int

countNA(columns=None)#

Counts total number of SpecialValues.NA across columns

Parameters:
columnsstr | List[str], optional

Columns to count special values in, by default None

Returns:
Total number of SpecialValues.NA across columns
Parameters:

columns (str | List[str] | None) –

Return type:

int

countNegInf(columns=None)#

Counts total number of SpecialValues.NegInf across columns

Parameters:
columnsstr | List[str], optional

Columns to count special values in, by default None

Returns:
Total number of SpecialValues.NegInf across columns
Parameters:

columns (str | List[str] | None) –

Return type:

int

countPosInf(columns=None)#

Counts total number of SpecialValues.PosInf across columns

Parameters:
columnsstr | List[str], optional

Columns to count special values in, by default None

Returns:
Total number of SpecialValues.PosInf across columns
Parameters:

columns (str | List[str] | None) –

Return type:

int

countUndef(columns=None)#

Counts total number of SpecialValues.Undef across columns

Parameters:
columnsstr | List[str], optional

Columns to count special values in, by default None

Returns:
Total number of SpecialValues.Undef across columns
Parameters:

columns (str | List[str] | None) –

Return type:

int

property default_records#

Default records of an equation

property dimension#

The dimension of symbol

property domain#

List of domains given either as string (* for universe set) or as reference to the Set/Alias object

property domain_forwarding#

A boolean indicating whether domain forwarding is enabled

property domain_labels#

The column headings for the records DataFrame

property domain_names#

String version of domain names

property domain_type#

State of the domain links

dropDefaults()#

Drop records that are set to GAMS default records (check .default_records property for values)

Return type:

None

dropDomainViolations()#

drop records from the symbol that contain a domain violation

dropDuplicateRecords(keep='first')#

Drop records with (case insensitive) duplicate domains from the symbol

Parameters:
keepstr | bool, optional

keep argument can take values of “first” (keeps the first instance of a duplicate record), “last” (keeps the last instance of a record), or False (drops all duplicates including the first and last), by default “first”

Parameters:

keep (str | bool) –

Return type:

None

dropEps()#

Drop records from the symbol that are GAMS EPS (zero 0.0 records will be retained)

Return type:

None

dropMissing()#

Drop records from the symbol that are NaN (includes both NA and Undef special values)

Return type:

None

dropNA()#

Drop records from the symbol that are GAMS NA

Return type:

None

dropUndef()#

Drop records from the symbol that are GAMS Undef

Return type:

None

equals(other, columns=None, check_uels=True, check_meta_data=True, rtol=None, atol=None, verbose=False)#

Used to compare the symbol to another symbol

Parameters:
otherVariable

_description_

columnsstr, optional

allows the user to numerically compare only specified variable attributes, by default None; compare all

check_uelsbool, optional

If True, check both used and unused UELs and confirm same order, otherwise only check used UELs in data and do not check UEL order. by default True

check_meta_databool, optional

If True, check that symbol name and description are the same, otherwise skip. by default True

rtolint | float, optional

relative tolerance, by default None

atolint | float, optional

absolute tolerance, by default None

verbosebool, optional

If True, will return an exception from the asserter describing the nature of the difference. by default False

Returns:
bool

True if symbols are equal, False otherwise

Parameters:
  • other (Variable) –

  • columns (str) –

  • check_uels (bool) –

  • check_meta_data (bool) –

  • rtol (int | float | None) –

  • atol (int | float | None) –

  • verbose (bool) –

Return type:

bool

findDomainViolations()#

Get a view of the records DataFrame that contain any domain violations

Returns:
Optional[pd.DataFrame]

Records DataFrame that contain any domain violations

Return type:

DataFrame | None

findDuplicateRecords(keep='first')#

Get a view of the records DataFrame that contain any (case insensitive) duplicate domains – keep argument can take values of “first” (finds all duplicates while keeping the first instance as unique), “last” (finds all duplicates while keeping the last instance as unique), or False (finds all duplicates)

Parameters:
keepstr | bool, optional

Argument ‘keep’ must be either ‘first’ (returns duplicates except for the first occurrence), ‘last’ (returns duplicates except for the last occurrence), or False (returns all duplicates), by default “first”

Returns:
pd.DataFrame
Parameters:

keep (str | bool) –

Return type:

DataFrame

findEps(column=None)#

Find positions of SpecialValues.EPS in value column

Parameters:
columnstr, optional

Column to find the special values in, by default None

Returns:
pd.DataFrame

Dataframe containing special values

Parameters:

column (str | None) –

Return type:

DataFrame

findNA(column=None)#

Find positions of SpecialValues.NA in value column

Parameters:
columnstr, optional

Column to find the special values in, by default None

Returns:
pd.DataFrame

Dataframe containing special values

Parameters:

column (str | None) –

Return type:

DataFrame

findNegInf(column=None)#

Find positions of SpecialValues.NegInf in value column

Parameters:
columnstr, optional

Column to find the special values in, by default None

Returns:
pd.DataFrame

Dataframe containing special values

Parameters:

column (str | None) –

Return type:

DataFrame

findPosInf(column=None)#

Find positions of SpecialValues.PosInf in value column

Parameters:
columnstr, optional

Column to find the special values in, by default None

Returns:
pd.DataFrame

Dataframe containing special values

Parameters:

column (str | None) –

Return type:

DataFrame

findSpecialValues(values, column=None)#

Find positions of specified values in records columns

Parameters:
valuesfloat | List[float]

Values to look for

columnstr, optional

Column to find the special values in, by default None

Returns:
pd.DataFrame

Dataframe containing special values

Parameters:
  • values (float | List[float]) –

  • column (str | None) –

Return type:

DataFrame

findUndef(column=None)#

Find positions of SpecialValues.Undef in value column

Parameters:
columnstr, optional

Column to find the special values in, by default None

Returns:
pd.DataFrame

Dataframe containing special values

Parameters:

column (str | None) –

Return type:

DataFrame

generateRecords(density=None, func=None, seed=None)#

Convenience method to set standard pandas.DataFrame formatted records given domain set information. Will generate records with the Cartesian product of all domain sets.

Parameters:
densityint | float | list, optional

Takes any value on the interval [0,1]. If density is <1 then randomly selected records will be removed. density will accept a list of length dimension – allows users to specify a density per symbol dimension, by default None

funcCallable, optional

Functions to generate the records, by default None; numpy.random.uniform(0,1)

seedint, optional

Random number state can be set with seed argument, by default None

Parameters:
  • density (int | float | list | None) –

  • func (Callable | None) –

  • seed (int | None) –

Return type:

None

getDomainViolations()#

Returns a list of DomainViolation objects if any (None otherwise)

Returns:
Optional[DomainViolation]

List of DomainViolation objects if any (None otherwise)

Return type:

List[DomainViolation] | None

getMaxAbsValue(columns=None)#

Get the maximum absolute value across chosen columns

Parameters:
columnsstr | List[str], optional

Columns to find maximum absolute values in, by default None

Returns:
float

Maximum absolute value

Parameters:

columns (str | List[str] | None) –

Return type:

float

getMaxValue(columns=None)#

Get the maximum value across chosen columns

Parameters:
columnsstr | List[str], optional

Columns to find maximum values in, by default None

Returns:
float

Maximum value

Parameters:

columns (str | List[str] | None) –

Return type:

float

getMeanValue(columns=None)#

Get the mean value across chosen columns

Parameters:
columnsstr | List[str], optional

Columns to find mean values in, by default None

Returns:
float

Mean value

Parameters:

columns (str | List[str] | None) –

Return type:

float

getMinValue(columns=None)#

Get the minimum value across chosen columns

Parameters:
columnsstr | List[str], optional

Columns to find minimum values in, by default None

Returns:
float

Minimum value

Parameters:

columns (str | List[str] | None) –

Return type:

float

getSparsity()#

Get the sparsity of the symbol w.r.t the cardinality

Returns:
float

Sparsity of the symbol w.r.t the cardinality

Return type:

float

getUELs(dimensions=None, codes=None, ignore_unused=False, unique_only=False)#

Gets UELs from symbol dimensions. If dimensions is None then get UELs from all dimensions (maintains order). The argument codes accepts a list of str UELs and will return the corresponding int; must specify a single dimension if passing codes.

Parameters:
dimensionsint | list, optional

Symbols’ dimensions, by default None

codesint | list, optional

Symbols’ codes, by default None

ignore_unusedbool, optional

Flag to ignore unused UELs, by default False

unique_onlybool, optional

Flag to check only unique UELs, by default False

Returns:
List[str]

Only UELs in the data if ignore_unused=True, otherwise return all UELs.

Parameters:
  • dimensions (int | list | None) –

  • codes (int | list | None) –

  • ignore_unused (bool) –

  • unique_only (bool) –

Return type:

List[str]

hasDomainViolations()#

Returns True if there are domain violations in the records, returns False if not.

Returns:
bool

True if there are domain violations in the records, returns False if not.

Return type:

bool

hasDuplicateRecords()#

Returns True if there are (case insensitive) duplicate records in the symbol, returns False if not

Returns:
bool

True if there are (case insensitive) duplicate records in the symbol, returns False if not

Return type:

bool

property infeas#

Infeasability

Returns:
ImplicitParameter
isValid(verbose=False, force=False)#

Checks if the symbol is in a valid format

Parameters:
verbosebool, optional

Throw exceptions if verbose=True, by default False

forcebool, optional

Recheck a symbol if force=True, by default False

Returns:
bool

True if a symbol is in valid format, False otherwise (throws exceptions if verbose=True)

Parameters:
  • verbose (bool) –

  • force (bool) –

Return type:

bool

property is_scalar: bool#

Returns True if the len(self.domain) = 0

Returns:
bool

True if the len(self.domain) = 0

ljustUELs(length, fill_character=None, dimensions=None)#

Will left justify all UELs in the symbol or a subset of specified dimensions, can be chained with other *UELs string operations

Parameters:
lengthint
fill_characterstr, optional

Characters to fill in the empty, by default None

dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:
  • length (int) –

  • fill_character (str | None) –

  • dimensions (int | List[int] | None) –

lowerUELs(dimensions=None)#

Will lowercase all UELs in the parent symbol or a subset of specified dimensions in the parent symbol, can be chain with other *UELs string operations

Parameters:
dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:

dimensions (int | List[int] | None) –

lstripUELs(dimensions=None)#

Will left strip whitespace from all UELs in the parent set or a subset of specified dimensions in the parent set, can be chain with other *UELs string operations

Parameters:
dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:

dimensions (int | List[int] | None) –

property name#

Name of symbol

property number_records#

Number of records

pivot(index=None, columns=None, value=None, fill_value=None)#

Convenience function to pivot records into a new shape (only symbols with >1D can be pivoted)

Parameters:
indexstr | list, optional

If index is None then it is set to dimensions [0..dimension-1], by default None

columnsstr | list, optional

If columns is None then it is set to the last dimension, by default None

valuestr, optional

If value is None then the level values will be pivoted, by default None

fill_valueint | float | str, optional

Missing values in the pivot will take the value provided by fill_value, by default None

Returns:
DataFrame

Pivoted records dataframe

Parameters:
  • index (str | list | None) –

  • columns (str | list | None) –

  • value (str | None) –

  • fill_value (int | float | str | None) –

Return type:

DataFrame

removeUELs(uels=None, dimensions=None)#

Removes UELs that appear in the symbol dimensions, If uels is None then remove all unused UELs (categories). If dimensions is None then operate on all dimensions.

Parameters:
uelsdict | list | str

List of UELs (case-sensitive) that appear in the symbol dimensions

dimensionsint | list, optional

Symbols’ dimensions, by default None

Parameters:
  • uels (dict | list | str | None) –

  • dimensions (int | list | None) –

Return type:

None

renameUELs(uels, dimensions=None, allow_merge=False)#

Renames UELs (case-sensitive) that appear in the symbol dimensions. If dimensions is None then operate on all dimensions of the symbol. ** All trailing whitespace is trimmed **

Parameters:
uelsdict | list | str

List of UELs (case-sensitive) that appear in the symbol dimensions

dimensionsint | list, optional

Symbols’ dimensions, by default None

allow_mergebool, optional

If True, the categorical object will be re-created to offer additional data flexibility. By default False

Parameters:
  • uels (dict | list | str) –

  • dimensions (int | list | None) –

  • allow_merge (bool) –

Return type:

None

reorderUELs(uels=None, dimensions=None)#

Reorders the UELs in the symbol dimensions. If uels is None, reorder UELs to data order and append any unused categories. If dimensions is None then reorder UELs in all dimensions of the symbol.

Parameters:
uelsstr | List[str], optional

List of UELs, by default None

dimensionsint | list, optional

Symbol dimensions, by default None

Parameters:
  • uels (str | List[str] | None) –

  • dimensions (int | list | None) –

Return type:

None

rjustUELs(length, fill_character=None, dimensions=None)#

Will right justify all UELs in the symbol or a subset of specified dimensions, can be chained with other *UELs string operations

Parameters:
lengthint
fill_characterstr, optional

Characters to fill in the empty, by default None

dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:
  • length (int) –

  • fill_character (str | None) –

  • dimensions (int | List[int] | None) –

rstripUELs(dimensions=None)#

Will right strip whitespace from all UELs in the parent set or a subset of specified dimensions in the parent set, can be chain with other *UELs string operations

Parameters:
dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:

dimensions (int | List[int] | None) –

setUELs(uels, dimensions=None, rename=False)#

Set the UELs for symbol dimensions. If dimensions is None then set UELs for all dimensions. ** All trailing whitespace is trimmed **

Parameters:
uelsstr | List[str]

List of UELs (case-sensitive) that appear in the symbol dimensions

dimensionsint | list, optional

Symbols’ dimensions, by default None

renamebool, optional

If True, the old UEL names will be renamed with the new UEL names. By default False

Parameters:
  • uels (str | List[str]) –

  • dimensions (int | list | None) –

  • rename (bool) –

Return type:

None

property shape: tuple#

Returns a tuple describing the array dimensions if records were converted with .toDense()

Returns:
tuple

A tuple describing the records dimensions

stripUELs(dimensions=None)#

Will strip whitespace from all UELs in the parent set or a subset of specified dimensions in the parent set, can be chain with other *UELs string operations

Parameters:
dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:

dimensions (int | List[int] | None) –

property summary#

Summary of the symbol

titleUELs(dimensions=None)#

Will title (capitalize all individual words) in all UELs in the Container or a subset of specified symbols, can be chained with other *UELs string operations

Parameters:
dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:

dimensions (int | List[int] | None) –

toDense(column='level')#

Convert column to a dense numpy.array format

Parameters:
columnstr, optional

The column to convert, by default “level”

Returns:
np.ndarray, optional

A column to a dense numpy.array format

Parameters:

column (str) –

Return type:

ndarray | None

toDict(columns=None, orient=None)#

Convenience method to return symbol records as a Python dictionary

Parameters:
columnsstr, optional

Controls which attributes to include in the dict, by default None

orientstr, optional

Orient can take values natural or columns and will control the shape of the dict. Must use orient=”columns” if attempting to set symbol records with setRecords, by default None

Returns:
dict

Records as a Python dictionary

Parameters:
  • columns (str | None) –

  • orient (str | None) –

Return type:

dict

toList(columns=None)#

Convenience method to return symbol records as a Python list

Parameters:
columnsstr, optional

Controls which attributes to include in the list, by default None

Returns:
list

Records as a Python list

Parameters:

columns (str | None) –

Return type:

list

toSparseCoo(column='level')#

Convert column to a sparse COOrdinate numpy.array format

Parameters:
columnstr, optional

The column to convert, by default “level”

Returns:
coo_matrix, optional

A column in coo_matrix format

Parameters:

column (str) –

Return type:

coo_matrix | None

toValue(column=None)#

Convenience method to return symbol records as a Python float. Only possible with scalar symbols

Parameters:
columnstr, optional

Attribute can be specified with column argument, by default None

Returns:
float

Value of the symbol

Parameters:

column (str | None) –

Return type:

float

upperUELs(dimensions=None)#

Will uppercase all UELs in the parent symbol or a subset of specified dimensions in the parent symbol, can be chain with other *UELs string operations

Parameters:
dimensionsint | List[int], optional

Symbols’ dimensions, by default None

Parameters:

dimensions (int | List[int] | None) –

whereMax(column=None)#

Find the domain entry of records with a maximum value (return first instance only)

Parameters:
columnstr, optional

Columns to find maximum values in, by default None

Returns:
List[str]

List of symbol names where maximum values exist

Parameters:

column (str | None) –

Return type:

List[str]

whereMaxAbs(column=None)#

Find the domain entry of records with a maximum absolute value (return first instance only)

Parameters:
columnstr, optional

Columns to find maximum absolute values in, by default None

Returns:
List[str]

List of symbol names where maximum absolute values exist

Parameters:

column (str | None) –

Return type:

List[str]

whereMin(column=None)#

Find the domain entry of records with a minimum value (return first instance only)

Parameters:
columnstr, optional

Columns to find minimum values in, by default None

Returns:
List[str]

List of symbol names where minimum values exist

Parameters:

column (str | None) –

Return type:

List[str]

property records#

Records of the Equation

Returns:
DataFrame
setRecords(records, uels_on_axes=False)[source]#

Main convenience method to set standard pandas.DataFrame formatted records

Parameters:
recordsAny

Records to set for the symbol

uels_on_axesbool, optional

If True, setRecords will assume that all domain information is contained in the axes of the pandas object – data will be flattened (if necessary), by default False

Parameters:
  • records (Any) –

  • uels_on_axes (bool) –

Return type:

None

property type#

The type of equation; 3. ‘regular’ – equal, less than or greater than 4. ‘nonbinding’, ‘N’, or ‘=N=’ – nonbinding relationship 5. ‘cone’, ‘C’, or ‘=C=’ – cone equation 6. ‘external’, ‘X’, or ‘=X=’ – external equation 7. ‘boolean’, ‘B’, or ‘=B=’ – boolean equation

Returns:
str

The type of equation

gamsRepr()[source]#

Representation of this Equation in GAMS language.

Returns:
str
Return type:

str

getStatement()[source]#

Statement of the Equation declaration

Returns:
str
Return type:

str

class gamspy.EquationType(value)[source]#

Bases: Enum

An enumeration.

REGULAR = 'REGULAR'#
NONBINDING = 'NONBINDING'#
EXTERNAL = 'EXTERNAL'#
CONE = 'CONE'#
BOOLEAN = 'BOOLEAN'#
classmethod values()[source]#

Convenience function to return all values of enum