52 Object::createString<OperationFixedTime>,
true);
63 Object::createString<OperationTimePer>);
74 Object::createString<OperationAlternate>);
79 METH_VARARGS | METH_KEYWORDS,
"add an alternate"
89 Object::createString<OperationRouting>);
124 if (k->getOperation() ==
this) k->setOperation(NULL);
128 if (l->getOperation() ==
this) l->setOperation(NULL);
132 if (m->getProducingOperation() ==
this) m->setProducingOperation(NULL);
165 bool makeflowsloads)
const
179 vector<Calendar::EventIterator*> cals(10);
182 if (actualduration) *actualduration = duration;
188 if (loc && loc->getAvailable())
214 DateRange(thedate-duration, thedate);
219 Date curdate = thedate;
225 bool available =
true;
226 for (
int c = 0; c < calcount && available; c++)
232 available = cals[c]->getCalendar()->getBool();
234 curdate = cals[0]->getDate();
236 if (available && !status)
241 if (forward && result.
getStart() == Date::infinitePast)
244 else if (!forward && result.
getEnd() == Date::infiniteFuture)
248 else if (!available && status)
256 if (delta >= curduration)
258 result.
setEnd(thedate + curduration);
262 curduration -= delta;
268 if (delta >= curduration)
270 result.
setStart(thedate - curduration);
274 curduration -= delta;
277 else if (forward && curdate == Date::infiniteFuture)
283 if (delta >= curduration)
284 result.
setEnd(thedate + curduration);
285 else if (actualduration)
286 *actualduration = duration - curduration;
288 else if (actualduration)
289 *actualduration = duration - curduration;
292 else if (!forward && curdate == Date::infinitePast)
298 if (delta >= curduration)
299 result.
setStart(thedate - curduration);
300 else if (actualduration)
301 *actualduration = duration - curduration;
303 else if (actualduration)
304 *actualduration = duration - curduration;
309 if (forward) ++(*cals[0]);
314 while (calcount)
delete cals[--calcount];
320 while (calcount)
delete cals[calcount--];
340 vector<Calendar::EventIterator*> cals(10);
343 if (actualduration) *actualduration = 0L;
349 if (loc && loc->getAvailable())
374 if (actualduration) *actualduration = end - start;
381 Date curdate = start;
386 bool available =
true;
387 for (
int c = 0; c < calcount && available; c++)
389 if (cals[c]->getBucket())
390 available = cals[c]->getBucket()->getBool();
392 available = cals[c]->getCalendar()->getBool();
394 curdate = cals[0]->getDate();
396 if (available && !status)
407 if (result.
getStart() == Date::infinitePast)
411 else if (!available && status)
417 if (actualduration) *actualduration += end - start;
422 if (actualduration) *actualduration += curdate - start;
425 else if (curdate >= end)
430 if (actualduration) *actualduration += end - start;
444 while (calcount)
delete cals[--calcount];
450 while (calcount)
delete cals[calcount--];
459 unsigned long i,
bool makeflowsloads)
const
461 opplan->oper =
const_cast<Operation*
>(
this);
493 HasDescription::writeElement(o, tag);
503 if (size_minimum != 1.0)
505 if (size_multiple > 0.0)
507 if (size_maximum < DBL_MAX)
568 else throw LogicException(
"Incorrect object type during read operation");
573 HasDescription::endElement(pIn, pAttr, pElement);
584 throw LogicException(
"Incorrect parameters for fixedtime operationplan");
590 if (q > 0 && q < getSizeMinimum()) q = getSizeMinimum();
591 if (q > getSizeMaximum()) q = getSizeMaximum();
600 if (preferEnd) x = calculateOperationTime(e, duration,
false, &actualduration);
601 else x = calculateOperationTime(s, duration,
true, &actualduration);
603 else if (s) x = calculateOperationTime(s, duration,
true, &actualduration);
604 else x = calculateOperationTime(e, duration,
false, &actualduration);
608 else if (actualduration == duration)
648 while (fp1 != o->endFlowPlans())
671 while (fp1 != o->endFlowPlans())
727 throw LogicException(
"Incorrect parameters for timeper operationplan");
732 if (q > 0 && q < getSizeMinimum()) q = getSizeMinimum();
733 if (q > getSizeMaximum()) q = getSizeMaximum();
742 x = calculateOperationTime(s,e,&actual);
743 if (actual < duration)
756 if (q * duration_per < static_cast<double>(actual - duration) + 1)
763 static_cast<double>(actual - duration) / duration_per,
764 true,
false, execute);
772 duration + static_cast<long>(duration_per * q)
774 if (preferEnd) x = calculateOperationTime(e, wanted,
false, &actual);
775 else x = calculateOperationTime(s, wanted,
true, &actual);
787 TimePeriod wanted(duration + static_cast<long>(duration_per * q));
788 x = calculateOperationTime(e, wanted,
false, &actual);
789 if (actual == wanted)
795 else if (actual < duration)
805 double max_q = duration_per ?
806 static_cast<double>(actual-duration) / duration_per :
808 q = opplan->
setQuantity(q < max_q ? q : max_q,
true,
false, execute);
809 wanted = duration +
static_cast<long>(duration_per * q);
810 x = calculateOperationTime(e, wanted,
false, &actual);
821 duration + static_cast<long>(duration_per * q)
824 x = calculateOperationTime(s, wanted,
true, &actual);
825 if (actual == wanted)
831 else if (actual < duration)
841 double max_q = duration_per ?
842 static_cast<double>(actual-duration) / duration_per :
844 q = opplan->
setQuantity(q < max_q ? q : max_q,
true,
false, execute);
845 wanted = duration +
static_cast<long>(duration_per * q);
846 x = calculateOperationTime(e, wanted,
false, &actual);
913 for (Operationlist::const_iterator i = steps.begin(); i!=steps.end(); ++i)
939 else throw LogicException(
"Incorrect object type during read operation");
950 throw LogicException(
"Incorrect parameters for routing operationplan");
971 bool realfirst =
true;
975 for (
OperationPlan* i = opplan->lastsubopplan; i; i = i->prevsubopplan)
978 x = i->getOperation()->setOperationPlanParameters(i,q,Date::infinitePast,e,preferEnd,execute);
991 for (
OperationPlan *i = opplan->firstsubopplan; i; i = i->nextsubopplan)
994 x = i->getOperation()->setOperationPlanParameters(i,q,s,Date::infinitePast,preferEnd,execute);
1006 "Updating a routing operationplan without start or end date argument"
1019 if (d != Date::infiniteFuture)
1022 for (Operation::Operationlist::const_reverse_iterator e =
1026 d, NULL, o, 0,
true);
1036 for (Operation::Operationlist::const_iterator e =
1040 Date::infinitePast, NULL, o, 0,
true);
1051 if (c ==
"PRIORITY")
return PRIORITY;
1052 if (c ==
"MINCOST")
return MINCOST;
1063 Operationlist::iterator altIter = alternates.begin();
1064 alternatePropertyList::iterator propIter = alternateProperties.begin();
1065 while (altIter!=alternates.end() && prio >= propIter->first)
1071 alternates.insert(altIter,o);
1081 suboperation of alternate operation '" +
getName() +
"'");
1082 Operationlist::const_iterator altIter = alternates.begin();
1083 alternatePropertyList::const_iterator propIter = alternateProperties.begin();
1084 while (altIter!=alternates.end() && *altIter != o)
1089 if (*altIter == o)
return *propIter;
1091 "' isn't a suboperation of alternate operation '" +
getName() +
"'");
1098 Operationlist::const_iterator altIter = alternates.begin();
1099 alternatePropertyList::iterator propIter = alternateProperties.begin();
1100 while (altIter!=alternates.end() && *altIter != o)
1106 propIter->first = f;
1109 "' isn't a suboperation of alternate operation '" +
getName() +
"'");
1116 Operationlist::const_iterator altIter = alternates.begin();
1117 alternatePropertyList::iterator propIter = alternateProperties.begin();
1118 while (altIter!=alternates.end() && *altIter != o)
1124 propIter->second = dr;
1127 "' isn't a suboperation of alternate operation '" +
getName() +
"'");
1153 alternatePropertyList::const_iterator propIter = alternateProperties.begin();
1154 for (Operationlist::const_iterator i = alternates.begin();
1155 i != alternates.end(); ++i)
1160 if (propIter->second.getStart() != Date::infinitePast)
1162 if (propIter->second.getEnd() != Date::infiniteFuture)
1186 typedef pair<Operation*,alternateProperty> tempData;
1191 tempData* tmp =
static_cast<tempData*
>(pIn.
getUserArea());
1195 addAlternate(tmp->first, tmp->second.first, tmp->second.second);
1198 tmp->second.first = 1;
1202 tmp->second.first = pElement.
getInt();
1206 tmp->second.second.setStart(pElement.
getDate());
1208 tmp->second.second.setEnd(pElement.
getDate());
1213 if (b) tmp->first = b;
1214 else throw LogicException(
"Incorrect object type during read operation");
1230 throw LogicException(
"Incorrect parameters for alternate operationplan");
1236 x = x->prevsubopplan;
1268 if (props.first != 0.0 && props.second.within(o->
getDates().
getEnd()))
1273 (*altIter)->createOperationPlan(
1283 Operationlist::iterator altIter = alternates.begin();
1284 alternatePropertyList::iterator propIter = alternateProperties.begin();
1285 while (altIter!=alternates.end() && *altIter != o)
1292 alternates.erase(altIter);
1293 alternateProperties.erase(propIter);
1294 o->superoplist.remove(
this);
1298 logger <<
"Warning: operation '" << *o
1299 <<
"' isn't a suboperation of alternate operation '" << *
this
1317 throw LogicException(
"Setup operationplan always must have an owner");
1320 if (g->getResource()->getSetupMatrix() && !g->getSetup().empty())
1322 ldplan =
new LoadPlan(opplan, &*g);
1331 const Load* lastld = NULL;
1332 Date boundary = s ? s : e;
1333 if (ldplan->
getDate() < boundary)
1379 if (preferEnd) x = calculateOperationTime(e, duration,
false, &actualduration);
1380 else x = calculateOperationTime(s, duration,
true, &actualduration);
1382 else if (s) x = calculateOperationTime(s, duration,
true, &actualduration);
1383 else x = calculateOperationTime(e, duration,
false, &actualduration);
1387 else if (actualduration == duration)
1562 if (!altoper)
throw LogicException(
"Can't add alternates to NULL alternate");
1565 PyObject *oper = NULL;
1567 PyObject *eff_start = NULL;
1568 PyObject *eff_end = NULL;
1569 static const char *kwlist[] = {
"operation",
"priority",
"effective_start",
"effective_end", NULL};
1570 if (!PyArg_ParseTupleAndKeywords(args, kwdict,
1571 "O|iOO:addAlternate",
1572 const_cast<char**>(kwlist), &oper, &prio, &eff_start, &eff_end))
1575 throw DataException(
"alternate operation must be of type operation");
1589 altoper->
addAlternate(static_cast<Operation*>(oper), prio, eff);
1593 PythonType::evalException();
1596 return Py_BuildValue(
"");
1620 if (!oper)
throw LogicException(
"Can't add steps to NULL routing");
1624 for (
unsigned int i=0; i<4; ++i) steps[i] = NULL;
1625 if (PyArg_UnpackTuple(args,
"addStep", 1, 4, &steps[0], &steps[1], &steps[2], &steps[3]))
1626 for (
unsigned int i=0; i<4 && steps[i]; ++i)
1629 throw DataException(
"routing steps must be of type operation");
1630 oper->
addStepBack(static_cast<Operation*>(steps[i]));
1635 PythonType::evalException();
1638 return Py_BuildValue(
"");