In simulannealbnd solver can we use integer data type?

I want to use integer data type in simulannealbnd solver. Is there any way out to do the same?

Answers (2)

No, that optimizer has no way of handling discrete inputs.
If you want to experiment you could try the following strategy (that will probably not work at all well):
  • do not use a direct input variable. Instead, use an input variable with lower bound 1.0 and an upper bound 1+delta where delta = (largest desired integer minus lowest desired integer) divided by 2^53
  • set the options so that the minimum step size is eps(1)
  • inside the function take the input, subtract 1.0, multiply by 2^53 and add the minimum desired integer. The result should in theory be an integer
  • you might need to set options about function tolerance
I think this will likely not work well... but it is crazy enough that it just might work.

2 Comments

Thank you for your advice.
Since integers and double are both in the input variable of my objective function, it seems difficult to set the step size respectively.
So, I first, use GA to optimize whole variables, fix integer variables by setting LB, UB, and using simulannealbnd to optimize double type variables.
But it tooks a lot of time at simulannealbnd. If I set step size at simulannealbnd, I can shorten the optimization time but I can't find how to set step size. If you know, please help.
https://www.mathworks.com/help/optim/ug/optim.problemdef.optimizationproblem.optimoptions.html
set the StepTolerance option which defaults to 1e-10
If you are using my outline of how to transform continuous into integer, then you would need about 1e-16 which would potentially take much much longer than what you have now.
Simulated annealing is slow. It does not use any gradient information to make predictions about what to try next, and does not assume continuity.

Sign in to comment.

I have the same question.
Have you solved it now?

Asked:

on 17 Jan 2018

Commented:

on 19 Jul 2022

Community Treasure Hunt

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

Start Hunting!