algorithm - Allocating resources according to rules -- is simulated annealing appropriate? -


i design application can allocate resources according rules. believe simulated annealing work, not familiar , wondering if there alternative algorithms might suitable.

for example if had grid, , color each cell in grid, design algorithm find optimum or close-to-optimum solution rule set following:

  • 1000x1000 grid
  • must place 500 red cells, 500 blue cells, , 1000 green cells
  • a red cell must touching red cell
  • a blue cell must not touching blue cell
  • a green cell may placed along edge
  • arrangements can scored based on mean distance of colored cells upper-left hand corner

would simulated annealing appropriate problem? need algorithm can compute solution reliably (seconds minutes).

simulated annealing close optimal solution pretty fast. however, implementing simulated annealing correctly (which isn't code) can challenging. many people (including myself in past) implement wrong, think did right , presume algorithm isn't good.

alternatives algorithms tabu search, genetic algorithms, simplex, ...

here's how constraints in drools planner (java, open source, asl):

rule "a red cell must touching red cell" when    // there cell assignment of color red    $a1: cellassignment(color = red, $x1 : x, $y1 : y)    // there no other red cell neighbor of    not cellassignment(color = red, eval(mydistancehelper.distance(x, y, $x1, $y1) == 1))    insertlogical(new intconstraintoccurrence(             "a red cell must touching red cell",              constrainttype.negative_hard, 1, // weight 1             $a1)); end  rule "a blue cell must not touching blue cell" when    // there cell assignment of color blue    $a1: cellassignment(color = blue, $x1 : x, $y1 : y)    // there blue cell neighbor of    $a2: cellassignment(color = blue, eval(mydistancehelper.distance(x, y, $x1, $y1) == 1))    insertlogical(new intconstraintoccurrence(             "a blue cell must not touching blue cell",              constrainttype.negative_hard, 1, // weight 1             $a1, $a2)); end  ... 

now fun part is: once have score rules, can throw several algorithms (tabu search, simulated annealing, ...) on (see benchmarker support) , use best 1 in production. more information in reference manual.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -