Introduction
When dealing with stochastic programming and Monte Carlo simulationbased scenario generation, you may encounter infeasible scenarios that complicate the optimization process. One effective strategy to address this issue is to modify the optimization model to handle infeasibility internally. This approach eliminates the need to adjust scenario probabilities on the fly and allows the optimization to proceed smoothly.
In this guide, I'll teach you how to apply this strategy, focusing on two main methods:
Introducing Penalty Terms or Slack Variables: Adjusting the model to allow for constraint violations at a cost.
Using Chance Constraints: Replacing hard constraints with probabilistic ones that can tolerate a small acceptable level of constraint violation.
We'll go through each method in detail, explaining the concepts, providing mathematical formulations, and illustrating with examples in the context of the Stochastic Knapsack Problem.
1. Introducing Penalty Terms or Slack Variables
Concept Overview
Goal: Allow the model to handle infeasible scenarios internally by permitting constraint violations but penalizing them in the objective function.
How It Works:
Slack Variables: Add variables to represent the extent of constraint violations (slack or surplus) and include associated penalties in the objective function.
Penalty Terms: Directly incorporate penalties for constraint violations into the objective function.
This approach ensures that the optimization process considers the cost of violating constraints and seeks solutions that minimize both the original objective and the penalties.
Applying Penalty Terms to the Stochastic Knapsack Problem
Original Stochastic Knapsack Model
Let's recall the original formulation:

Decision Variables:
 $x_i \in {0, 1}$ : Whether to include item $i$ in the knapsack.

Parameters:
 $v_i^s$ : Value of item $i$ in scenario $s$ .
 $w_i^s$ : Weight of item $i$ in scenario $s$ .
 $W$ : Knapsack capacity.
 $p_s$ : Probability of scenario $s$ .
Objective Function:
 Constraints:
Modified Model with Penalty Terms
We introduce penalties for exceeding the knapsack capacity in any scenario.

Additional Variables:
 $\delta_s \geq 0$ : Amount by which the capacity constraint is violated in scenario $s$ .
Modified Constraints:

Penalizing Constraint Violations:
 We add a penalty term to the objective function that includes the sum of $\delta_s$ multiplied by a penalty coefficient.

Penalty Coefficient:
 Let $M$ be a large positive number representing the penalty per unit of constraint violation.
Modified Objective Function:
Model Interpretation
The model seeks to maximize the expected total value of selected items while minimizing the expected penalty from constraint violations.
The penalty $M$ should be set high enough to discourage constraint violations unless absolutely necessary.
Implementation Steps

Set Penalty Coefficient $M$ :
 Choose an appropriate value for $M$ .
 $M$ should be large enough to make constraint violations undesirable but not so large that it causes numerical instability.

Modify Constraints:
 Add slack variables $\delta_s$ to the capacity constraints for each scenario.

Add Penalty Terms to Objective Function:
 Subtract the weighted penalty $M \delta_s$ in the objective function.

Adjust Variable Domains:
 Ensure that $\delta_s \geq 0$ for all scenarios.

Solve the Modified Optimization Problem:
 Use an appropriate optimization solver capable of handling the modified model.
Example
Let's work through a simplified example with numerical values.
Scenario Data:
Items: 2 items.
Scenarios: 3 scenarios.
Knapsack Capacity: $W = 10$ units.
Scenario $s$  $p_s$  $v_1^s$  $w_1^s$  $v_2^s$  $w_2^s$ 

1  0.333  7  6  5  5 
2  0.333  8  7  6  6 
3  0.333  6  8  4  7 
Original Constraints:
 Scenario 3 is infeasible because the minimum possible total weight ( $w_1^3 + w_2^3 = 8 + 7 = 15$ ) exceeds $W = 10$ .
Modified Model with Penalty Terms:
Introduce $\delta_s \geq 0$ for $s = 1, 2, 3$ .
Modified Constraints:
 Modified Objective Function:
 Let's set $M = 100$ .
