The use of cumulative

I am working on a problem when I use a predicate cumulatives/[2,3]. But I get very poor performance when I try to combine this with minimizeinlabeling

I have the following demo. 10, all with a duration of 1, 4 cars, all with a capacity = 1. My goal is to minimize the total time, i.e. minimize(maximum(Es)):

:- use_module(library(clpfd)).
:- use_module(library(lists)).

go( Ss, Es, Ms, Tm, Lab ) :-

    Ss = [S1, S2, S3, S4,S5,S6,S7,S8,S9,S10], %Starttimes
    Es = [E1, E2, E3, E4,E5,E6,E7,E8,E9,E10], %Endtimeds
    Ms = [M1, M2, M3, M4,M5,M6,M7,M8,M9,M10], %MachineIds


    domain(Ss, 1, 20),
    domain(Es, 1, 20),
    domain(Ms, 1, 10),

    %All task has duration = 1
    Tasks = [
        task(  S1, 1,  E1,  1, M1 ), 
        task(  S2, 1,  E2,  1, M2 ), 
        task(  S3, 1,  E3,  1, M3 ), 
        task(  S4, 1,  E4,  1, M4 ), 
        task(  S5, 1,  E5,  1, M5 ), 
        task(  S6, 1,  E6,  1, M6 ), 
        task(  S7, 1,  E7,  1, M7 ), 
        task(  S8, 1,  E8,  1, M8 ), 
        task(  S9, 1,  E9,  1, M9 ), 
        task( S10, 1,  E10, 1, M10 ) 
    ],

    %All machines has resource capacity = 1
    Machines = [
        machine(  1, 1 ),
        machine(  2, 1 ),
        machine(  3, 1 ),
        machine(  4, 1 ) 
    ],

    cumulatives(Tasks, Machines, [bound(upper)] ),

    maximum( MaxEndTime, Es ),

    %Make the list of options to pass to the labeling predicate
    append( [ [minimize(MaxEndTime)], [time_out( Tm, _)], Lab ], LabOpt ),
    %The variables to lable:
    append([Ms, Ss ], Vars),

    labeling( LabOpt, Vars). 

If I run this now and resolve within 1 second, I get:

| ?- go( S, E, M, 1000, []).
E = [2,3,4,5,6,7,8,9,10,11],
M = [1,1,1,1,1,1,1,1,1,1],
S = [1,2,3,4,5,6,7,8,9,10] ? 

those. all tasks were scheduled to run on machine 1

I need to start the solver within 30 seconds before I see any signs of minimization:

| ?- go( S, E, M, 30000, []).
E = [2,3,4,5,6,7,8,9,10,2],
M = [1,1,1,1,1,1,1,1,1,2],
S = [1,2,3,4,5,6,7,8,9,1] ? 

If I work for 60 seconds, I will start to get acceptable results:

| ?- go( S, E, M, 60000, []).
E = [2,3,4,2,3,4,2,3,4,2],
M = [1,1,1,2,2,2,3,3,3,4],
S = [1,2,3,1,2,3,1,2,3,1] ? 

I feel this has been going on for too long. Any comments on why this took so long?

+4
2

task_intervals(true) cumulatives, :

cumulatives(Tasks, Machines, [bound(upper),task_intervals(true)] )

2ms , .

+2

, .

-, . M S-. 51 . S, M . [S1, M1, S2, M2, S3, M3, S4, M4, S5, M5, S6, M6, S7, M7, S8, M8, S9, M9, S10, M10]. 2 .

-, , . , , , . , , , . :

lex_chain([[S1,M1],[S2,M2],[S3,M3],[S4,M4],[S5,M5],[S6,M6],[S7,M7],[S8,M8],[S9,M9],[S10,M10]]),

10 .

.

+5

Source: https://habr.com/ru/post/1540486/


All Articles