Click here to Skip to main content
15,887,267 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionVery advanced Computer Graphics library Pin
markweber5-Mar-09 5:08
markweber5-Mar-09 5:08 
AnswerRe: Very advanced Computer Graphics library Pin
Mark Churchill9-Mar-09 13:57
Mark Churchill9-Mar-09 13:57 
GeneralRe: Very advanced Computer Graphics library Pin
markweber10-Mar-09 3:26
markweber10-Mar-09 3:26 
Questiona parellel program problem Pin
JackPuppy2-Mar-09 1:49
JackPuppy2-Mar-09 1:49 
AnswerRe: a parellel program problem Pin
JackPuppy2-Mar-09 2:43
JackPuppy2-Mar-09 2:43 
AnswerRe: a parellel program problem Pin
JackPuppy2-Mar-09 2:44
JackPuppy2-Mar-09 2:44 
QuestionGreedy problem with filling sequence Pin
proggged26-Feb-09 4:23
proggged26-Feb-09 4:23 
AnswerRe: Greedy problem with filling sequence Pin
Perisic, Aleksandar28-Feb-09 5:38
Perisic, Aleksandar28-Feb-09 5:38 
In order to analyse this problem more deeply we need to create the following structure.
First for each set of equal elements there is one position that is the best. For 55555 it is 3[5]4[5]5[5]6[5]7[5] and similarity is 6. If the number of elements is even we have two possibilities 7777 is 5[7]6[7]7[7]8[7] or 6[7]7[7]8[7]9[7], similarity = 4.
Now if we place every group of equal elements into their best positions and it turns out that they do not overlap, that is the best solution. But they may overlap.

*******aaaaa
**********bbbbbbb
************ccccccccc
**************ddddddddd

In that case we have to slide and cross them around to avoid overlapping but still to get the best result regarding similarity.

Now each position has its similarity value regarding the distance from the optimal 0 valued position of an element. For example for 5 and 9 we have

1 2 3 4 5 6 7 8 9 position
4 3 2 1 0 1 2 3 4 = S[5]
8 7 6 5 4 3 2 1 0 = S[9]

Once you have these values you can create a table if you like, though the table content is obvious. Now assume that multiset has these elements a1 a2 a3 a4 ... ai, repeated n1 n2 n3 n4... ni times. The table is easy to create:

0102030405060708091011...
... = S[a1]
... = S[a2]
... = S[a3]
...
... = S[ai]

Now you go: select n1 positions for element a1, then another not yet selected n2 positions for a2, then another n3 not yet selected positions for a3... and finally ni for ai.
Calculate the similarity.

Keep controllably changing selected ni positions for element ai, then for a,i-1 a,i-2.... This is simply an extend algorithm for creating combinations. You will have to check
|n over n1|*|(n-n1) over n2|*|(n-n1-n2) over n3|*|(n-n1-n2-n3) over n4|*...|(n-n1-...) over ni|
This is quite a number!

I can create heuristics but for a precise algorithm you would probably need something at least as strong as knapsack problem.

Overlapping check is something I would start with, for sure.

Another related idea is not to select all positions for one element first, but rather to select one position for a1 then one position for a2.., and so on until ai. Then to select the position for the second a1 element (if we have it), the second a2 element... second ai element. If you start this way here then you might start with placing each first element into position with value 0.

This second solution can lead to some clever heuristics.
GeneralRe: Greedy problem with filling sequence Pin
Perisic, Aleksandar1-Mar-09 3:45
Perisic, Aleksandar1-Mar-09 3:45 
QuestionAnd Or and Xor with floating point Pin
PIEBALDconsult25-Feb-09 4:35
mvePIEBALDconsult25-Feb-09 4:35 
AnswerRe: And Or and Xor with floating point Pin
Dan Neely25-Feb-09 4:47
Dan Neely25-Feb-09 4:47 
GeneralRe: And Or and Xor with floating point Pin
supercat925-Feb-09 5:28
supercat925-Feb-09 5:28 
GeneralRe: And Or and Xor with floating point Pin
Dan Neely25-Feb-09 5:38
Dan Neely25-Feb-09 5:38 
GeneralRe: And Or and Xor with floating point Pin
supercat925-Feb-09 6:08
supercat925-Feb-09 6:08 
GeneralRe: And Or and Xor with floating point Pin
PIEBALDconsult25-Feb-09 6:48
mvePIEBALDconsult25-Feb-09 6:48 
QuestionCalculate intersection between arcs / lines and arc /arc Pin
sagaert21-Feb-09 8:12
sagaert21-Feb-09 8:12 
AnswerRe: Calculate intersection between arcs / lines and arc /arc Pin
Arash Partow21-Feb-09 16:40
Arash Partow21-Feb-09 16:40 
GeneralRe: Calculate intersection between arcs / lines and arc /arc Pin
sagaert22-Feb-09 3:13
sagaert22-Feb-09 3:13 
QuestionCaculate time left for data transfer Pin
cdpace17-Feb-09 6:21
cdpace17-Feb-09 6:21 
GeneralRe: Caculate time left for data transfer Pin
Luc Pattyn17-Feb-09 6:32
sitebuilderLuc Pattyn17-Feb-09 6:32 
GeneralRe: Caculate time left for data transfer Pin
cdpace17-Feb-09 11:30
cdpace17-Feb-09 11:30 
GeneralRe: Caculate time left for data transfer Pin
Luc Pattyn17-Feb-09 13:51
sitebuilderLuc Pattyn17-Feb-09 13:51 
AnswerRe: Caculate time left for data transfer Pin
Leonardo Muzzi17-Feb-09 9:12
Leonardo Muzzi17-Feb-09 9:12 
Questionthinning algorithm Pin
Swati Khanna17-Feb-09 1:40
Swati Khanna17-Feb-09 1:40 
AnswerRe: thinning algorithm Pin
riced17-Feb-09 2:33
riced17-Feb-09 2:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.