35 using namespace frepple::utils;
45 class ResourceInfinite;
51 class OperationPlanState;
52 class OperationFixedTime;
53 class OperationTimePer;
54 class OperationRouting;
55 class OperationAlternate;
67 class PeggingIterator;
178 startdate(start), enddate(end), nextBucket(NULL),
179 prevBucket(NULL), priority(priority), days(127), starttime(0L),
180 endtime(86400L), cal(c)
183 if (c->firstBucket) c->firstBucket->prevBucket =
this;
184 nextBucket = c->firstBucket;
185 c->firstBucket =
this;
241 void setDays(
short p)
244 throw DataException(
"Calendar bucket days must be between 0 and 127");
257 if (t > 86399L || t < 0L)
258 throw DataException(
"Calendar bucket start time must be between 0 and 86399 seconds");
271 if (t > 86400L || t < 0L)
272 throw DataException(
"Calendar bucket end time must be between 0 and 86400 seconds");
337 static DECLARE_EXPORT PyObject* addPythonBucket(PyObject*, PyObject*, PyObject*);
356 bool forward =
true) : theCalendar(c), curDate(d)
358 curBucket = lastBucket = c ? c->findBucket(d,forward) : NULL;
359 curPriority = lastPriority = curBucket ? curBucket->priority : INT_MAX;
381 {
return b.curBucket != curBucket;}
383 {
return b.curBucket == curBucket;}
385 {
if (curBucket) curBucket = curBucket->nextBucket;
return *
this;}
389 {
if(curBucket) curBucket = curBucket->prevBucket;
return *
this;}
392 Bucket* operator ->()
const {
return curBucket;}
393 Bucket& operator *()
const {
return *curBucket;}
414 virtual size_t getSize()
const
416 size_t i =
sizeof(
Calendar) + getName().size();
424 int lowestPriority()
const
428 if (i->getPriority() < min) min = i->getPriority();
439 virtual Bucket* createNewBucket(
Date start,
Date end,
int id=1,
int priority=0)
440 {
return new Bucket(
this, start, end,
id, priority);}
461 :
Bucket(c, start, end, id, priority), val(0) {initType(metadata);}
488 Bucket::endElement(pIn, pAttr, pElement);
492 virtual size_t getSize()
const
521 {setDefault(0.0); initType(metadata);}
532 static DECLARE_EXPORT PyObject* setPythonValue(PyObject*, PyObject*, PyObject*);
538 double getValue(
const Date d)
const
541 return x ? x->
getValue() : defaultValue;
547 void setValue(
Date start,
Date end,
const double v);
558 virtual bool getBool()
const {
return defaultValue != 0;}
567 Bucket* createNewBucket(
Date start,
Date end,
int id,
int priority=0)
568 {
return new BucketDouble(
this, start, end,
id, priority);}
610 {initType(metadata);}
621 virtual const DateRange getDates()
const = 0;
624 virtual string getDescription()
const = 0;
627 virtual string getEntity()
const = 0;
634 virtual bool isFeasible()
const = 0;
640 virtual double getWeight()
const = 0;
648 PyObject* str()
const
681 virtual Object* getOwner()
const = 0;
761 virtual Plannable* getEntity()
const = 0;
769 virtual void updateProblems() = 0;
815 bool empty()
const {
return first == NULL;}
851 virtual void solve(
void* = NULL) = 0;
852 virtual void solve(
const Demand*,
void* = NULL)
855 {
throw LogicException(
"Called undefined solve(Operation*) method");}
857 {
solve(reinterpret_cast<const Operation*>(o),v);}
859 {
solve(reinterpret_cast<const Operation*>(o),v);}
861 {
solve(reinterpret_cast<const Operation*>(o),v);}
863 {
solve(reinterpret_cast<const Operation*>(o),v);}
865 {
throw LogicException(
"Called undefined solve(Resource*) method");}
867 {
solve(reinterpret_cast<const Resource*>(r),v);}
868 virtual void solve(
const Buffer*,
void* = NULL)
871 {
solve(reinterpret_cast<const Buffer*>(b),v);}
873 {
solve(reinterpret_cast<const Buffer*>(b),v);}
874 virtual void solve(
const Load* b,
void* v = NULL)
876 virtual void solve(
const Flow* b,
void* v = NULL)
878 virtual void solve(
const FlowEnd* b,
void* v = NULL)
879 {
solve(reinterpret_cast<const Flow*>(b),v);}
881 {
throw LogicException(
"Called undefined solve(Solvable*) method");}
906 unsigned short loglevel;
959 void setChanged(
bool b =
true) {changed=b;
if (b) anyChange=
true;}
969 bool useProblemDetection;
1030 unsigned short cluster;
1073 static unsigned short getNumberOfClusters()
1075 if (recomputeLevels || computationBusy) computeLevels();
1076 return numberOfClusters;
1084 static unsigned short getNumberOfHangingClusters()
1086 if (recomputeLevels || computationBusy) computeLevels();
1087 return numberOfHangingClusters;
1091 short getLevel()
const
1093 if (recomputeLevels || computationBusy) computeLevels();
1098 unsigned short getCluster()
const
1100 if (recomputeLevels || computationBusy) computeLevels();
1142 size_t extrasize()
const
1163 virtual size_t getSize()
const
1182 size_t extrasize()
const
1199 virtual size_t getSize()
const
1225 loc(NULL), size_minimum(1.0), size_multiple(0.0), size_maximum(DBL_MAX),
1226 cost(0.0), hidden(false), first_opplan(NULL), last_opplan(NULL) {}
1255 throw DataException(
"No negative pre-operation time allowed");
1274 throw DataException(
"No negative post-operation time allowed");
1289 void setCost(
const double c)
1291 if (c >= 0) cost = c;
1292 else throw DataException(
"Operation cost must be positive");
1302 bool makeflowsloads=
true)
const;
1398 {
return flowdata.find(b,d);}
1403 {
return loaddata.find(r,d);}
1408 DECLARE_EXPORT void deleteOperationPlans(
bool deleteLockedOpplans =
false);
1413 void setSizeMinimum(
double f)
1416 throw DataException(
"Operation can't have a negative minimum size");
1425 void setSizeMultiple(
double f)
1428 throw DataException(
"Operation can't have a negative multiple size");
1437 void setSizeMaximum(
double f)
1439 if (f < size_minimum)
1440 throw DataException(
"Operation maximum size must be higher than the minimum size");
1442 throw DataException(
"Operation maximum size must be greater than 0");
1457 size_t extrasize()
const
1492 void setHidden(
bool b) {
if (hidden!=b) setChanged(); hidden = b;}
1538 double size_minimum;
1541 double size_multiple;
1544 double size_maximum;
1609 int sizeFlowPlans()
const;
1620 int sizeLoadPlans()
const;
1641 opplan = x ? x->firstsubopplan : NULL;
1651 opplan = op->getFirstOpPlan();
1670 opplan = opplan->nextsubopplan;
1672 opplan = opplan->next;
1674 if (!opplan &&
mode == 3)
1679 opplan = op->getFirstOpPlan();
1692 opplan = opplan->nextsubopplan;
1694 opplan = opplan->next;
1696 if (!opplan &&
mode==3)
1700 opplan = op->getFirstOpPlan();
1718 Operation::iterator op;
1735 static bool empty() {
return begin()==end();}
1741 static unsigned long size()
1743 unsigned long cnt = 0;
1778 bool roundDown =
false,
bool update =
true,
bool execute =
true);
1824 dates.setStartAndEnd(st,nd);
1859 while (o->owner) o = o->owner;
1913 PyObject* str()
const
1921 static PyObject* create(PyTypeObject*, PyObject*, PyObject*);
1980 bool getHidden()
const {
return getOperation()->getHidden();}
1994 virtual void updateProblems();
2008 virtual size_t getSize()
const
2068 OperationPlan() : owner(NULL), quantity(0.0), flags(0), dmd(NULL),
2069 id(0), oper(NULL), firstflowplan(NULL), firstloadplan(NULL),
2070 prev(NULL), next(NULL), firstsubopplan(NULL), lastsubopplan(NULL),
2071 nextsubopplan(NULL), prevsubopplan(NULL), motive(NULL)
2072 {initType(metadata);}
2075 static const short IS_LOCKED = 1;
2076 static const short IS_SETUP = 2;
2077 static const short HAS_SETUP = 4;
2080 OperationPlan *owner;
2126 FlowPlan* firstflowplan;
2129 LoadPlan* firstloadplan;
2135 OperationPlan* prev;
2141 OperationPlan* next;
2144 OperationPlan* firstsubopplan;
2147 OperationPlan* lastsubopplan;
2150 OperationPlan* nextsubopplan;
2153 OperationPlan* prevsubopplan;
2190 : start(x), end(y), quantity(q) {}
2194 : start(x.getStart()), end(x.getEnd()), quantity(q) {}
2214 throw DataException(
"FixedTime operation can't have a negative duration");
2228 virtual size_t getSize()
const
2271 virtual size_t getSize()
const
2302 throw DataException(
"TimePer operation can't have a negative duration");
2313 throw DataException(
"TimePer operation can't have a negative duration-per");
2344 virtual size_t getSize()
const
2371 if (!o)
throw DataException(
"Adding NULL operation to routing");
2372 steps.push_front(o);
2379 if (!o)
throw DataException(
"Adding NULL operation to routing");
2389 {steps.remove(o); o->superoplist.remove(
this);}
2422 virtual size_t getSize()
const
2425 + steps.size() * 2 *
sizeof(
Operation*);
2434 Operationlist steps;
2440 getOperation()->setOperationPlanParameters(
this, x.
quantity, x.
start, x.
end,
true);
2443 assert(dates.getEnd() == x.
end || x.
start!=x.
end);
2469 case PRIORITY: os <<
"PRIORITY";
return os;
2470 case MINCOST: os <<
"MINCOST";
return os;
2471 case MINPENALTY: os <<
"MINPENALTY";
return os;
2473 default: assert(
false);
return os;
2552 static DECLARE_EXPORT PyObject* addAlternate(PyObject*, PyObject*, PyObject*);
2556 virtual size_t getSize()
const
2567 typedef list<alternateProperty> alternatePropertyList;
2571 alternatePropertyList alternateProperties;
2579 Operationlist alternates;
2596 deliveryOperation(NULL), price(0.0) {}
2605 if (deliveryOperation)
return deliveryOperation;
2609 if (i->deliveryOperation)
return i->deliveryOperation;
2627 void setPrice(
const double c)
2629 if (c >= 0) price = c;
2665 virtual size_t getSize()
const
2689 hidden(false), producing_operation(NULL), loc(NULL), it(NULL),
2690 min_val(0), max_val(default_max), min_cal(NULL), max_cal(NULL),
2691 carrying_cost(0.0) {}
2700 {producing_operation = o; setChanged();}
2751 void setCarryingCost(
const double c)
2753 if (c >= 0) carrying_cost = c;
2754 else throw DataException(
"Buffer carrying_cost must be positive");
2763 size_t extrasize()
const
2801 {
return flows.find(o,d);}
2807 DECLARE_EXPORT void deleteOperationPlans(
bool deleteLockedOpplans =
false);
2811 void setHidden(
bool b) {
if (hidden!=b) setChanged(); hidden = b;}
2882 double carrying_cost;
2893 virtual size_t getSize()
const
2912 virtual size_t getSize()
const
2915 {setDetectProblems(
false); initType(metadata);}
2979 virtual size_t getSize()
const
2987 size_minimum(0), size_maximum(DBL_MAX), size_multiple(0),
2988 oper(NULL) {initType(metadata);}
2998 throw DataException(
"Procurement buffer can't have a negative lead time");
3010 getOperation()->setFence(p);
3016 double getMinimumInventory()
const
3025 void setMinimumInventory(
double f)
3028 throw DataException(
"Procurement buffer can't have a negative minimum inventory");
3036 getFlowPlans().insert(min);
3040 setMaximumInventory(f);
3044 double getMaximumInventory()
const
3051 void setMaximumInventory(
double f)
3054 throw DataException(
"Procurement buffer can't have a negative maximum inventory");
3062 getFlowPlans().insert(max);
3066 setMinimumInventory(f);
3079 throw DataException(
"Procurement buffer can't have a negative minimum interval");
3082 if (max_interval < min_interval) max_interval = min_interval;
3094 throw DataException(
"Procurement buffer can't have a negative maximum interval");
3097 if (max_interval < min_interval) min_interval = max_interval;
3104 void setSizeMinimum(
double f)
3107 throw DataException(
"Procurement buffer can't have a negative minimum size");
3109 getOperation()->setSizeMinimum(f);
3111 if (size_maximum < size_minimum) size_maximum = size_minimum;
3118 void setSizeMaximum(
double f)
3121 throw DataException(
"Procurement buffer can't have a negative maximum size");
3123 getOperation()->setSizeMaximum(f);
3125 if (size_maximum < size_minimum) size_minimum = size_maximum;
3132 void setSizeMultiple(
double f)
3135 throw DataException(
"Procurement buffer can't have a negative multiple size");
3137 getOperation()->setSizeMultiple(f);
3165 double size_minimum;
3170 double size_maximum;
3175 double size_multiple;
3195 : quantity(q), hasAlts(false), altFlow(NULL), search(
PRIORITY)
3200 try { validate(
ADD); }
3203 if (getOperation()) getOperation()->flowdata.erase(
this);
3204 if (getBuffer()) getBuffer()->flows.erase(
this);
3205 resetReferenceCount();
3212 : quantity(q), hasAlts(false), altFlow(NULL), search(
PRIORITY)
3218 try { validate(
ADD); }
3221 if (getOperation()) getOperation()->flowdata.erase(
this);
3222 if (getBuffer()) getBuffer()->flows.erase(
this);
3223 resetReferenceCount();
3284 virtual bool getHidden()
const
3286 return (getBuffer() && getBuffer()->getHidden())
3287 || (getOperation() && getOperation()->getHidden());
3294 virtual double getFlowplanQuantity(
const FlowPlan*)
const;
3306 virtual size_t getSize()
const {
return sizeof(
Flow) + getName().size();}
3310 explicit Flow() : quantity(0.0), hasAlts(false),
3311 altFlow(NULL), search(
PRIORITY) {initType(metadata);}
3331 static PyObject* create(PyTypeObject* pytype, PyObject* args, PyObject* kwds);
3377 virtual Date getFlowplanDate(
const FlowPlan* fl)
const;
3435 Buffer* b = getFlow()->getBuffer();
3437 b->flowplans.
erase(
this);
3453 void setQuantity(
double qty,
bool b=
false,
bool u =
true)
3455 if (getFlow()->getEffective().within(getDate()))
3456 oper->setQuantity(qty / getFlow()->getQuantity(), b, u);
3466 {
return &(getFlow()->getBuffer()->flowplans);}
3477 return getEffective().within(fl->
getDate()) ?
3523 size_t getSize()
const
3524 {
return sizeof(
Rule) + from.size() + to.size();}
3600 {
return b.curRule != curRule;}
3602 {
return b.curRule == curRule;}
3604 {
if (curRule) curRule = curRule->nextRule;
return *
this;}
3608 {
if(curRule) curRule = curRule->prevRule;
return *
this;}
3611 Rule* operator ->()
const {
return curRule;}
3612 Rule& operator *()
const {
return *curRule;}
3638 virtual size_t getSize()
const
3640 size_t i =
sizeof(
SetupMatrix) + getName().size();
3641 for (
RuleIterator j = beginRules(); j!= endRules(); ++j)
3646 size_t extrasize()
const
3648 size_t i = getName().size();
3649 for (
RuleIterator j = beginRules(); j!= endRules(); ++j)
3661 static DECLARE_EXPORT PyObject* addPythonRule(PyObject*, PyObject*, PyObject*);
3680 DECLARE_EXPORT Rule* calculateSetup(
const string,
const string)
const;
3697 virtual size_t getSize()
const
3721 static DECLARE_EXPORT PyObject* addPythonResource(PyObject*, PyObject*);
3733 virtual size_t getSize()
const
3735 size_t i =
sizeof(
Skill) + getName().size() + resources.size() * 3 *
sizeof(
Resource*);
3739 size_t extrasize()
const
3741 return getName().size() + resources.size() * 3 *
sizeof(
Resource*);
3746 resourcelist resources;
3759 virtual size_t getSize()
const
3780 static const long defaultMaxEarly = 100*86400L;
3784 size_max_cal(NULL), size_max(0), loc(NULL), cost(0.0), hidden(false), maxearly(defaultMaxEarly),
3785 setupmatrix(NULL) { setMaximum(1); };
3808 void setCost(
const double c)
3810 if (c >= 0) cost = c;
3835 {
return loads.find(o,d);}
3846 size_t extrasize()
const
3849 + setup.size() + skills.size() * 3 *
sizeof(
Skill*);
3871 void setHidden(
bool b) {
if (hidden!=b) setChanged(); hidden = b;}
3885 if (c >= 0L) maxearly = c;
3911 loadplanlist loadplans;
3939 static PyObject* plan(PyObject*, PyObject*);
3966 PyObject* bucketiterator;
3969 Resource::loadplanlist::iterator ldplaniter;
3972 PyObject* iternext();
3981 bool hasUnavailability;
3982 double bucket_available;
3984 double bucket_setup;
3985 double bucket_unavailable;
3987 void update(
Date till);
3990 PyObject* start_date;
4006 virtual size_t getSize()
const
4021 {setDetectProblems(
false); initType(metadata);}
4023 virtual size_t getSize()
const
4069 static PyObject* create(PyTypeObject*, PyObject*, PyObject*);
4089 : hasAlts(false), altLoad(NULL), search(
PRIORITY), skill(NULL)
4095 try { validate(
ADD); }
4098 if (getOperation()) getOperation()->loaddata.erase(
this);
4099 if (getResource()) getResource()->loads.erase(
this);
4100 resetReferenceCount();
4107 : hasAlts(false), altLoad(NULL), search(
PRIORITY), skill(NULL)
4114 try { validate(
ADD); }
4117 if (getOperation()) getOperation()->loaddata.erase(
this);
4118 if (getResource()) getResource()->loads.erase(
this);
4119 resetReferenceCount();
4148 void setQuantity(
double f)
4150 if (f < 0)
throw DataException(
"Load quantity can't be negative");
4184 virtual double getLoadplanQuantity(
const LoadPlan*)
const;
4194 bool getHidden()
const
4196 return (getResource() && getResource()->getHidden())
4197 || (getOperation() && getOperation()->getHidden());
4203 virtual size_t getSize()
const
4204 {
return sizeof(
Load) + getName().size() + getSetup().size();}
4207 Load() : qty(1.0), hasAlts(false), altLoad(NULL),
4208 search(
PRIORITY), skill(NULL) {initType(metadata);}
4242 static PyObject* create(PyTypeObject*, PyObject*, PyObject*);
4332 virtual size_t getSize()
const
4333 {
return sizeof(
Plan) + name.size() + descr.size();}
4350 it(NULL), oper(NULL), cust(NULL), qty(0.0), prio(0),
4351 maxLateness(
TimePeriod::MAX), minShipment(1), hidden(false) {}
4357 deleteOperationPlans(
true);
4399 int getCluster()
const
4460 size_t extrasize()
const
4463 +
sizeof(
void*) * 2 * deli.size();
4480 throw DataException(
"The maximum demand lateness must be positive");
4494 virtual void setMinShipment(
double m)
4497 throw DataException(
"The minumum demand shipment quantity must be positive");
4562 virtual size_t getSize()
const
4609 bool isStart()
const {
return start_or_end == START;}
4621 {
return &(res->loadplans);}
4657 enum type {START, END};
4683 return dr.
getStart() > getEffective().getStart() ?
4685 getEffective().getStart();
4687 return dr.
getEnd() < getEffective().getEnd() ?
4689 getEffective().getEnd();
4702 return lp->
isStart() ? getQuantity() : -getQuantity();
4714 string getDescription()
const
4718 << (oper ? oper :
static_cast<OperationPlan*
>(getOwner())->getOperation())
4719 <<
"' planned in the past";
4723 double getWeight()
const
4724 {
return oper ? state.quantity :
dynamic_cast<OperationPlan*
>(getOwner())->getQuantity();}
4726 {
if (add) addProblem();}
4728 : oper(o), state(st, nd, q) {}
4732 {
return oper ?
static_cast<Object*
>(oper) : dynamic_cast<OperationPlan*>(owner);}
4735 if (oper)
return DateRange(state.start, state.end);
4766 string getDescription()
const
4770 << (oper ? oper :
static_cast<OperationPlan*
>(getOwner())->getOperation())
4771 <<
"' planned before fence";
4775 double getWeight()
const
4776 {
return oper ? state.quantity :
static_cast<OperationPlan*
>(getOwner())->getQuantity();}
4779 {
if (add) addProblem();}
4781 : oper(o), state(st, nd, q) {}
4785 {
return oper ?
static_cast<Object*
>(oper) : dynamic_cast<OperationPlan*>(owner);}
4788 if (oper)
return DateRange(state.start, state.end);
4818 string getDescription()
const
4821 if (!o->nextsubopplan)
4822 return string(
"Bogus precedence problem on '")
4826 +
"' starts before operation '"
4831 double getWeight()
const
4833 return static_cast<double>(getDates().getDuration()) / 86400;
4836 {
if (add) addProblem();}
4865 string getDescription()
const
4866 {
return string(
"Demand '") + getDemand()->getName() +
"' is not planned";}
4868 double getWeight()
const {
return getDemand()->getQuantity();}
4870 {
if (add) addProblem();}
4874 {
return DateRange(getDemand()->getDue(),getDemand()->getDue());}
4899 double getWeight()
const
4901 assert(getDemand() && !getDemand()->getDelivery().empty());
4903 getDemand()->getDue(),
4904 getDemand()->getLatestDelivery()->getDates().getEnd()
4910 {
if (add) addProblem();}
4917 assert(getDemand() && !getDemand()->getDelivery().empty());
4919 getDemand()->getLatestDelivery()->getDates().getEnd());
4942 double getWeight()
const
4944 assert(getDemand() && !getDemand()->getDelivery().empty());
4946 getDemand()->getDue(),
4947 getDemand()->getEarliestDelivery()->getDates().getEnd()
4951 {
if (add) addProblem();}
4957 assert(getDemand() && !getDemand()->getDelivery().empty());
4959 getDemand()->getEarliestDelivery()->getDates().getEnd());
4982 Date st,
Date nd,
double q,
bool add =
true)
4983 :
Problem(o), description(d), entity(e), dates(st,nd), qty(q)
4984 {
if (add) addProblem();}
4990 if (entity ==
"demand")
return dynamic_cast<Demand*
>(owner);
4991 if (entity ==
"buffer")
return dynamic_cast<Buffer*
>(owner);
4992 if (entity ==
"resource")
return dynamic_cast<Resource*
>(owner);
4993 if (entity ==
"operation")
return dynamic_cast<Operation*
>(owner);
4996 size_t getSize()
const
5020 string getDescription()
const
5023 ch <<
"Demand '" << getDemand()->getName() <<
"' planned "
5024 << (getDemand()->getQuantity() - getDemand()->getPlannedQuantity())
5029 double getWeight()
const
5030 {
return getDemand()->getQuantity() - getDemand()->getPlannedQuantity();}
5032 {
if (add) addProblem();}
5036 {
return DateRange(getDemand()->getDue(), getDemand()->getDue());}
5055 string getDescription()
const
5058 ch <<
"Demand '" << getDemand()->getName() <<
"' planned "
5059 << (getDemand()->getPlannedQuantity() - getDemand()->getQuantity())
5064 double getWeight()
const
5065 {
return getDemand()->getPlannedQuantity() - getDemand()->getQuantity();}
5067 {
if (add) addProblem();}
5072 {
return DateRange(getDemand()->getDue(), getDemand()->getDue());}
5094 :
Problem(r), qty(q), dr(st,nd) {
if (add) addProblem();}
5127 :
Problem(r), qty(q), dr(d) {
if (add) addProblem();}
5160 :
Problem(b), qty(q), dr(st,nd) {
if (add) addProblem();}
5193 :
Problem(b), qty(q), dr(st,nd) {
if (add) addProblem();}
5242 virtual void rollback() {
delete opplan; opplan = NULL;}
5243 virtual void undo() {
if (opplan) opplan->deleteFlowLoads();}
5244 virtual void redo() {
if (opplan) opplan->createFlowLoads();}
5260 virtual void commit()
5262 if (opplan)
delete opplan;
5267 if (!opplan)
return;
5268 opplan->createFlowLoads();
5269 if (opplan->getIdentifier())
5271 opplan->insertInOperationplanList();
5272 if (opplan->getDemand())
5273 opplan->getDemand()->addDelivery(opplan);
5278 if (!opplan)
return;
5279 opplan->deleteFlowLoads();
5280 if (opplan->getIdentifier())
5282 opplan->removeFromOperationplanList();
5283 if (opplan->getDemand())
5284 opplan->getDemand()->removeDelivery(opplan);
5287 virtual void rollback()
5321 Date newStart,
Date newEnd,
double newQty = -1.0);
5330 virtual void rollback() {restore(
true); opplan = NULL;}
5332 virtual void undo() {restore(
false);}
5351 assert(opplan->getOperation());
5353 opplan->getOperation()->setOperationPlanParameters(opplan, q, s, e, b);
5413 unsigned short type;
5479 owner(o), eiter(4) {}
5485 owner(NULL), eiter(4) {}
5541 : downstream(b), firstIteration(true)
5545 states.push(state(0,abs(e->
getQuantity()),1.0,e,NULL));
5547 states.push(state(0,abs(e->
getQuantity()),1.0,NULL,e));
5554 const FlowPlan* x = states.top().cons_flowplan;
5561 const FlowPlan* x = states.top().prod_flowplan;
5562 if (!x) x = states.top().cons_flowplan;
5569 const FlowPlan* x = states.top().prod_flowplan;
5576 const FlowPlan* x = states.top().cons_flowplan;
5583 const FlowPlan* x = states.top().prod_flowplan;
5601 double getQuantityBuffer()
const
5603 const state& t = states.top();
5604 return t.prod_flowplan
5605 ? t.factor * t.prod_flowplan->getOperationPlan()->getQuantity()
5625 PeggingIterator operator++(
int)
5626 {PeggingIterator tmp = *
this; ++*
this;
return tmp;}
5635 PeggingIterator operator--(
int)
5636 {PeggingIterator tmp = *
this; --*
this;
return tmp;}
5639 bool operator==(
const PeggingIterator& x)
const {
return states == x.states;}
5642 bool operator!=(
const PeggingIterator& x)
const {
return states != x.states;}
5648 operator bool ()
const {
return !states.empty();}
5665 size_t getSize()
const {
return sizeof(PeggingIterator);}
5695 state(
unsigned int l,
double d,
double f,
5697 : qty(d), factor(f), level(l),
5698 cons_flowplan(fc), prod_flowplan(fp), pegged(p) {};
5701 bool operator != (
const state& s)
const
5703 return cons_flowplan != s.cons_flowplan
5704 || prod_flowplan != s.prod_flowplan
5705 || level != s.level;
5709 bool operator == (
const state& s)
const
5711 return cons_flowplan == s.cons_flowplan
5712 && prod_flowplan == s.prod_flowplan
5713 && level == s.level;
5718 typedef stack < state > statestack;
5729 DECLARE_EXPORT void followPegging(
const OperationPlan*,
short,
double,
double);
5743 bool firstIteration;
5761 curflowplan = b.curflowplan;
5762 prevflowplan = b.prevflowplan;
5765 {
return b.curflowplan != curflowplan;}
5767 {
return b.curflowplan == curflowplan;}
5770 prevflowplan = curflowplan;
5771 if (curflowplan) curflowplan = curflowplan->nextFlowPlan;
5778 void deleteFlowPlan()
5780 if (!curflowplan)
return;
5781 if (prevflowplan) prevflowplan->nextFlowPlan = curflowplan->nextFlowPlan;
5782 else curflowplan->oper->firstflowplan = curflowplan->nextFlowPlan;
5785 curflowplan = curflowplan->nextFlowPlan;
5818 curloadplan = b.curloadplan;
5819 prevloadplan = b.prevloadplan;
5822 {
return b.curloadplan != curloadplan;}
5824 {
return b.curloadplan == curloadplan;}
5827 prevloadplan = curloadplan;
5828 if (curloadplan) curloadplan = curloadplan->nextLoadPlan;
5835 void deleteLoadPlan()
5837 if (!curloadplan)
return;
5838 if (prevloadplan) prevloadplan->nextLoadPlan = curloadplan->nextLoadPlan;
5839 else curloadplan->oper->firstloadplan = curloadplan->nextLoadPlan;
5842 curloadplan = curloadplan->nextLoadPlan;
5865 :
public FreppleIterator<ProblemIterator,Problem::const_iterator,Problem>
5883 :
public FreppleIterator<BufferIterator,Buffer::memberIterator,Buffer>
5892 :
public FreppleIterator<LocationIterator,Location::memberIterator,Location>
5901 :
public FreppleIterator<CustomerIterator,Customer::memberIterator,Customer>
5919 :
public FreppleIterator<DemandIterator,Demand::memberIterator,Demand>
5928 :
public FreppleIterator<ResourceIterator,Resource::memberIterator,Resource>
5943 :
public FreppleIterator<OperationIterator,Operation::iterator,Operation>
5949 :
public FreppleIterator<CalendarIterator,Calendar::iterator,Calendar>
5955 :
public FreppleIterator<SetupMatrixIterator,SetupMatrix::iterator,SetupMatrix>
5986 PyObject *iternext();
6000 : res(r), ir(r ? r->getSkills().begin() : NULL), skill(NULL), is(NULL)
6003 throw LogicException(
"Creating resourceskill iterator for NULL resource");
6007 : res(NULL), ir(NULL), skill(s), is(s ? s->getResources().begin() : NULL)
6010 throw LogicException(
"Creating resourceskill iterator for NULL skill");
6015 Resource::skilllist::const_iterator ir;
6017 Skill::resourcelist::const_iterator is;
6018 PyObject *iternext();
6035 throw LogicException(
"Creating bucket iterator for NULL calendar");
6042 PyObject *iternext();
6053 : cal(c), eventiter(c,d,f), forward(f) {}
6059 PyObject *iternext();
6069 :
public FreppleIterator<OperationPlanIterator,OperationPlan::iterator,OperationPlan>
6102 throw LogicException(
"Creating flowplan iterator for NULL buffer");
6110 throw LogicException(
"Creating flowplan iterator for NULL operationplan");
6116 if (buffer_or_opplan)
delete bufiter;
6117 else delete opplaniter;
6135 bool buffer_or_opplan;
6137 PyObject *iternext();
6154 throw LogicException(
"Creating loadplan iterator for NULL resource");
6155 resiter =
new Resource::loadplanlist::const_iterator(r->
getLoadPlans().
begin());
6161 throw LogicException(
"Creating loadplan iterator for NULL operationplan");
6167 if (resource_or_opplan)
delete resiter;
6168 else delete opplaniter;
6186 bool resource_or_opplan;
6188 PyObject *iternext();
6205 throw LogicException(
"Creating demandplan iterator for NULL demand");
6211 Demand::OperationPlan_list::const_iterator i;
6212 PyObject *iternext();
6227 : res(r), ir(r ? r->getLoads().begin() : NULL), oper(NULL), io(NULL)
6230 throw LogicException(
"Creating loadplan iterator for NULL resource");
6234 : res(NULL), ir(NULL), oper(o), io(o ? o->getLoads().begin() : NULL)
6237 throw LogicException(
"Creating loadplan iterator for NULL operation");
6242 Resource::loadlist::const_iterator ir;
6244 Operation::loadlist::const_iterator io;
6245 PyObject *iternext();
6260 : buf(b), ib(b ? b->getFlows().begin() : NULL), oper(NULL), io(NULL)
6263 throw LogicException(
"Creating flowplan iterator for NULL buffer");
6267 : buf(NULL), ib(NULL), oper(o), io(o ? o->getFlows().begin() : NULL)
6270 throw LogicException(
"Creating flowplan iterator for NULL operation");
6278 PyObject *iternext();