42 if (userexit_demand) userexit_demand.
call(l,
PythonObject(data->constrainedPlanning));
54 logger <<
" in unconstrained mode";
61 const_cast<Demand*
>(l)->deleteOperationPlans(
false, data);
71 if (plan_qty < l->getMinShipment()) plan_qty = l->
getMinShipment();
77 if (loglevel>0)
logger <<
" Nothing to be planned." << endl;
82 double best_q_qty = 0.0, best_a_qty = 0.0;
89 string problemtext = string(
"Demand '") + l->
getName() +
"' has no delivery operation";
116 logger <<
"Demand '" << l <<
"' asks: "
117 << plan_qty <<
" " << plan_date << endl;
124 double q_qty = plan_qty;
128 data->planningDemand =
const_cast<Demand*
>(l);
132 deliveryoper->
solve(*
this,v);
138 bool originalLogConstraints = data->logConstraints;
139 data->logConstraints =
false;
145 logger <<
"Demand '" << l <<
"' tries planning minimum quantity " << l->
getMinShipment() << endl;
151 deliveryoper->
solve(*
this,v);
159 double max_qty = plan_qty;
160 double delta = fabs(max_qty - min_qty);
164 double new_qty = floor((min_qty + max_qty) / 2);
166 logger <<
"Demand '" << l <<
"' tries planning a different quantity " << new_qty << endl;
172 deliveryoper->
solve(*
this,v);
181 delta = fabs(max_qty - min_qty);
187 logger <<
"Demand '" << l <<
"' restores plan for quantity " << min_qty << endl;
194 deliveryoper->
solve(*
this,v);
200 data->logConstraints = originalLogConstraints;
203 data->logConstraints = originalLogConstraints;
208 logger <<
"Demand '" << l <<
"' gets answer: "
209 << data->
state->
a_qty <<
" " << next_date <<
" "
213 Date copy_plan_date = plan_date;
222 || data->
state->
a_qty + ROUNDING_ERROR < l->getMinShipment()
235 best_q_date = plan_date;
242 if (next_date <= copy_plan_date)
247 logger <<
"Warning: Demand '" << l <<
"': Lazy retry" << endl;
252 plan_date = next_date;
267 logger <<
"Demand '" << l <<
"' plans coordination." << endl;
279 deliveryoper->
solve(*
this,v);
282 logger <<
"Warning: Demand '" << l <<
"': Failing coordination" << endl;
301 data->CommandManager::commit();
320 if (best_a_qty > 0.0 && data->constrainedPlanning)
322 if (loglevel>=2)
logger <<
"Demand '" << l <<
"' accepts a best answer." << endl;
326 for(
double remainder = best_q_qty;
333 deliveryoper->
solve(*
this,v);
336 logger <<
"Warning: Demand '" << l <<
"': Failing accepting best answer" << endl;
343 data->CommandManager::commit();
355 while (data->
state > mystate) data->
pop();
361 while (data->
state > mystate) data->
pop();
384 if (dynamic_cast<CommandList*>(&*cmd))
385 scanExcess(dynamic_cast<CommandList*>(&*cmd));
394 logger <<
"Denying creation of redundant operationplan "