Find the minimum positive value between two decisions variables in MILP Environment and big-M method
1 件のコメント
回答 (1 件)
Hi @Edoardo Beduglio,
To achieve your objective of calculating the positive minimum value between (A) and (B) over 16 consecutive time steps while maintaining constraints, you need to adjust the way we handle the constraints involving the binary variables (z_1) and (z_2). You want to ensure that if either A(t,d) or (B(t,d) has a positive value, then (D(k,d) should reflect the smallest positive value. If both are zero, you want (D(k,d) to also be zero. Here is how you can reformulate your constraints:
for k = 1: T/16 t_start = 16*(k-1) + 1 : k*16 ; for t = t_start mincons1(t,d) = D(k,d) <= A(t,d) + M * (1 - z1(t,d)); mincons2(t,d) = D(k,d) <= B(t,d) + M * (1 - z2(t,d));
% Ensure D(k,d) is set to zero if both A and B are zero mincons3(t,d) = z1(t,d) + z2(t,d) >= 1; % At least one must be positive end end
Here, (M) is a large constant. The constraint mincons3 ensures that at least one of the binary variables must be activated if both decision variables are non-zero. Now to make sure that when both values are zero, you correctly set (D(k,d), you can introduce another binary variable, say (z3(t,d)) which indicates whether both A(t,d) and B(t,d) are zero:
z3(t,d) = (A(t,d)==0 & B(t,d)==0);
Then modify your constraints accordingly:
D(k,d) <= M * (1 - z3(t,d)); % If both are zero, D must also be zero.
Since your objective function focuses on profit maximization involving (x), (y)and (D)you should ensure that while maximizing profit, it does not inadvertently drive your decision variables (A) and (B) to zero. Consider adding penalties or rewards in your objective function that account for maintaining non-zero values in either of those matrices. Here is a simplified version of how your loop might look:
for k = 1: T/16 t_start = 16*(k-1)+1 : k*16; for t = t_start % Minimum constraints mincons1(t,d) = D(k,d) <= A(t,d) + M * (1 - z1(t,d)); mincons2(t,d) = D(k,d) <= B(t,d) + M * (1 - z2(t,d));
% Both A and B cannot be zero at the same time without affecting D mincons3(t,d) = z1(t,d) + z2(t,d) >= 1; end end
When tuning parameters, make sure that the constant (M) is appropriately chosen; it should be large enough to not constrain feasible solutions but not excessively large as it may lead to numerical instability in optimization.
Depending on the solver you are using, you might need to experiment with different formulations or settings to achieve optimal performance without unintended consequences on variable values.
By carefully structuring your constraints and handling edge cases effectively, you can ensure that your MILP formulation accurately captures the desired behavior of your decision variables while still achieving your overall objective of profit maximization.
Hope this helps.
0 件のコメント
参考
カテゴリ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!