linopy.variables.Variables

linopy.variables.Variables#

class linopy.variables.Variables(data, model, _label_position_index=None)#

A variables container used for storing multiple variable arrays.

__init__(data, model, _label_position_index=None)#

Methods

__init__(data, model[, _label_position_index])

add(variable)

Add a variable to the variables container.

fix([value, decimals, overwrite])

Fix all variables in this container to their solution or a scalar value.

format_labels(values)

Get a string representation of a selection of variable labels.

get_blockmap([dtype])

Get a one-dimensional array mapping the variables to blocks.

get_label_position(values)

Get tuple of name and coordinate for variable labels.

get_label_position_with_index(label)

Get name, coordinate, and raw numpy index for a single variable label.

get_label_range(name)

Get starting and ending label for a variable.

get_name_by_label(label)

Get the variable name of the variable containing the passed label.

get_solver_attribute(attr)

Get an attribute from the solver model.

items()

print_labels(values)

Print a selection of labels of the variables.

relax()

Relax integrality of all integer/binary variables in this container.

remove(name)

Remove variable name from the variables.

reset_solution()

Reset the stored solution of variables.

set_blocks(blocks)

Get a dataset of same shape as variables.labels indicating the blocks.

unfix()

Unfix all variables in this container.

unrelax()

Restore integrality of all previously relaxed variables in this container.

Attributes

attrs

Get the attributes of all variables.

binaries

Get all binary variables.

continuous

Get all continuous variables.

coords

Get the coordinates of all variables.

dataset_attrs

dataset_names

fixed

Get all currently fixed variables.

flat

Convert all variables to a single pandas Dataframe.

indexes

Get the indexes of all variables.

integers

Get all integers variables.

labels

Get the labels of all variables.

lower

Get the lower bounds of all variables.

nvars

Get the number all variables effectively used by the model.

relaxed

Get all currently relaxed variables.

semi_continuous

Get all semi-continuous variables.

sizes

Get the sizes of all variables.

solution

Get the solution of variables.

sos

Get all variables involved in an sos constraint.

upper

Get the upper bounds of all variables.

data

model