optimization problem with arrays

1 回表示 (過去 30 日間)
Gerard Burjalès
Gerard Burjalès 2022 年 12 月 7 日
編集済み: Bruno Luong 2022 年 12 月 7 日
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

採用された回答

Bruno Luong
Bruno Luong 2022 年 12 月 7 日
編集済み: Bruno Luong 2022 年 12 月 7 日
Could you try this equivalent expression
A=sum(array1.*(array1>0));
  3 件のコメント
Bruno Luong
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));
Gerard Burjalès
Gerard Burjalès 2022 年 12 月 7 日
Thanks for solving the issue and for the warm welcome in this community

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear 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!

Translated by