LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
I build a stack to create a report with the optimization of circuits with respect to the length and number of circuits (or parts).
In practice, the script must create the best combination of the circuit to select the coil with less waste.
I started with tablefield "Circuit" (where I put the ID and length of circuits) tablefield a "Coil" (where I put the length of the coils I have available)
and a field "Report" where I read the results (of course I created the report in attach. with hand! )
Any idea how can I do?
Thanks in advance
Davide
Attachments
Schermata 2010-05-08 a 11.58.35.png (57.6 KiB) Viewed 4515 times
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
I need help on how to write the algorithm with Rev. Until now I have written small applications, and create this script is hard for me.
The script should create groups of combinations (in relation to the total length of the coils in the field “coils") summing the item 2 of the field "Circuit" and the script must prefer the combination with less waste (see field “Report”)
I wrote a quick script that should show the way. I assumed you have your data in a field called "rawdata", and that the data contains both the ID and the length, one pair on each line separated with a comma. Not sure how optimal this is, and I only dealt with the 500 foot spools:
on mouseUp
Put fld "rawdata" into rawData
put 0 into spools
Sort rawData by item 2 of each
repeat until the number of lines of rawdata = 0
put 0 into balance
add 1 to spools
repeat with y = the number of lines of rawData down to 1
if item 2 of line y of rawData + balance < 500 then
add item 2 of line y of rawData to balance
delete line y of rawData
else
next repeat
end if
end repeat
end repeat
answer spools
end mouseUp