Borrar filtros
Borrar filtros

Force fmincon to output interger values?

3 visualizaciones (últimos 30 días)
Brian
Brian el 31 de Oct. de 2012
Hello, thanks for reading this,
I am doing a minimization optimization homework problem using fmincon, and I was wondering how I can run the optimization using integer values instead of double values for my variables.
I have the project spread out around 3 functions, 1 defining the governing equation, 1 defining the constraints (all equality constraints) and the last bringing up the fmincon solver. I can get a minimization, and it makes sense mathematically, however I need the answer to be in integer values, i.e. x(1) = 1, x(2) = 5, ... instead of x(1) = 1.633, x(2) = 3.1223, etc.
I can provide my code if necessary.
Thanks for your help!

Respuesta aceptada

Matt J
Matt J el 31 de Oct. de 2012
Editada: Matt J el 1 de Nov. de 2012
You can use ROUND, FLOOR, CEIL, etc... to modify the FINAL output of FMINCON (not the output of your objective function), but FMINCON cannot constrain its search to the space of integer-valued solutions. You would need GA in the Global Optimization Toolbox for that.

Más respuestas (2)

Sean de Wolski
Sean de Wolski el 31 de Oct. de 2012
Editada: Sean de Wolski el 31 de Oct. de 2012
Note that using round/ceil/floor/ and friends this will introduce discontinuities and nonsmoothness into your Objective Function which fmincon algorithms are not designed to handle.
I would recommend either using ga() or following John's Advice in section 21 here:

Brian
Brian el 31 de Oct. de 2012
That was what I was worrying about.
So, I can round the answers I get, but I cannot put integers into the minimization and output integers. I will deal with what I have, then.
Thanks for your help!

Community Treasure Hunt

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

Start Hunting!

Translated by