33 if (userexit_demand) userexit_demand.
call(l,
PythonObject(data->constrainedPlanning));
45 logger <<
" in unconstrained mode";
52 const_cast<Demand*
>(l)->deleteOperationPlans(
false, data);
64 if (loglevel>0)
logger <<
" Nothing to be planned." << endl;
69 double best_q_qty = 0.0, best_a_qty = 0.0;
74 string problemtext = string(
"Demand '") + l->
getName() +
"' has no delivery operation";
89 && j->getDescription() == problemtext)
101 logger <<
"Demand '" << l <<
"' asks: "
102 << plan_qty <<
" " << plan_date << endl;
109 double q_qty = plan_qty;
113 data->planningDemand =
const_cast<Demand*
>(l);
117 deliveryoper->
solve(*
this,v);
123 bool originalLogConstraints = data->logConstraints;
124 data->logConstraints =
false;
130 logger <<
"Demand '" << l <<
"' tries planning minimum quantity " << l->
getMinShipment() << endl;
136 deliveryoper->
solve(*
this,v);
144 double max_qty = plan_qty;
145 double delta = fabs(max_qty - min_qty);
149 double new_qty = floor((min_qty + max_qty) / 2);
151 logger <<
"Demand '" << l <<
"' tries planning a different quantity " << new_qty << endl;
157 deliveryoper->
solve(*
this,v);
166 delta = fabs(max_qty - min_qty);
172 logger <<
"Demand '" << l <<
"' restores plan for quantity " << min_qty << endl;
179 deliveryoper->
solve(*
this,v);
185 data->logConstraints = originalLogConstraints;
188 data->logConstraints = originalLogConstraints;
193 logger <<
"Demand '" << l <<
"' gets answer: "
194 << data->
state->
a_qty <<
" " << next_date <<
" "
198 Date copy_plan_date = plan_date;
207 || data->
state->
a_qty + ROUNDING_ERROR < l->getMinShipment()
220 best_q_date = plan_date;
227 if (next_date <= copy_plan_date)
232 logger <<
"Warning: Demand '" << l <<
"': Lazy retry" << endl;
237 plan_date = next_date;
252 logger <<
"Demand '" << l <<
"' plans coordination." << endl;
264 deliveryoper->
solve(*
this,v);
267 logger <<
"Warning: Demand '" << l <<
"': Failing coordination" << endl;
286 data->CommandManager::commit();
305 if (best_a_qty > 0.0 && data->constrainedPlanning)
307 if (loglevel>=2)
logger <<
"Demand '" << l <<
"' accepts a best answer." << endl;
311 for(
double remainder = best_q_qty;
318 deliveryoper->
solve(*
this,v);
321 logger <<
"Warning: Demand '" << l <<
"': Failing accepting best answer" << endl;
328 data->CommandManager::commit();
357 if (dynamic_cast<CommandList*>(&*cmd))
358 scanExcess(dynamic_cast<CommandList*>(&*cmd));
367 logger <<
"Denying creation of redundant operationplan "