1-dimensional nesting algorithm
what an effective algorithm nesting 1 dimensional lengths predefined batch lengths?
for example, mandatory steel bars following quantities lengths,
- 5 x 2 metres
- 5 x 3 metres
- 5 x 4 metres
and cut 10 metre bars.
how calculate settlement rupturing 10m bars smallest array bars used?
in addition, incorporate churned batch lengths algorithm?
i've bit work i'm going adult i solved it. i wish useful someone.i'm certain ok answer possess doubt this. judge change an answer some-more appropriate.
first interjection everybody answered. separate me suitable algorithm; .
this post also useful; .
ok, solution.
i'll following vernacular solution;
- stock: length component cut smaller pieces
- cut: length component cut stock. churned cuts competence taken same square stock
- waste: length component left square batch after cuts have made.
there 3 sure stages clarify problem,
- identify illusory cut combinations
- identify combinations taken any square stock
- find optimal brew cut combinations.
step 1
with n cuts, there 2^n-1 unparalleled cut combinations. combinations represented binary law table.
where a,b,c unparalleled cuts;
a b c | combination
-------------------
0 0 0 | none
0 0 1 | c
0 1 0 | b
0 1 1 | bc
1 0 0 | a
1 0 1 | ac
1 1 0 | ab
1 1 1 | abc
a for-loop bitwise operators used fast emanate groupings any cut combination.
this definitely radical infinite values n.
in conditions there churned instances same cut. assembled register combinations.
a b b | combination
-------------------
0 0 0 | none
0 0 1 | b
0 1 0 | b (same previous)
0 1 1 | bb
1 0 0 | a
1 0 1 | ab
1 1 0 | ab (same previous)
1 1 1 | abb
i means feat excess devaluate calculate combinations. i grouped register cuts together distributed unparalleled combinations group. i following appended list combinations any unparalleled multiple second organisation emanate new group.
for example, cuts aabbc, slight follows.
a | combination
-------------------
0 1 |
1 1 | aa
call organisation x.
append x unparalleled instances b,
b b x | combination
-------------------
0 0 1 |
| aa
0 1 0 | b
0 1 1 | ba
| baa
1 1 0 | bb
1 1 1 | bba
| bbaa
call organisation y.
append y unparalleled instances c,
c y | combination
-----------------
0 1 |
| aa
| b
| ba
| baa
| bb
| bba
| bbaa
1 0 | c
1 1 | ca
| caa
| cb
| cba
| cbaa
| cbb
| cbba
| cbbaa
this instance produces 17 unparalleled combinations instead 31 (2^5-1). saving roughly half.
once combinations identified check fits stock.
step 2
the aim step map cut combinations identified step 1 accessible batch sizes.
this comparatively rudimentary process.
for any cut combination,
calculate sum cut lengths.
any vigilant stock,
sum cuts reduction batch length,
store stock, cut multiple rubbish information structure.
supplement structure list sort.
this outcome list current nested cut combinations.
it quite required store rubbish distributed cut lengths batch length. however, storing rubbish reduces guess mandatory step 3.
step 3
in step brand multiple cuts produces slightest waste. formed list current nests generated step 2.
in an ideal universe calculate possibilities name best one. any non-trivial set cuts take evermore calculate all. only have positive non optimal solution.
there several algorithms accomplishing task.
i chose slight feeling nest slightest waste. repeat until cuts have accounted for.
start 3 lists
- cutlist: list mandatory cuts (including duplicates).
- nestlist: list nests generated step 2. sorted lowest rubbish top waste.
- finallist: primarily empty, store list cut combinations cost user.
method
pick nest nestlist slightest waste
each cut nest contained cutlist
mislay cuts cutlist
duplicate nest finallist
cuts nest cutlist
mislay nest nestlist
repeat until cutlist empty
with slight i managed sum rubbish around 2-4% customary exam data. hopefully i revisit problem during indicate have during implementing algorithm. should give improved results.
i wish helped anyone else carrying problem.
david
Comments
Post a Comment