I need to make a CPM model with costs using AMPL.
My .mod:
set TASKS;
set ARCS within {TASKS cross TASKS};
param duration{TASKS} >= 0;
param cost{TASKS} >=0;
param description{TASKS} symbolic;
var
TASKS_ES{TASKS} >= 0; #Earliest Start
var
TASKS_EF{TASKS} >= 0; # Earliest Finish
var
TASKS_LS{TASKS} >= 0; # Latest Start
var
TASKS_LF{TASKS} >= 0; # Latest Finish
var
TASKS_SLACK{TASKS} >= 0; # Slacks
#Final time (global)
var TF >= 0;
minimize CPM: card(TASKS)*TF - sum {j in TASKS} TASKS_SLACK[j];
.. #constraints
My .dat:
param : TASKS : duration cost description :=
T01 5 5 'A'
T02 1 1 'B'
T03 2 2 'C'
T04 3 3 'D'
T05 2 2 'E'
T06 3 3 'F'
T07 4 4 'G'
T08 2 2 'H'
T09 1 1 'I'
T10 1 1 'J'
;
set ARCS :=
T01 T02
T01 T03
T02 T03
T02 T05
T03 T04
T05 T07
T04 T07
T03 T06
T06 T07
T07 T08
;
Works perfectly, but i need to add this constraint for calculate the cost of all tasks (I can minimize the duration of all tasks, but i need the optimal time of each task):
cost(duration_task(i,j)) = k(i,j) - cost(i,j) * duration_task(i,j)
duration_task is the time that minimizes my objective function with all the constraints.
This will be like:
subject to cost {(i,j) in ARCS} : max_cost + (min_cost - max-cost / max_time - min_time)*(time_task(i,j) - min_time)
Example:
Need some help, thanks.
- EDITED!