gana.sets.variable#

Continuous Variable

Functions

display(*objs[, include, exclude, metadata, ...])

Display a Python object in all frontends.

draw(element[, data, kind, font_size, ...])

Plot the variable set

make_P(inp[, index])

Make input into a parameter set (P)

make_T(inp[, index])

Make input into a theta set (T)

Classes

C(function[, leq, parent, pos, nn, category])

Represents a relationship between Parameters, Variables, or Expressions.

Elem(*values)

Type of function

F([one, two, one_type, two_type, mul, add, ...])

Provides relational operations between parameter, variable, parametric variable, or function sets (F).

FCase(*values)

function cases

I(*members[, size, start, mutable, tag, ...])

Set of index elements (X).

Math([data, url, filename, metadata])

V(*index[, itg, nn, bnr, mutable, tag, ltx, ...])

Ordered set of variables (Var).

product(*iterables[, repeat])

Cartesian product of input iterables.

class V(*index: I, itg: bool = False, nn: bool = True, bnr: bool = False, mutable: bool = False, tag: str = '', ltx: str = '', name: str = '')[source]#

Bases: _E

Ordered set of variables (Var).

Parameters:
  • index (I or tuple[I], optional) – Indices. Defaults to None.

  • itg (bool, optional) – If the variable set is integer. Defaults to False.

  • nn (bool, optional) – If the variable set is non-negative. Defaults to True.

  • bnr (bool, optional) – If the variable set is binary. Defaults to False.

  • mutable (bool, optional) – If the variable set is mutable. Defaults to False.

  • tag (str) – Tag/details

  • ltx (str) – LaTeX representation of the variable set.

Variables:
  • index (I) – Index of the variable set (product of all indices)

  • map (dict[I, V]) – Index to variable mapping

  • _ (list[V]) – List of variables in the set

  • itg (bool) – Integer variable set flag

  • nn (bool) – Non-negative variable set flag

  • bnr (bool) – Binary variable set flag

  • mutable (bool) – Mutable variable set flag

  • tag (str) – Tag/details

  • name (str) – Name, set by the program

  • n (int) – Number id, set by the program

  • args (dict[str, bool]) – Arguments for making similar variable sets

  • ltx (str) – LaTeX representation of the variable set

Raises:
  • ValueError – If variable is binary and not non-negative

  • ValueError – Multiplication by tuple or list of tuples

  • ValueError – Division by None, tuple, or list of tuples

  • ZeroDivisionError – Division by zero

  • ValueError – Division of something by a variable

  • ValueError – Raising variable to a power, except 0 or 1

property matrix: dict#

Matrix Representation

property args: dict[str, str | bool]#

Return the arguments of the variable set

property A: list[list[float]]#

Generate a diagonal matrix representation of the variable set

property features_in: list[C | O]#

Constraints and objectives that this variable set is part of

make_function() F[source]#

Make a function

Returns:

Function representing the variable set

Return type:

F

copy() V[source]#

Returns a copy of the variable set

Returns:

Copy of the variable set

Return type:

V

birth_variables(mutating: bool = False, n_start: int = 0)[source]#

Births a variable at every index in the index set

Parameters:
  • mutating (bool, optional) – If the variable set is being mutated. Defaults to False.

  • n_start (int, optional) – The starting number for positioning the variables. Defaults to 0.

output(n_sol: int = 0, aslist: bool = False, asdict: bool = False, compare=False) list[float] | dict[tuple[I, ...], float] | None[source]#

Solution

Parameters:
  • n_sol (int, optional) – Solution number. Defaults to 0.

  • aslist (bool, optional) – Returns values taken as list. Defaults to False.

  • asdict (bool, optional) – Returns values taken as dictionary. Defaults to False.

  • compare (bool, optional) – Displays a comparison of the solutions across multiple objectives. Defaults to False.

Returns:

Solution values

Return type:

list[float] | dict[tuple[I, …], float] | None

f_eval(*values: float | int, n_sol: int = 0, n_cr: int = 0) float[source]#

Evaluates the variable value as a function of parametric variables

Parameters:
  • values (float | int) – values of the parametric variables

  • n_sol (int, optional) – Solution number. Defaults to 0.

  • n_cr (int, optional) – Critical region number. Defaults to 0.

Returns:

evaluated value

Return type:

float

eval(*theta_vals: float, n_sol: int = 0) float | None[source]#

Evaluates the variable value as a function of parametric variables

Parameters:
  • theta_vals (float) – values of the parametric variables

  • n_sol (int, optional) – solution number. Defaults to 0.

  • roundoff (int, optional) – round off the evaluated value. Defaults to 4.

Returns:

evaluated value

Return type:

float | None

property ltx: str#

LaTeX representation

property index_ltx: str#

LaTeX representation of the index

latex() str[source]#

LaTeX representation :returns: LaTeX representation of the variable set :rtype: str

show(descriptive: bool = False)[source]#

Display the variables

Parameters:

descriptive (bool, optional) – Print members of the index set

mps() str[source]#

Name in MPS file

Returns:

Name in MPS file

Return type:

str

lp() str[source]#

LP representation

Returns:

LP representation

Return type:

str

property longname: str#

Long name

report() V[source]#

Return a reporting binary variable

Returns:

Reporting binary variable

Return type:

V

line(font_size: float = 16, fig_size: tuple[float, float] = (12, 6), linewidth: float = 0.7, color: str = 'blue', grid_alpha: float = 0.3, usetex: bool = True, str_idx_lim: int = 10)[source]#

Plot the variable set

Parameters:
  • font_size (float, optional) – Font size for the plot. Defaults to 16.

  • fig_size (tuple[float, float], optional) – Size of the figure. Defaults to (12, 6).

  • linewidth (float, optional) – Width of the line in the plot. Defaults to 0.7.

  • color (str, optional) – Color of the line in the plot. Defaults to ‘blue’.

  • grid_alpha (float, optional) – Transparency of the grid lines. Defaults to 0.3.

  • usetex (bool, optional) – Use LaTeX for text rendering. Defaults to True.

  • str_idx_lim (int, optional) – Limit for string indices display. Defaults to 10.

bar(font_size: float = 16, fig_size: tuple[float, float] = (12, 6), linewidth: float = 0.7, color: str = 'blue', grid_alpha: float = 0.3, usetex: bool = True, str_idx_lim: int = 10)[source]#

Plot the variable set

Parameters:
  • font_size (float, optional) – Font size for the plot. Defaults to 16.

  • fig_size (tuple[float, float], optional) – Size of the figure. Defaults to (12, 6).

  • linewidth (float, optional) – Width of the line in the plot. Defaults to 0.7.

  • color (str, optional) – Color of the line in the plot. Defaults to ‘blue’.

  • grid_alpha (float, optional) – Transparency of the grid lines. Defaults to 0.3.

  • usetex (bool, optional) – Use LaTeX for text rendering. Defaults to True.

  • str_idx_lim (int, optional) – Limit for string indices display. Defaults to 10.