title: How to design acceptance probability function for simulated annealing with multiple distinct costs?
body: <p>I am using <a href="http://en.wikipedia.org/wiki/Simulated_annealing" rel="noreferrer">simulated annealing</a> to solve an NP-complete resource scheduling problem. For each candidate ordering of the tasks I compute several different costs (or energy values). Some examples are (though the specifics are probably irrelevant to the question):</p>
  
  <ul>
  <li><code>global_finish_time</code>: The total number of days that the schedule spans.</li>
  <li><code>split_cost</code>: The number of days by which each task is delayed due to interruptions by other tasks (this is meant to discourage interruption of a task once it has started).</li>
  <li><code>deadline_cost</code>: The sum of the squared number of days by which each missed deadline is overdue.</li>
  </ul>
  
  <p>The traditional acceptance probability function looks like this (in Python):</p>
  
  <pre><code>def acceptance_probability(old_cost, new_cost, temperature):
      if new_cost &lt; old_cost:
          return 1.0
      else:
          return math.exp((old_cost - new_cost) / temperature)
  </code></pre>
  
  <p>So far I have combined my first two costs into one by simply adding them, so that I can feed the result into <code>acceptance_probability</code>. But what I would really want is for <code>deadline_cost</code> to always take precedence over <code>global_finish_time</code>, and for <code>global_finish_time</code> to take precedence over <code>split_cost</code>.</p>
  
  <p>So my question to Stack Overflow is: how can I design an acceptance probability function that takes multiple energies into account but always considers the first energy to be more important than the second energy, and so on? In other words, I would like to pass in <code>old_cost</code> and <code>new_cost</code> as tuples of several costs and return a sensible value .</p>
  
  <p><strong>Edit:</strong> After a few days of experimenting with the proposed solutions I have concluded that the only way that works well enough for me is Mike Dunlavey's suggestion, even though this creates many other difficulties with cost components that have different units. I am practically forced to compare apples with oranges.</p>
  
  <p>So, I put some effort into "normalizing" the values. First, <code>deadline_cost</code> is a sum of squares, so it grows exponentially while the other components grow linearly. To address this I use the square root to get a similar growth rate. Second, I developed a function that computes a linear combination of the costs, but auto-adjusts the coefficients according to the highest cost component seen so far.</p>
  
  <p>For example, if the tuple of highest costs is (A, B, C) and the input cost vector is (x, y, z), the linear combination is BCx + Cy + z. That way, no matter how high z gets it will never be more important than an x value of 1.</p>
  
  <p>This creates "jaggies" in the cost function as new maximum costs are discovered. For example, if C goes up then BCx and Cy will both be higher for a given (x, y, z) input and so will differences between costs. A higher cost difference means that the acceptance probability will drop, as if the temperature was suddenly lowered an extra step. In practice though this is not a problem because the maximum costs are updated only a few times in the beginning and do not change later. I believe this could even be theoretically proven to converge to a correct result since we know that the cost will converge toward a lower value.</p>
  
  <p>One thing that still has me somewhat confused is what happens when the maximum costs are 1.0 and lower, say 0.5. With a maximum vector of (0.5, 0.5, 0.5) this would give the linear combination 0.5*0.5*x + 0.5*y + z, i.e. the order of precedence is suddenly reversed. I suppose the best way to deal with it is to use the maximum vector to scale all values to given ranges, so that the coefficients can always be the same (say, 100x + 10y + z). But I haven't tried that yet.</p>