optimization problem with arrays
2 次查看(过去 30 天)
显示 更早的评论
Hello, I am trying to create a problem based optimization problem for minimazing.
To summer it up, I want to do this optimization and I don't know how to do what I have in bold:
array1 = array2 - array3 .* (optimization_variable);
A=sum(array1(array1>0));
objective = A;
Is there any way to put conditionals in an optimization problem?
Thanks in advance
0 个评论
采纳的回答
Bruno Luong
2022-12-7
编辑:Bruno Luong
2022-12-7
Could you try this equivalent expression
A=sum(array1.*(array1>0));
3 个评论
Bruno Luong
2022-12-7
编辑:Bruno Luong
2022-12-7
May be you should relax the if test and replace it with one of the sigmodid function
S = @(x) atan(x)/(pi/2); % select the function you want
scale = ... ; small number appropriate for array1.
A = sum(array1.*((S(array1/scale)+1)/2));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Programming and Mixed-Integer Linear Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!