本文整理汇总了C++中PythonObject::getBool方法的典型用法代码示例。如果您正苦于以下问题:C++ PythonObject::getBool方法的具体用法?C++ PythonObject::getBool怎么用?C++ PythonObject::getBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonObject
的用法示例。
在下文中一共展示了PythonObject::getBool方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setattro
DECLARE_EXPORT int SolverMRP::setattro(const Attribute& attr, const PythonObject& field)
{
if (attr.isA(Tags::tag_constraints))
setConstraints(field.getInt());
else if (attr.isA(Tags::tag_autocommit))
setAutocommit(field.getBool());
else if (attr.isA(Tags::tag_userexit_flow))
setUserExitFlow(field);
else if (attr.isA(Tags::tag_userexit_demand))
setUserExitDemand(field);
else if (attr.isA(Tags::tag_userexit_buffer))
setUserExitBuffer(field);
else if (attr.isA(Tags::tag_userexit_resource))
setUserExitResource(field);
else if (attr.isA(Tags::tag_userexit_operation))
setUserExitOperation(field);
else if (attr.isA(Tags::tag_plantype))
setPlanType(field.getInt());
// Less common parameters
else if (attr.isA(tag_iterationthreshold))
setIterationThreshold(field.getDouble());
else if (attr.isA(tag_iterationaccuracy))
setIterationAccuracy(field.getDouble());
else if (attr.isA(tag_lazydelay))
setLazyDelay(field.getTimeperiod());
else if (attr.isA(tag_allowsplits))
setAllowSplits(field.getBool());
else if (attr.isA(tag_planSafetyStockFirst))
setPlanSafetyStockFirst(field.getBool());
// Default parameters
else
return Solver::setattro(attr, field);
return 0;
}
示例2: setattro
DECLARE_EXPORT int Item::setattro(const Attribute& attr, const PythonObject& field)
{
if (attr.isA(Tags::tag_name))
setName(field.getString());
else if (attr.isA(Tags::tag_description))
setDescription(field.getString());
else if (attr.isA(Tags::tag_category))
setCategory(field.getString());
else if (attr.isA(Tags::tag_subcategory))
setSubCategory(field.getString());
else if (attr.isA(Tags::tag_price))
setPrice(field.getDouble());
else if (attr.isA(Tags::tag_owner))
{
if (!field.check(Item::metadata))
{
PyErr_SetString(PythonDataException, "item owner must be of type item");
return -1;
}
Item* y = static_cast<Item*>(static_cast<PyObject*>(field));
setOwner(y);
}
else if (attr.isA(Tags::tag_operation))
{
if (!field.check(Operation::metadata))
{
PyErr_SetString(PythonDataException, "item operation must be of type operation");
return -1;
}
Operation* y = static_cast<Operation*>(static_cast<PyObject*>(field));
setOperation(y);
}
else if (attr.isA(Tags::tag_hidden))
setHidden(field.getBool());
else
return -1;
return 0;
}
示例3: setattro
DECLARE_EXPORT int Location::setattro(const Attribute& attr, const PythonObject& field)
{
if (attr.isA(Tags::tag_name))
setName(field.getString());
else if (attr.isA(Tags::tag_description))
setDescription(field.getString());
else if (attr.isA(Tags::tag_category))
setCategory(field.getString());
else if (attr.isA(Tags::tag_subcategory))
setSubCategory(field.getString());
else if (attr.isA(Tags::tag_owner))
{
if (!field.check(Location::metadata))
{
PyErr_SetString(PythonDataException, "location owner must be of type location");
return -1;
}
Location* y = static_cast<Location*>(static_cast<PyObject*>(field));
setOwner(y);
}
else if (attr.isA(Tags::tag_available))
{
if (!field.check(CalendarDouble::metadata))
{
PyErr_SetString(PythonDataException, "location availability must be of type double calendar");
return -1;
}
CalendarDouble* y = static_cast<CalendarDouble*>(static_cast<PyObject*>(field));
setAvailable(y);
}
else if (attr.isA(Tags::tag_hidden))
setHidden(field.getBool());
else
return -1;
return 0;
}
示例4: solve
DECLARE_EXPORT void SolverMRP::solve(const Flow* fl, void* v) // @todo implement search mode
{
// Note: This method is only called for consuming flows and for the leading
// flow of an alternate group. See SolverMRP::checkOperation
SolverMRPdata* data = static_cast<SolverMRPdata*>(v);
if (fl->hasAlternates())
{
// CASE I: It is an alternate flow.
// We ask each alternate flow in order of priority till we find a flow
// that has a non-zero reply.
// 1) collect a list of alternates
list<const Flow*> thealternates;
const Flow *x = fl->hasAlternates() ? fl : fl->getAlternate();
for (Operation::flowlist::const_iterator i = fl->getOperation()->getFlows().begin();
i != fl->getOperation()->getFlows().end(); ++i)
if ((i->getAlternate() == x || &*i == x)
&& i->getEffective().within(data->state->q_flowplan->getDate()))
thealternates.push_front(&*i);
// 2) Sort the list
thealternates.sort(sortFlow);
// 3) Control the planning mode
bool originalPlanningMode = data->constrainedPlanning;
data->constrainedPlanning = true;
const Flow *firstAlternate = NULL;
double firstQuantity = 0.0;
// Remember the top constraint
bool originalLogConstraints = data->logConstraints;
//Problem* topConstraint = data->planningDemand->getConstraints().top();
// 4) Loop through the alternates till we find a non-zero reply
Date min_next_date(Date::infiniteFuture);
double ask_qty;
FlowPlan *flplan = data->state->q_flowplan;
for (list<const Flow*>::const_iterator i = thealternates.begin();
i != thealternates.end();)
{
const Flow *curflow = *i;
data->state->q_flowplan = flplan; // because q_flowplan can change
// 4a) Switch to this flow
if (data->state->q_flowplan->getFlow() != curflow)
data->state->q_flowplan->setFlow(curflow);
// 4b) Call the Python user exit if there is one
if (userexit_flow)
{
PythonObject result = userexit_flow.call(data->state->q_flowplan, PythonObject(data->constrainedPlanning));
if (!result.getBool())
{
// Return value is false, alternate rejected
if (data->getSolver()->getLogLevel()>1)
logger << indent(curflow->getOperation()->getLevel())
<< " User exit disallows consumption from '"
<< (*i)->getBuffer()->getName() << "'" << endl;
// Move to the next alternate
if (++i != thealternates.end() && data->getSolver()->getLogLevel()>1)
logger << indent(curflow->getOperation()->getLevel()) << " Alternate flow switches from '"
<< curflow->getBuffer()->getName() << "' to '"
<< (*i)->getBuffer()->getName() << "'" << endl;
continue;
}
}
// Remember the first alternate
if (!firstAlternate)
{
firstAlternate = *i;
firstQuantity = data->state->q_flowplan->getQuantity();
}
// Constraint tracking
if (*i != firstAlternate)
// Only enabled on first alternate
data->logConstraints = false;
else
// Keep track of constraints, if enabled
data->logConstraints = originalLogConstraints;
// 4c) Ask the buffer
data->state->q_qty = ask_qty = - data->state->q_flowplan->getQuantity();
data->state->q_date = data->state->q_flowplan->getDate();
CommandManager::Bookmark* topcommand = data->setBookmark();
curflow->getBuffer()->solve(*this,data);
// 4d) A positive reply: exit the loop
if (data->state->a_qty > ROUNDING_ERROR)
{
// Update the opplan, which is required to (1) update the flowplans
// and to (2) take care of lot sizing constraints of this operation.
if (data->state->a_qty < ask_qty - ROUNDING_ERROR)
{
flplan->setQuantity(-data->state->a_qty, true);
data->state->a_qty = -flplan->getQuantity();
}
if (data->state->a_qty > ROUNDING_ERROR)
//.........这里部分代码省略.........