how to write or constrains optimization
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
my problem in how to write the syntx of equality constrains in optimization for thatcase
x(1) =50 OR x(1) =20
0 个评论
回答(1 个)
John D'Errico
2020-2-3
0 个投票
For which optimization tool? fmincon? You can't.
This essentially reduces to a discrete optimization problem. You can think of it as essentially a binary integer programming problem. Tools like fmincon cannot handle discrete variables. Period. fmincon assumes a continuously differentiable objective function of the parameters.
You can use the GA optimizer however. It allows discrete variables as an alternative.
And, of course, if you have only one variable that takes on just two possible levels, then you can make it even simpler - just run the optimization twice, setting x(1) in each case to 20 and then to 50. Take the better of the two solutions, and you have the optimal solution.
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!