// Machine calendar
MachineException[] machine_exceptions = {
// Machine 1 - Shift from 8-12 and 14-18
// Mon
new MachineException(){ Start = 0, Duration = 8, Machine = 1},
new MachineException(){ Start = 12, Duration = 2, Machine = 1},
new MachineException(){ Start = 18, Duration = 6, Machine = 1},
...
// Sat
new MachineException(){ Start = 0+120, Duration = 24, Machine = 1},
// Sun
new MachineException(){ Start = 0+144, Duration = 24, Machine = 1},
// Machine 2 - Shift from 8-12 e 14-18
// Mon
new MachineException(){ Start = 0, Duration = 8, Machine = 2},
new MachineException(){ Start = 12, Duration = 2, Machine = 2},
new MachineException(){ Start = 18, Duration = 6, Machine = 2},
...
// Sat
new MachineException(){ Start = 0+120, Duration = 24, Machine = 2},
// Sun
new MachineException(){ Start = 0+144, Duration = 24, Machine = 2},
};
this draw when the machine is not available ...
I use disjunctive constraints to tell OR-TOOLS to not allocate TASK during exception machine slot
foreach (MachineException m in machine_exceptions)
{
m.Interval = solver.MakeFixedInterval(m.Start, m.Duration, string.Format("Machine_{0} off", m.Machine - 1));
}
Dictionary<int, SequenceVar> all_machines_calendars = new Dictionary<int, SequenceVar>();
for (int machine_id = 0; machine_id < machines_to_tasks.Count(); ++machine_id)
{
List<IntervalVar> calendar = machines_to_tasks[machine_id];
calendar.AddRange(machine_exceptions.Where(rsv => rsv.Machine == machine_id + 1).Select(rsv => rsv.Interval));
string dsjName = String.Format("Machine_{0} calendar", machine_id);
DisjunctiveConstraint disj = solver.MakeDisjunctiveConstraint(calendar.ToArray(), dsjName);
all_machines_calendars[machine_id] = disj.SequenceVar();
solver.Add(disj);
}
// add the sequence
all_sequences.Concat<SequenceVar>(all_machines_calendars.Values);
Finally I obtain a model where the tasks of jobs are allocated (the gray bar is the machine off slot)
--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Laurent,first thank you for your quick reply. I found a old thread where you expose your idea to precompute the duration taking in account overlap>>>>>>>>>>>>>>>>let's take an exampletask : start between 0 and 10, duration = 5break between 2 and 4, and 6 and 7.so duration is [8, 8, -1, -1, 6, 6, -1, 5, 5, 5]I use -1 to forbid this as a starting point.>>>>>>>>>>>>>>>>Ok, I understand your idea BUT I'm not able to text C# code to implement this stuff ....I create the IntervalVar with this method:
IntervalVar interval = solver.MakeFixedDurationIntervalVar(start, horizon, duration, optional, name);
How I can create the IntervalVar with variable duration like you suggest me? What method should I use? (some snippet C# available?)
--
Hi Laurent,
--
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discuss+unsubscribe@googlegroups.com.
Hi Laurent,
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/59f88dbd-471a-491e-826f-1e00d30d5d38%40googlegroups.com.
calendar.AddRange(machine_exceptions.Where(rsv => rsv.Machine == machine_id + 1).Select(rsv => rsv.Interval));
string dsjName = String.Format("Machine_{0} calendar", machine_id);
DisjunctiveConstraint disj = solver.MakeDisjunctiveConstraint(calendar.ToArray(), dsjName);
all_machines_calendars[machine_id] = disj.SequenceVar();
solver.Add(disj);
}
// add the sequence
all_sequences.Concat<SequenceVar>(all_machines_calendars.Values);