Originally posted by: SystemAdmin
[elham said:]
Thank you so much Didier for helping me.
Sorry I forgot to copy the part that I initialized "conditional tasks" and "afters" variables . Actually the(minimization= lower bound) code does not have a problem and works properly. My biggest problem is that I don't know how to change the model to get the upper bound.
To explain it, you can take a look at the image file that I attached to this mail. here each agent is in charge of executing some tasks as shown in the picture.tasks are shown as circles and the arrows shows the precedence relation between tasks. tasks {c,e} in agent 1 and {g, i} in agent 2 are mutually exclusive.
for the lower bound problem I would like to know:
(1) which tasks in each set {g,i} and {c,e} should be executed , and (2) each agent in what order should execute its tasks in order to have the minimum completion of all tasks as an objective. The code that I attached here works perfect for this problem.
However the main problem is that I am also interested to know as part of my research the worst completion time of all tasks (upper bound), in other words I would like to know:
(1) which tasks in each set of {g,i} and {c,e} should be executed , such that if each agent execute its tasks[b] in an optimal order[/b], we get the maximum completion time (upper bound) for completion of all tasks.
The problem is that my objective at an upper level is to maximize the whole completion time based on the deciding wich tasks from {c,e} and {g, i} to execute. but in the lower level and once the decision was made about this, I want these tasks to be executed in an optimal order by optimal I mean the order that gives the minimum completion time.
I hope I could explain my problem. I attached both the image and my lower bound problem which works properly . I really really appreciate your help to model the upper bound problem. Thanks a lot.
using CP;
{string} TaskNames= ...;
int cgroupNo=...;
{string} ctasks[1..cgroupNo]=...;
int AgentNo = ...;
range aa = 1..AgentNo;
int Duration [t in TaskNames] = ...;
int Agent[t in TaskNames] = ...;
tuple Precedence {
string before;
string after;
int communicationTime;
};
{Precedence} Precedences = ...;
{string} afters = {p.after | p in Precedences};
{string} conditionalTasks = union(i in 1..cgroupNo) ctasks[i];
dvar interval s[aa];
dvar interval task [t in TaskNames] optional size Duration[t];
dvar sequence Agents[a in aa ] in
all (t in TaskNames: Agent[t]==a) task[t];
minimize max (t in TaskNames) endOf(task[t]);
subject to
{
forall( i in 1..cgroupNo)
sum ( c in ctasks[i]) presenceOf(task[c])==1;
forall (t in TaskNames: t not in conditionalTasks && t not in afters)
presenceOf(task[t]);
forall( p in Precedences)
{
presenceOf(task[p.after]) => presenceOf(task[p.before]);
if (p.after not in conditionalTasks)
presenceOf(task[p.before])=>presenceOf(task[p.after]);
endBeforeStart(task[p.before],task[p.after],p.communicationTime);
}
forall (a in aa)
noOverlap(Agents[a]);
}
execute {
for (var t in TaskNames)
{
if (task[t].end != 0)
writeln("task: " + t
" " task[t].start + "..." +task[t].end );
}
cp.param.FailLimit = 1000;
}
And here is my Data file:
TaskNames = {
"send-13","send-12","send-14","in-21","taur-21","in-31","taur-31","in-41", "taur-41",
"send-21","send-23","send-24","in-12","taur-12","in-32","taur-32","in-42","taur-42",
"send-31","send-32","send-34","in-13","taur-13","in-23","taur-23","in-43","taur-43",
"send-41","send-42","send-43","in-14","taur-14","in-24","taur-24","in-34","taur-34"
};
Agent= [
1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,
4,4,4,4,4,4,4,4,4];
Duration=[
38, 55, 65, 7, 67, 5, 45, 6, 50
71, 36, 54, 4, 40, 3, 38, 8, 68,
42, 31, 35, 5, 49, 3, 35, 7, 63,
59, 70, 60, 7, 63, 5, 59, 4, 42];
Precedences =
{
<", "taur-21", 0>,
<", "taur-31", 0>,
<", "taur-41", 0>,
<", "taur-12", 0>,
<", "taur-32", 0>,
<", "taur-42", 0>,
<", "taur-13", 0>,
<", "taur-23", 0>,
<", "taur-43", 0>,
<", "taur-14", 0>,
<", "taur-24", 0>,
<", "taur-34", 0>,
<", "in-12", 80>,
<", "in-13", 100>,
<", "in-14", 120>,
<", "in-21", 140>,
<", "in-23", 75>,
<", "in-24", 85>,
<", "in-31", 84>,
<", "in-32", 70>,
<", "in-34", 75>,
<", "in-41", 110>,
<", "in-42", 138>,
<", "in-43", 125>
};
AgentNo = 4;
cgroupNo= 4;
ctasks= [
{"send-12", "send-14"},
{"send-21", "send-24"},
{"send-31", "send-34"},
{"send-41", "send-43"}];
#ConstraintProgramming-General#DecisionOptimization