Search for optimal values of variables

6 ビュー (過去 30 日間)
Fawad Farooq Ashraf
Fawad Farooq Ashraf 2021 年 6 月 1 日
回答済み: Fawad Farooq Ashraf 2021 年 6 月 1 日
I have two parameters c1 & c2 as variables which I pass to a function and it returns x as 0 or 1 (not logical operators but values). It returns 0 for most cases but for very few cases, specific values of c1 & c2 return x = 1 satisfying certain conditions.
How can I use MATLAB to automatically search for those values of c1 and c2 (bounded in an interval). Using a while loop by varying c1,c2 randomly isn't helping. I tried fminsearch, fmincon and lsqnonlin but they all converge to an infeasible point right at the start and I dont know the reason.
I want my code to find such values of c1, c2 which satisfy x = 1 in an optimal way. Can anybody help?
  1 件のコメント
LO
LO 2021 年 6 月 1 日
can you post an example of your code ? it would be easier to know what you mean

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

採用された回答

Fawad Farooq Ashraf
Fawad Farooq Ashraf 2021 年 6 月 1 日
I figured this out. And I'd share how i did it, in case anyone else encounters the same problem.
I used fmincon with objective function as 0 and equality constraints equal to the conditions at which x became 1.
That solved my problem.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by