fmincon with full multiple

6 次查看(过去 30 天)
Hey guys,
is there a way to get only whole numbers with fmincon? I want only full multiples of 1 as a result.
ceq = mod(x1,1);
I tried modulo, but fmincon will give me my starting position as a result.

采纳的回答

John D'Errico
John D'Errico 2017-6-2
编辑:John D'Errico 2017-6-2
FMINCON REQUIRES a continuous, differentiable objective function (and constraints).
If you use mod inside the objective function, or discretize something inside like that in any way (perhaps using round or floor), then your function is not at all continuous nor is it differentiable. So FMINCON must fail on your objective.
FMINCON has no capability to allow integer valued parameters in any way.
If you insist on the use of FMINCON, at best you could remove the mod from inside your function, then round the result afterwards. There is no assurance the result will be truly optimal then, but that is the best you can do using FMINCON.
You cannot use FMINCON to solve your problem. I believe some other tools, such as GA from the Global optimization toolbox, can do what you wish.

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by