algorithm - Place connected boxes on a 2D plane -
given n rectangular boxes , m connections between them, want place them on plane efficiently such total sum of length of connections remains minimum.
the throught process have split plane in grid n or more spaces, , place boxes maximum number of connections farther apart in grid starting diagonally opposite corner spaces.
this might not efficient when there 1 box connected n-1 boxes , connections. expect 1 box in center , other boxes around it.
is there standard solution such problem? can pointer how approach such problem?
it non-linear optimization problem , can solved, instance, using simulated annealing or general objective function minimization such gradient descent methods.
given layout of boxes, let l denote sum of lengths of connections given layout. want minimize l. simple simulated annealing scheme works this:
layout = random_layout() t = 1.0 while(true) l = sum_of_lengths(layout) layout' = move_one_box(layout) l' = sum_of_lengths(layout) if (l' < l or random(0..1) < t) layout = layout' t = t * 0.999
initially, algorithm moves boxes randomly around, when t decreases, algorithm gradually changes greedy optimizer. can run multiple runs of algorithm , pick best result. simulated annealing scheme.
Comments
Post a Comment