jijzepttools.modeling.algorithm.dantzig_wolfe_decomposition.replace#
Functions#
Apply convex combination weights (u, p) to an expression. |
|
replace expression with separated indices |
|
replace problem with indices with non-overlapped conditions |
|
replace overlap constraint with separated indices |
Module Contents#
- apply_convex_combination_weights(expr: jijzepttools.modeling.utils.type.Expr, disjoint_forall_holder: jijzepttools.modeling.algorithm.dantzig_wolfe_decomposition.utils.DisjointForallHolder, forall: List[Tuple[jijmodeling.Element, jijzepttools.modeling.utils.type.Expr]], u: jijzepttools.modeling.utils.type.DecisionVar | None = None, p: jijmodeling.Element | None = None) jijzepttools.modeling.utils.type.Expr #
Apply convex combination weights (u, p) to an expression.
This function corresponds to the lambd=None case in Dantzig-Wolfe decomposition, where we apply column generation variables u[indices…, p] to the expression.
Note: This function assumes var_ref=[] for simplicity.
- Parameters:
expr – The expression to transform
disjoint_forall_holder – DisjointForallHolder instance
forall – List of forall indices
u – Convex combination weight variable (theta in Dantzig-Wolfe)
p – Column generation index
- Returns:
The transformed expression with u, p weights applied
- replace_expression_with_separated_indices(expr: jijzepttools.modeling.utils.type.Expr, disjoint_forall_holder: jijzepttools.modeling.algorithm.dantzig_wolfe_decomposition.utils.DisjointForallHolder, lambd: jijmodeling.Placeholder | None, forall: List[Tuple[jijmodeling.Element, jijzepttools.modeling.utils.type.Expr]], var_ref: List[jijmodeling.Subscript], u: jijzepttools.modeling.utils.type.DecisionVar | None = None, p: jijmodeling.Element | None = None) List[jijzepttools.modeling.utils.type.Expr] #
replace expression with separated indices the input expr is assume to be:
expression that containts only single type of decision variable
expression that is either a single term or SumOp term
this function returns a list of expressions that are separated by disjoint_forall_holder the strategy is as follows:
validate expr. if more than one decision variable is detected, raise ValueError
validate expr. if ProdOp is detected, raise ValueError
- Parameters:
expr (Expr) – expression to be replaced
disjoint_forall_holder (DisjointForallHolder) – disjoint forall holder
lambd (tp.Optional[jm.Placeholder]) – lambda placeholder (dual variable).
forall (tp.List[tp.Tuple[jm.Element, Expr]]) – forall indices.
var_ref (tp.List[jm.Subscript]) – variable references.
u (tp.Optional[jm_type.DecisionVar]) – convex combination weight variable (theta in Dantzig-Wolfe). When provided with p, transforms expressions to sum(p, u[indices…, p] * subproblem_expr).
p (tp.Optional[jm.Element]) – column generation index. Must be provided together with u.
- Returns:
replaced expressions
- Return type:
tp.List[Expr]
- replace_problem_with_separated_indices(problem: jijmodeling.Problem, disjoint_forall_holder: jijzepttools.modeling.algorithm.dantzig_wolfe_decomposition.utils.DisjointForallHolder, constraint_prefix: str, separable_exprs: List[jijzepttools.modeling.utils.type.Expr], manual_replace: Dict[str, Tuple[List[List[Tuple[jijmodeling.Element, jijzepttools.modeling.utils.type.Expr]] | None], List[Tuple[jijmodeling.Element, jijzepttools.modeling.utils.type.Expr]] | None]]) Tuple[jijmodeling.Problem, Tuple[List[List[str]], List[str]]] #
replace problem with indices with non-overlapped conditions
- Parameters:
problem (jm.Problem) – problem to be replaced
disjoint_forallconditions (tp.List[tp.List[Expr]]) – list of disjoint forall. Note that each condition must be a disjoint condition (no overlapped elements).
constraint_prefix (str) – prefix of constraint name
separable_exprs (tp.List[Expr]) – separable expressions
manual_replace (tp.Dict[str, tp.Tuple[tp.List[tp.List[tp.Tuple[jm.Element, Expr]]], tp.List[tp.List[tp.Tuple[jm.Element, Expr]]]]], optional) – manual replace. Defaults to {}.
- Returns:
replaced problem and replaced constraint names. The first element of the tuple is a list of separable constraints. The second element of the tuple is a list of overlapped constraints.
- Return type:
tp.Tuple[jm.Problem, tp.Tuple[tp.List[tp.List[str]], tp.List[str]]]
- replace_overlapped_constraint(constraint: jijmodeling.Constraint, overlapped_forall_list: List[List[Tuple[jijmodeling.Element, jijzepttools.modeling.utils.type.Expr]]]) List[jijmodeling.Constraint] #
replace overlap constraint with separated indices
- Parameters:
constraint (jm.Constraint) – constraint to be replaced
forall_list (tp.List[tp.List[tp.Tuple[jm.Element, Expr]]]) – list of forall indices
- Returns:
replaced constraints
- Return type:
tp.List[jm.Constraint]