How to try each possibilities?

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!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
matgarage
Posts: 73
Joined: Sat Apr 20, 2013 11:39 am

How to try each possibilities?

Post by matgarage » Fri Sep 11, 2015 5:40 pm

I'm working on a project where I need to dispatch products into groups and then test a set of 'performances'.
For example :
18 products to dispach
8 room/sit in each group
3 groups where to dispatch the product

I've wrote a script that use logical rules to optimize the dispatching of the products into each group, to get a 'not so bad' result of performances.
To test for other possibilities I've set a function that random the dispatching and test, recursively, until limit of try or if the goal of performance is reached.

But, I would like to try for each possibilities, one by one, and stop when each possibilities have been tested.

Is there a logical/mathematical method to do that in script ?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: How to try each possibilities?

Post by dunbarx » Sat Sep 12, 2015 12:52 am

Hi.

I am having difficulty undertanding exactly what you are trying to do. Can you give a concrete example, even if of a simple case?

Craig Newman

matgarage
Posts: 73
Joined: Sat Apr 20, 2013 11:39 am

Re: How to try each possibilities?

Post by matgarage » Sat Sep 12, 2015 10:34 am

Hi Craig

I get 3 groups (boxes), and in each group i get 8 sit/room to place products.
I get 18 products to pack into the boxes.
So I need 3 boxes.
For each product numbered from 1 to 18, there is many possible dispatching :
Box 1 = 1 , 2 , 3 , 4 , 5 , 6
Box 2 = 7 , 8 , 9 , 10 , 11 , 12
Box 3 = 13 , 14 , 15 , 16 , 17 , 18

OR

Box 1 = 7 , 8 , 9 , 10 , 11 , 12
Box 2 = 13 , 14 , 15 , 16 , 17 , 18
Box 3 = 1 , 2 , 3 , 4 , 5 , 6

OR

Box 1 = 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14
Box 2 = 15 , 16 , 17 , 18 , 5 , 6
Box 3 = 1 , 2 , 3 , 4

OR ...

Each dispatching is evaluated by my script to calculate a performance.
For this example we can say that each product has a weight and I can calculate the total weight of each dispatching to find the one that fit with my goal.

I'm looking for a way to try each possible dispatching.
I think about a sort of record of each tested combination and a test to compare actual random dispatch to this list. But it will be even longer.
Tell me if I'm wrong but I think that in my example there is :
(8 * 8 * 8 ) * 18 = 9216 possibilities
But we can say that
1 , 2 , 3 , 4 , 5 , 6 is the same that 6 , 5 , 4 , 3 , 2 , 1 (if I'm testing the total weight)

AND

Box 1 = 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14
Box 2 = 15 , 16 , 17 , 18 , 5 , 6 , 3 , 4
Box 3 = 1 , 2
is the same that
Box 1 = 1 , 2
Box 2 = 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14
Box 3 = 15 , 16 , 17 , 18 , 5 , 6 , 3 , 4

Interesting way to optimize but that's to complicated for my skills.
Perhaps you can give me some hints ?

Post Reply