How to specify the variables to be integers in fmincon function.

3 次查看(过去 30 天)
I need to solve a quadratically constrained program by fmincon with all variables restricted in integers. Is it possible to specify variable types in fmincon? If not, is there another way to solve this problem?

回答(2 个)

John D'Errico
John D'Errico 2016-10-27
You cannot do so. Period. fmincon does not allow integer constraints. To solve that class of problem, you need a integer programming tool, in this case, a nonlinear one. But NOT fmincon.
I believe the genetic optimization tools can allow integer constraints.
  2 个评论
Walter Roberson
Walter Roberson 2016-10-27
ga() allows integer constraints, but when you have an integer constraint it does not allow nonlinear constraints.
Abdolkarim Mohammadi
When you have integer variables in ga(), you can have linear and/or nonlinear inequality constraints. Integer ga() only prohibits linear and/or nonlinear equality constraints.

请先登录,再进行评论。


Math Works
Math Works 2022-7-28
Is there an equivalent integer one that doesn't define f as vectors?
  13 个评论
Walter Roberson
Walter Roberson 2022-7-29
Yes, you generate a set of integers, and then you treat those as locally constant and optimize over the other values. You get a best result for varying the other variables relative to that particular list of integers, and then you move on to the next list of integers, and repeat, keeping track of the best result as you go.
Math Works
Math Works 2022-7-29
Yes, that's exactly what I did.
Basically, every for-chain iteration step treats all the integer variables as constants, then do the local continuous constrained optimization problem. With some global tracker variables and helper functions, this can be implemented with some effort.
I still don't understand why MATLAB can't abstract this process though. Just ask for the boundries for the integer variables. Formulating the problem becomes harder when you need to think about the lower level implementations. At that point, I'm better off doing it in C++ directly.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Nonlinear Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by