Decision Variables:
$x_i \in {0, 1}$ for $i = 1, 2$ .
$\delta_s \geq 0$ for $s = 1, 2, 3$ .
Solving the Model:
 Use an optimization solver to find the values of $x_1, x_2, \delta_1, \delta_2, \delta_3$ that maximize $Z$ while satisfying the constraints.
Interpretation of Results:
The solver will likely select items that maximize total value while minimizing or avoiding penalties.
In Scenario 3, some penalty may be incurred if constraint violation is unavoidable.
Considerations When Using Penalty Terms

Choosing Penalty Coefficient $M$ :
 Too Small: The model may accept constraint violations too readily.
 Too Large: Numerical issues may arise, or the model may become too conservative.

Penalties Reflect Real Costs:
 If possible, set $M$ to reflect the actual cost or impact of violating the constraint.

Interpretability:
 Solutions with constraint violations should be acceptable within the context of the problem.
2. Using Chance Constraints
Concept Overview
Goal: Allow constraints to be violated in a controlled manner by requiring them to be satisfied with a specified probability level.
How It Works:
Chance Constraints: Constraints are reformulated to require that they are met in all but a small fraction $\epsilon$ of scenarios.
Probability Level: Decisionmakers set $\epsilon$ , the maximum acceptable probability of constraint violation.
Applying Chance Constraints to the Stochastic Knapsack Problem
Model Formulation
Decision Variables:
 $x_i \in {0, 1}$ : Decision variables for selecting items.
Parameters:
 As before: $v_i^s, w_i^s, W, p_s$ .
Chance Constraint:
 Require that the capacity constraint is satisfied with at least probability $1  \epsilon$ :
 This means that the weight constraint can be violated in at most $\epsilon \times 100\%$ of the scenarios.
Reformulating the Chance Constraint
 Since we have a discrete set of scenarios, the chance constraint can be expressed as:
Where $S_{\text{feasible}}$ is the set of scenarios where the constraint is satisfied.
Integer Programming Formulation
Introduce binary variables $y_s$ to indicate whether the constraint is satisfied in scenario $s$ :
$y_s = 1$ if the constraint is satisfied in scenario $s$ .
$y_s = 0$ if the constraint is violated in scenario $s$ .
Modified Constraints:

Capacity Constraint with Indicator Variables:
$\sum_{i=1}^{n_{\text{items}}} w_i^s x_i \leq W + M (1  y_s), \quad \forall s = 1, 2, \dots, n$ $M$ is a large constant that effectively deactivates the constraint when $y_s = 0$ .

Chance Constraint:
$\sum_{s=1}^{n} p_s y_s \geq 1  \epsilon$
Objective Function: 
Maximize expected value as before:
$\text{Maximize } Z = \sum_{s=1}^{n} p_s \left( \sum_{i=1}^{n_{\text{items}}} v_i^s x_i \right)$
Variable Domains:$x_i \in {0, 1}$$y_s \in {0, 1}$
Explanation
For each scenario $s$ , if $y_s = 1$ , the capacity constraint must be satisfied.
If $y_s = 0$ , the capacity constraint can be violated.
The chance constraint ensures that the probability of scenarios where $y_s = 1$ (i.e., the constraint is satisfied) is at least $1  \epsilon$ .
Example
Using the same scenario data as before:
Scenario $s$  $p_s$  $v_1^s$  $w_1^s$  $v_2^s$  $w_2^s$ 

1  0.333  7  6  5  5 
2  0.333  8  7  6  6 
3  0.333  6  8  4  7 
Suppose we can accept a 10% chance of violating the capacity constraint ( $\epsilon = 0.10$ ).
Variables:
Constraints:

