app.conversion.conversion_utils
Conversion-specific utility functions for optimization problems.
This module contains utilities specifically for working with conversion functionality variables, constraints, and expressions.
create_empty_pulp_var(name, time_set_size)
Create a list of empty LpVariable with the specified name and time set size.
Parameters:
name : str Base name for the variables time_set_size : int Number of time steps to create variables for
Returns:
List[pulp.LpVariable] List of PuLP variables with non-negative bounds
handle_arithmetic_operator(operator, left_result, right_result)
Handle arithmetic operators for expression creation.
Parameters:
operator : Operator The arithmetic operator left_result : Any Left operand result right_result : Any Right operand result
Returns:
PuLP expression The resulting arithmetic expression
Raises:
ValueError If the operation violates linear programming constraints
handle_comparison_operator(operator, left_result, right_result)
Handle comparison operators for constraint creation.
Parameters:
operator : Operator The comparison operator left_result : Any Left operand result right_result : Any Right operand result
Returns:
PuLP constraint The resulting constraint
is_arithmetic_operator(operator)
Check if operator is an arithmetic operator.
Parameters:
operator : Operator The operator to check
Returns:
bool True if operator is an arithmetic operator
is_comparison_operator(operator)
Check if operator is a comparison operator.
Parameters:
operator : Operator The operator to check
Returns:
bool True if operator is a comparison operator
validate_linear_division(right_result)
Validate that division maintains linearity.
Parameters:
right_result : Any The divisor
Raises:
ValueError If divisor is a variable (non-linear)
validate_linear_multiplication(left_result, right_result)
Validate that multiplication maintains linearity.
Parameters:
left_result : Any Left operand right_result : Any Right operand
Raises:
ValueError If both operands are variables (non-linear)
warn_about_not_equal_constraint()
Warn user about complexity of not-equal constraints.