Algorithm for combining ranges of a segment - help to create

 

Please help me to create an algorithm that combines pieces (ranges) of a segment into one segment without intersecting segments, with a possible gap to be filled in later.

Initially we have an array of numbers in a certain range, numbers can be repeated, this array is divided into segments by borders. Borders are generated by different algorithms, usually the boundaries are not uniform, so it turns out that the array of numbers sliced by different methods and each range has a different size. Next, an evaluation of each such segment by three criteria, each criterion has its own boundary, non-compliance with which eliminates a piece of the range. As a result, we get a table with the following content.

i - sequence number of the range;

S - range start boundary;

F - range end boundary;

%R - criterion #1;

%dP - criterion number 2;

%K_SCO - criterion number 3;

K_Svod - summary assessment of all criteria.

The figure below shows how chunks (segments) can be placed in the plane:

The 3 colours of check marks next to the pieces are potential solutions to the problem.

The algorithm should provide different combinations of solutions to the problem so that the condition is fulfilled:

1. The segments are matched without crossing ranges (S>=A && F<B);

2. It is impossible to add one more segment from available ones - i.e. some completeness and maximal density proceeding from chosen and available variants;

3. The sequence of segments is ordered - to eliminate similar combinations;

4. at least one of the best bars is used, from thetop 30% according toK_Svod- to reduce the combinations and to keep the priority of the best score.

Ideally the quality estimate should be to maximise the sum of all segments according to K_Svod, but it might need to be corrected a bit to estimate the fill space/spaces.

Perhaps I used wrong terminology and my problem has already been solved long time ago - don't judge - enlighten me.

 
Aleksey Vyazmikin:


1) K_Svod - summary evaluation of all criteria.

2) The figure below shows how pieces (segments) can be placed in the plane:

3) The segments are matched without range intersections (S>=A && F<B);

1) what is this? why x's?

2) better show with a picture what is right and what is wrong

3) what is "A" and what is "B" ?

4) Also make a "mock-up" of the data table and show what you want to see as a satisfactory solution
 
Possibly solved in terms of graph theory. The vertices of a graph are segments, the arrows of the graph connect each vertex to all possible subsequent vertices (the nearest allowable segments). Each vertex and arrow is marked with weights and a rule is defined by which the weight of each path is counted. Some algorithm for finding optimal path in the graph is applied. I am not ready to investigate the question in more detail)
 
mytarmailS:

1) what is it? why X?

2) better show with a picture what is right and what is wrong ?

3) what is "A" and what is "B" ?

4) also make a "mock-up" of the data table and show what you want to see as a satisfying solution

1. it's a derivative of all 3 evaluations, X's from the fact that I haven't decided on weights yet, it's not essential.

2. The correct solution is to fill the space with segments (a line with probable unfilled space between segments)-in the figure above I've ticked off the colours for each of the possible 3 solutions. It is possible to think about additional heuristics, let's say that the sum of the allocated range of all segments is as big as possible, but besides the sum the K_Svod value is also important.

3) This is a value of numbers inside the segment, it would be better to write A1>=S1 && A1<F1 && F1<S2.

4. The solution would be an array with indices. Or I didn't understand the question. Algorithm, how to do it better, I don't know.

 
Aleksey Nikolayev:
Probably solved in terms of graph theory. The vertices of a graph are segments, the arrows of the graph connect each vertex with all possible subsequent ones (the nearest allowable segments). Each vertex and arrow is marked with weights and a rule is defined by which the weight of each path is counted. Some algorithm for finding optimal path in the graph is applied. I am not ready to investigate the question in more detail)

Thanks for the idea, I think it is possible to start constructing the sequence from the top of each index i and then evaluate the resulting combinations. All we need is a selection criterion or several criteria to get different combinations. Or randomize criteria.... is not clear yet.

 
Aleksey Vyazmikin:

1. it's a derivative of all 3 assessments, the X's from the fact that I haven't decided on the weights yet - it's not essential.

2. The correct solution is to fill the space with segments (a line with probable unfilled space between segments) - in the figure above, I have ticked off the colours for each of the possible 3 solutions. It is possible to think about additional heuristics, let's say that the sum of the allocated range of all segments is as big as possible, but besides the sum, the K_Svod value is also important.

3) This is a value of numbers inside the segment, it would be better to write A1>=S1 && A1<F1 && F1<S2.

4. The solution would be an array with indices. Or I didn't understand the question. The algorithm, how to do it better, I don't know.

I still don't get it.

 
Aleksey Vyazmikin:

Thanks for the idea, I think it is possible to start constructing the sequence from the top of each index i and then evaluate the resulting combinations. All we need is a selection criterion or several criteria to get different combinations. Or randomize criteria.... is not clear yet.

And where are the ticks, do they have some kind of criterion that the segment belongs to that tick?
Basically, you get three ticks. Blue, red, green.
So in this example, three identifiers.
If you assign these identifiers in some way, you can concatenate them into three main arrays.
Using the identifier, we get the size of the resulting segment,
use the identifier to define the main receiving array andincrease its capacity by this size,
use the identifier to insert the segment at the end of the array.
So, we need to define some criterion that the segment belongs to this checkbox (identifier).

 
mytarmailS:

I still don't understand

Please clarify what you don't understand - I'll try to explain in other words.

 
Roman:

But where are the ticks, do they have some kind of criterion that the segment belongs to that tick?
Basically, you got three ticks. Blue, red, green.
So in this example, three identifiers.
If you assign these identifiers in some way, you can concatenate them into three main arrays.
By identifier we get the size of the resulting segment,
by identifier we define a basic receiving array andincrement its capacity by this size,
by identifier we insert the segment to the end of the array.
So we need to define some criterion that the segment belongs to this checkbox (identifier).

I drew the segments, then I thought I would show the option of combining them - I looked at the combinations that do not overlap and together occupy a large area. Note that some of the segments have two ticks, which means that it is possible to have the segment in more than one combination.

That is, there is no identifier before data processing begins.
 
Aleksey Vyazmikin:

I drew the segments, then I thought I'd show the option of combining them - I looked at the combinations that don't intersect and together occupy a larger area. Note that some of the segments have two ticks, which means that it is possible to have the segment in more than one combination.

I.e. there is no identifier before data processing begins.

Perhaps based on your algorithm, each segment can be identified by some criterion and assigned an identifier.
And the fact that a segment can bein more than one combination depends on whether it needs to be added to the main array again or not.
Use ternary or conditional operators to play around with the logic.

 
Roman:

Perhaps based on your algorithm, each segment can be identified by some criterion and assigned an identifier.
And the fact that a segment can bein more than one combination depends on whether it needs to be added to the main array again or not.
Use ternary or conditional operators to play around with the logic.

So there's no algorithm to start with :) Each segment is identified by an ordinal number and has information about coordinates (X axis) and some sort of utility estimate at these coordinates.

So far only one idea comes to mind - choose the closest segment from the initial one. Maybe this way we can choose the first 3 closest, depending on the number of segments the number of combinations will grow.

Reason: