Borrar filtros
Borrar filtros

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

8 visualizaciones (últimos 30 días)
Zejun Xiang
Zejun Xiang el 27 de Oct. de 2016
Comentada: Math Works el 29 de Jul. de 2022
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?

Respuestas (2)

John D'Errico
John D'Errico el 27 de Oct. de 2016
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 comentarios
Walter Roberson
Walter Roberson el 27 de Oct. de 2016
ga() allows integer constraints, but when you have an integer constraint it does not allow nonlinear constraints.
Abdolkarim Mohammadi
Abdolkarim Mohammadi el 14 de Ag. de 2019
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.

Iniciar sesión para comentar.


Math Works
Math Works el 28 de Jul. de 2022
Is there an equivalent integer one that doesn't define f as vectors?
  13 comentarios
Walter Roberson
Walter Roberson el 29 de Jul. de 2022
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 el 29 de Jul. de 2022
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by