Mixed integer optimization gives infeasible solutions if trying to maximise an objective it was already able to minimize.
1 次查看(过去 30 天)
显示 更早的评论
I'm attempting to verify some properties of neural networks using mixed integer optimization but am struggling to see why my constraints aren't working. This is my problem:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259927/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259928/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259929/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259930/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259931/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259932/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259933/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259934/image.png)
I approximated the last constraint using a binary variable a and other inequalties, as it is non linear:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259935/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259936/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259937/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259938/image.png)
and if
or if
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259939/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259940/image.png)
I implemented this using the following code (I've included the full function in the attachments):
constraints.c1 = z_1_hat== W{1}*z_0+b{1};
constraints.c2 = z_2_hat== W{2}*z_1+b{2};
constraints.c3 = z_1>=0;
constraints.c4 = z_1>=z_1_hat;
constraints.c5 = optimconstr(size(Z_max{1}));
constraints.c6 = optimconstr(size(Z_max{1}));
for j=1:size(Z_max{1})
if Z_hat_max{1}(j)<=0
constraints.c5(j) = z_1(j)<=0; constraints.c6(j) = z_1(j)<=0;
elseif Z_hat_min{1}(j)>=0
constraints.c5(j) = z_1(j)<=z_1_hat(j); constraints.c6(j) = z_1(j)<=z_1_hat(j);
else
constraints.c5(j) = z_1(j)<=z_1_hat(j)-Z_hat_min{1}(j)*(1-a1(j));
constraints.c6(j) = z_1(j)<=Z_hat_max{1}(j)*a1(j);
end
end
It does provide feasible solutions as expected for several "properties", but for others it is unable to either maximise the cost function (even though it is able to minimise it) or vice versa. I'm not sure why this is happening because I am pretty certain my constraints are well defined. I've included the two functions required to run the code and 2 property.mat files that fail to give feasible solutions and two that do give feasible solutions. If anyone can explain why my code is failing I would appreciate it greatly.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Robust Control Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!