decogo.model.block_model

Main module for storing model data.

Classes

BlockModel(blocks, sense, cuts, sub_models)

This class stores sub-models and cut pool.

PyomoBlockModel(model, blocks, sense)

This class takes Pyomo model and stores sub-models and cut pool derived from the Pyomo model.

class decogo.model.block_model.BlockModel(blocks, sense, cuts, sub_models)[source]

This class stores sub-models and cut pool.

Parameters
  • blocks (list) – List (block-wise) of original string names of variables

  • sense (int) – Indicates the the problem is minimization (1) or maximization (-1)

  • cuts (PyomoCutPool) – Container which stores all linear constraints (global and local) and objective function

  • sub_models (list) – List of sub-models

__init__(blocks, sense, cuts, sub_models)[source]

Constructor method

get_non_zero_resources()[source]

Determines the indices of nonzero resources blockwise, i.e. checks whether left-hand side of the coupling constraints is nonzero, i.e. \(A_k \neq 0\)

Returns

indices of nonzero resources of nonzero

Return type

dict

eval_viol_lin_global_constraints(point)[source]

Evaluates the violation of global linear constraints, see model.constraints.PyomoCutPool.evaluate_violation_global_constraints()

trans_into_orig_space(block_id, direction)[source]

Computes \(d_k^TA_k, d_k \in \mathbb{R}^{m+1}\), where \(m\) is the number of global constraints

Parameters
  • block_id (int) – Block identifier

  • direction (list or ndarray) – Array with dimension \(m+1\), where \(m\) is the number of global constraints

Returns

An array with the dimension of \(n_k\), where \(n_k\) is size of the k-th block

Return type

ndarray

trans_into_im_space(block_id, point)[source]

Compute \(w=A_kx_k\), where \(x_k \in \mathbb{R}^{n_k}\)

Parameters
  • block_id (int) – Block identifier

  • point (ndarray) – Point in the original space

Returns

Point w in the image space, i.e. \(w \in \mathbb{R}^{m+1}\)

Return type

ndarray

num_nonzero_m_k(block_id)[source]

Compute \(w=A_kx_k\), where \(x_k \in \mathbb{R}^{n_k}\)

Parameters
  • block_id (int) – Block identifier

  • point (ndarray) – Point in the original space

Returns

Point w in the image space, i.e. \(w \in \mathbb{R}^{m+1}\)

Return type

ndarray

print_model_stats()[source]

Computes and prints the statistics of the new block model, i.e. mean, min, max of the new block sizes

global_con_hyper_block(kt)[source]
class decogo.model.block_model.PyomoBlockModel(model, blocks, sense)[source]

This class takes Pyomo model and stores sub-models and cut pool derived from the Pyomo model.

Parameters
  • model (ConcreteModel) – Input Pyomo model

  • blocks (list) – List (block-wise) of original string names of variables

  • sense (int) – Indicates the the problem is minimization (1) or maximization (-1)

__init__(model, blocks, sense)[source]

Constructor method

compute_gradients()[source]

Computes gradients for nonlinear constraints

update_var_lower_bound(new_lower_bound, index)[source]

Updates the lower bound of the variable with the given index

update_var_upper_bound(new_upper_bound, index)[source]

Updates the upper bound of the variable with the given index

max_violation_nonlinear_constraints(x)[source]

Determines if the solution is feasible regarding the nonlinear constraints by computing the maximum violation

Parameters

x (BlockVector) – Given point

Returns

Maximum violation and index of most violated constraint as tuple (viol, block_id, index)

Return type

tuple

round(block_id, point)[source]

Rounds point to the closest integer

Parameters
  • block_id (int) – Block identifier

  • point (ndarray) – Given point

Returns

New rounded point

Return type

ndarray