0

I want to use Simulated Annealing. My objective function exist of multiple variables, for some of them there are only a few options possible. I saw the same question on Stack here: How to use simulated annealing for a function with discrete paremeters?, but there was no answer but a reference to: How to put mathematical constraints with GenSA function in R.

I don't understand how to apply the advice from the second link to my situation (but I think the answer can be found there).

For example:

v <- c(50, 50, 25, 25)
lower <- c(0,0,0,20)
upper <- c(100,100,50,40)
out <- GenSA(v, lower = lower, upper = upper, fn = efficientFunction)

Assume that the fourth parameter, v[4], only can be in {20,25,30,35,40}. They suggested the use of Lagrange multipliers, hence, I was thinking of something like: lambda * ceil(v[4] / 5). Is this a good idea ?

But what can I do it the sample space of a variable does not have a nice pattern, for example third parameter, v[3], only can be in {0,21,33,89,100}. I don't understand why a Lagrange multiplier can help in this situation. Do I need to make the form of my parameters different that they follow a pattern or is there another option?

In case Lagrange multipliers are the only option, I'll end up with with 8 of these formulations in my objective. It seems to me that there is another option, but I don't know how!

With kind regards and thanks in advance, Roos

Roos
  • 11
  • 2

1 Answers1

0

With SA, you could start with a very simple neighbourhood sheme,

pick 1 of the parameters, and change it by selecting a new valid setting, 1 above, or 1 below the current one (we assume that they have a order, like I feel is your case).

There are no Lagrange multipliers involved in SA as I know. But there are many variations and maybe some with Constrainsts or other make use of them.

Willem Hendriks
  • 1,267
  • 2
  • 9
  • 15
  • That sounds as a solution for my problem. But I'm using the package GenSA in R at the moment. Is your approach possible in this package? I'm not sure if I can prepossess the neighbourhood scheme. (Therefore my solution about the Lagrange multipliers, to enforce this. ) – Roos Jun 02 '20 at 10:33
  • Are you restricted by only using `GenSA` ? Because there are other pacakges. You could write your own SA scheme as well. – Willem Hendriks Jun 02 '20 at 14:03