Capacity Constraints:
$6 x_1 + 5 x_2 \leq 10 + M (1  y_1)$$7 x_1 + 6 x_2 \leq 10 + M (1  y_2)$$8 x_1 + 7 x_2 \leq 10 + M (1  y_3)$ 
Chance Constraint:
$0.333 y_1 + 0.333 y_2 + 0.333 y_3 \geq 0.90$ 
Variable Domains:
$x_i \in {0, 1}$$y_s \in {0, 1}$
Objective Function:
 Same as before, without penalties:
M Value:
 Choose a sufficiently large $M$ to deactivate the constraint when $y_s = 0$ .
Solving the Model:
 Use an optimization solver that can handle mixedinteger programming problems.
Interpretation of Results:
The model will select $x_1$ and $x_2$ to maximize expected value while ensuring that the capacity constraint is satisfied in at least 90% of the total probability.
The capacity constraint can be violated in scenarios totaling up to 10% probability.
Considerations When Using Chance Constraints

Setting $\epsilon$ :
 Decide on the acceptable risk level for constraint violations based on practical considerations.

Computational Complexity:
 The model becomes a mixedinteger program, which may increase computational requirements.

Feasibility:
 Ensure that the model remains feasible under the specified chance constraint.
Comparing the Two Methods
Penalty Terms vs. Chance Constraints

Penalty Terms:
 Flexibility: Violations are penalized but allowed if they lead to a better overall objective value.
 Penalty Calibration: Requires careful selection of penalty coefficients.
 Objective Balance: Directly balances maximizing the objective and minimizing constraint violations.

Chance Constraints:
 Risk Control: Provides explicit control over the acceptable probability of constraint violations.
 Binary Decisions: Uses binary variables to enforce or relax constraints in specific scenarios.
 Complexity: May be more complex due to the introduction of additional binary variables.
Choosing Between Methods

Penalty Terms:
 Suitable when the cost of constraint violations can be quantified or estimated.
 Appropriate if occasional violations are acceptable and their impact is known.

Chance Constraints:
 Ideal when there is a need to limit the probability of constraint violations explicitly.
 Useful in risk management contexts where constraints must be satisfied with high confidence.
Implementation Tips
General Advice

Understanding the Context:
 Consider the practical implications of constraint violations in your specific problem.
 Understand whether penalties or controlled violation probabilities align better with decisionmaker preferences.

Solver Selection:
 Use optimization solvers capable of handling mixedinteger programming (e.g., CPLEX, Gurobi).
 Ensure the solver can handle the size and complexity of your modified model.

Parameter Tuning:
 Penalty Coefficient $M$ :
 Test different values to observe their impact on the solution.
 Avoid excessively large values that may cause numerical issues.
 Chance Constraint Level $\epsilon$ :
 Experiment with different risk levels to find one that balances feasibility and optimality.
Testing and Validation

SmallScale Testing:
 Start with a simplified version of your problem to test the modified model.

Scenario Analysis:
 Analyze how the solutions change with different penalty coefficients or chance constraint levels.

Sensitivity Analysis:
 Assess the sensitivity of the optimal solution to changes in parameters.

Feasibility Checks:
 Verify that the solutions satisfy constraints in the required proportion of scenarios.
Documentation

Model Assumptions:
 Clearly document assumptions made in modifying the model.

Parameter Choices:
 Record how penalty coefficients and chance constraint levels were selected.

Solution Interpretation:
 Provide interpretation of the results, especially regarding constraint violations.
Conclusion
By modifying your optimization model to handle infeasibility internally, you avoid the need to adjust scenario probabilities during optimization. Both introducing penalty terms or slack variables and using chance constraints are effective methods to achieve this.
Penalty Terms or Slack Variables enable the model to penalize constraint violations, balancing the objective value with the cost of violations.
Chance Constraints allow for a controlled level of constraint violations by specifying the acceptable probability of such events.
Implementing these methods involves adjusting your mathematical model, carefully selecting parameters, and using appropriate optimization solvers. By following the steps outlined above, you can apply these techniques to your stochastic programming problems and effectively manage infeasibility within your optimization model.
Top comments (0)