Beispiel #1
0
OperationItemSupplier::OperationItemSupplier(
  ItemSupplier* i, Buffer *b
  ) : supitem(i)
{
  if (!i || !b || !i->getSupplier())
    throw LogicException(
      "An OperationItemSupplier always needs to point to "
      "a itemsupplier and a buffer"
      );
  stringstream o;
  o << "Purchase " << b->getName() << " from " << i->getSupplier()->getName();
  setName(o.str());
  setDuration(i->getLeadTime());
  setSizeMultiple(i->getSizeMultiple());
  setSizeMinimum(i->getSizeMinimum());
  setLocation(b->getLocation());
  setSource(i->getSource());
  setCost(i->getCost());
  setFence(i->getFence());
  setHidden(true);
  new FlowEnd(this, b, 1);
  initType(metadata);

  // Optionally, create a load
  if (i->getResource())
    new LoadDefault(this, i->getResource(), i->getResourceQuantity());

  // Insert in the list of ItemSupplier operations.
  // The list is not sorted (for performance reasons).
  nextOperation = i->firstOperation;
  i->firstOperation = this;
}
Beispiel #2
0
OperationItemDistribution::OperationItemDistribution(
  ItemDistribution* i, Buffer *src, Buffer* dest
  ) : itemdist(i)
{
  if (!i || !src || !dest)
    throw LogicException(
      "An OperationItemDistribution always needs to point to "
      "a ItemDistribution, a source buffer and a destination buffer"
      );
  stringstream o;
  o << "Ship " << dest->getItem()->getName() << " from " << src->getName() << " to " << dest->getName();
  setName(o.str());
  setDuration(i->getLeadTime());
  setSizeMultiple(i->getSizeMultiple());
  setSizeMinimum(i->getSizeMinimum());
  setLocation(dest->getLocation());
  setSource(i->getSource());
  setCost(i->getCost());
  setFence(i->getFence());
  setHidden(true);
  new FlowEnd(this, dest, 1);
  new FlowStart(this, src, -1);
  initType(metadata);

  // Optionally, create a load
  if (i->getResource())
    new LoadDefault(this, i->getResource(), i->getResourceQuantity());

  // Insert in the list of ItemDistribution operations.
  // The list is not sorted (for performance reasons).
  nextOperation = i->firstOperation;
  i->firstOperation = this;
}
Beispiel #3
0
ItemDistribution::ItemDistribution()
{
  initType(metadata);

  // Trigger level and cluster recomputation
  HasLevel::triggerLazyRecomputation();
}
Beispiel #4
0
DECLARE_EXPORT LoadPlan::LoadPlan(OperationPlan *o, const Load *r, LoadPlan *lp)
{
  ld = const_cast<Load*>(r);
  oper = o;
  start_or_end = END;

  // Update the resource field
  res = lp->getResource();

  // Add to the operationplan
  nextLoadPlan = NULL;
  if (o->firstloadplan)
  {
    // Append to the end
    LoadPlan *c = o->firstloadplan;
    while (c->nextLoadPlan) c = c->nextLoadPlan;
    c->nextLoadPlan = this;
  }
  else
    // First in the list
    o->firstloadplan = this;

  // Insert in the resource timeline
  getResource()->loadplans.insert(
    this,
    ld->getLoadplanQuantity(this),
    ld->getLoadplanDate(this)
  );

  // Initialize the Python type
  initType(metadata);
}
Beispiel #5
0
void TDBoss::initAttributeWithIndex(int type,int id)
{
	m_nType = type;
	m_birthPosition = Point(GLB_SIZE.width-120,100);
	m_nId = id;
	m_nHP = 300;
	m_fHpBackUp = static_cast<float>(m_nHP);
	m_nAttackRate = 1;
	m_nDPS = 200;
	//初始化BossHp;
	Sprite* bg = Sprite::create(RESOURCE("td/ui_hpboss01.png"));
	bg->setPosition(Vec2(0,100.f));
	this->addChild(bg,Z_First);
	m_BossHpProgress = ProgressTimer::create(Sprite::create(RESOURCE("td/ui_hpboss02.png")));//创建一个进程条;
	m_BossHpProgress->setAnchorPoint(Vec2::ZERO);
	m_BossHpProgress->setBarChangeRate(Point(1,0));//设置进程条的变化速率;
	m_BossHpProgress->setType(ProgressTimer::Type::BAR);//设置进程条的类型;
	m_BossHpProgress->setMidpoint(Point(0,0.5));//设置进度的运动方向;
	m_BossHpProgress->setPosition(Vec2::ZERO);
	bg->addChild(m_BossHpProgress,Z_First);
	m_BossHpProgress->setPercentage(90);

	//初始化Boss类型;
	initType();
	m_bossLCA = TDBossLCA :: create(m_nAttackRate);
	this->addChild(m_bossLCA);
}
Beispiel #6
0
DECLARE_EXPORT SetupMatrix::Rule::Rule(SetupMatrix *s, int p)
  : cost(0), priority(p), matrix(s), nextRule(NULL), prevRule(NULL)
{
  // Validate the arguments
  if (!matrix) throw DataException("Can't add a rule to NULL setup matrix");

  // Find the right place in the list
  Rule *next = matrix->firstRule, *prev = NULL;
  while (next && p > next->priority)
  {
    prev = next;
    next = next->nextRule;
  }

  // Duplicate priority
  if (next && next->priority == p)
    throw DataException("Multiple rules with identical priority in setup matrix");

  // Maintain linked list
  nextRule = next;
  prevRule = prev;
  if (prev) prev->nextRule = this;
  else matrix->firstRule = this;
  if (next) next->prevRule = this;

  // Initialize the Python type
  initType(metadata);
}
Beispiel #7
0
FlowPlan::FlowPlan (OperationPlan *opplan, const Flow *f) 
  : fl(const_cast<Flow*>(f)), oper(opplan)
{
  assert(opplan && f);

  // Initialize the Python type
  initType(metadata);

  // Link the flowplan to the operationplan
  if (opplan->firstflowplan)
  {
    // Append to the end
    FlowPlan *c = opplan->firstflowplan;
    while (c->nextFlowPlan) c = c->nextFlowPlan;
    c->nextFlowPlan = this;
  }
  else
    // First in the list
    opplan->firstflowplan = this;

  // Compute the flowplan quantity
  fl->getBuffer()->flowplans.insert(
    this,
    fl->getFlowplanQuantity(this),
    fl->getFlowplanDate(this)
  );

  // Mark the operation and buffer as having changed. This will trigger the
  // recomputation of their problems
  fl->getBuffer()->setChanged();
  fl->getOperation()->setChanged();
}
Beispiel #8
0
ItemSupplier::ItemSupplier()
{
  initType(metadata);

  // Trigger level and cluster recomputation
  HasLevel::triggerLazyRecomputation();
}
Beispiel #9
0
DECLARE_EXPORT ItemSupplier::ItemSupplier() : loc(NULL),
  size_minimum(1.0), size_multiple(0.0), cost(0.0), firstOperation(NULL)
{
  initType(metadata);

  // Trigger level and cluster recomputation
  HasLevel::triggerLazyRecomputation();
}
Beispiel #10
0
PeggingIterator::PeggingIterator(const PeggingIterator& c)
    : downstream(c.downstream), firstIteration(c.firstIteration), first(c.first), second_pass(c.second_pass)
{
    initType(metadata);
    for (statestack::const_iterator i = c.states.begin(); i != c.states.end(); ++i)
        states.push_back( state(i->opplan, i->quantity, i->offset, i->level) );
    for (deque<state>::const_iterator i = c.states_sorted.begin(); i != c.states_sorted.end(); ++i)
        states_sorted.push_back(state(i->opplan, i->quantity, i->offset, i->level));
}
Beispiel #11
0
ItemSupplier::ItemSupplier(Supplier* s, Item* r, int u)
{
  setSupplier(s);
  setItem(r);
  setPriority(u);
  initType(metadata);

  // Trigger level and cluster recomputation
  HasLevel::triggerLazyRecomputation();
}
Beispiel #12
0
DECLARE_EXPORT ItemSupplier::ItemSupplier(Supplier* s, Item* r, int u)
  : loc(NULL), size_minimum(1.0), size_multiple(0.0), cost(0.0), firstOperation(NULL)
{
  setSupplier(s);
  setItem(r);
  setPriority(u);
  initType(metadata);

  // Trigger level and cluster recomputation
  HasLevel::triggerLazyRecomputation();
}
Beispiel #13
0
DECLARE_EXPORT PeggingIterator::PeggingIterator(const Demand* d)
  : downstream(false), firstIteration(true), first(false)
{
  initType(metadata);
  const Demand::OperationPlanList &deli = d->getDelivery();
  for (Demand::OperationPlanList::const_iterator opplaniter = deli.begin();
      opplaniter != deli.end(); ++opplaniter)
  {
    OperationPlan *t = (*opplaniter)->getTopOwner();
    updateStack(t, t->getQuantity(), 0.0, 0);
  }
}
Beispiel #14
0
PeggingIterator::PeggingIterator(LoadPlan* lp, bool b)
    : downstream(b), firstIteration(true), first(false), second_pass(false)
{
    initType(metadata);
    if (!lp) return;
    updateStack(
        lp->getOperationPlan()->getTopOwner(),
        lp->getOperationPlan()->getQuantity(),
        0.0,
        0
    );
}
Beispiel #15
0
DECLARE_EXPORT PeggingIterator::PeggingIterator(FlowPlan* fp, bool b)
  : downstream(b), firstIteration(true), first(false)
{
  initType(metadata);
  if (!fp) return;
  updateStack(
    fp->getOperationPlan()->getTopOwner(),
    fp->getOperationPlan()->getQuantity(),
    0.0,
    0
    );
}
Beispiel #16
0
TurnaroundPassenger::TurnaroundPassenger (MobLogEntry& p_entry, CARCportEngine* _pEngine ) :
    Passenger (p_entry, _pEngine )
{
	MobileElement::setBehavior( new TurnaroundPaxTerminalBehavior( this ));
	direction = ARRIVING;

	m_logMobEntry = p_entry;
	assert( m_pTerm );
    arrivingType = initType (p_entry.getArrFlight(), 'A');
	arrivingType.SetInputTerminal( m_pTerm );
    departingType = initType (p_entry.getDepFlight(), 'D');
	departingType.SetInputTerminal( m_pTerm );

    Flight *aFlight = getEngine()->m_simFlightSchedule.getItem (p_entry.getArrFlight());
	arrivingGate = aFlight->getArrGateIndex();
	m_nGate = arrivingGate;

    aFlight = getEngine()->m_simFlightSchedule.getItem (p_entry.getDepFlight());
	departingGate = aFlight->getDepGateIndex();
    departureTime = aFlight->getDepTime();
    m_type.setOtherFlightConstraint(arrivingType);

}
Beispiel #17
0
DECLARE_EXPORT OperationItemSupplier::OperationItemSupplier(
  ItemSupplier* i, Buffer *b
  ) : supitem(i)
{
  if (!i || !b || !i->getSupplier())
    throw LogicException(
      "An OperationItemSupplier always needs to point to "
      "a itemsupplier and a buffer"
      );
  stringstream o;
  o << "Purchase " << b->getName() << " from " << i->getSupplier()->getName();
  setName(o.str());
  setDuration(i->getLeadTime());
  setSizeMultiple(i->getSizeMultiple());
  setSizeMinimum(i->getSizeMinimum());
  setLocation(b->getLocation());
  setSource(i->getSource());
  setCost(i->getCost());
  setFence(i->getFence());
  setHidden(true);
  new FlowEnd(this, b, 1);
  initType(metadata);

  // Optionally, create a load
  if (i->getResource())
    new LoadDefault(this, i->getResource(), i->getResourceQuantity());

  // Insert in the list of ItemSupplier operations.
  // We keep the list sorted by the operation name.
  if (!i->firstOperation || getName() < i->firstOperation->getName())
  {
    // New head of the list
    nextOperation = i->firstOperation;
    i->firstOperation = this;
  }
  else
  {
    // Insert in the middle or at the tail
    OperationItemSupplier* o = i->firstOperation;
    while (o->nextOperation)
    {
      if (b->getName() < o->nextOperation->getName())
        break;
      o = o->nextOperation;
    }
    nextOperation = o->nextOperation;
    o->nextOperation = this;
  }
}
Beispiel #18
0
DECLARE_EXPORT ResourceSkill::ResourceSkill(Skill* s, Resource* r, int u)
{
  setSkill(s);
  setResource(r);
  setPriority(u);
  initType(metadata);
  try { validate(ADD); }
  catch (...)
  {
    if (getSkill()) getSkill()->resources.erase(this);
    if (getResource()) getResource()->skills.erase(this);
    resetReferenceCount();
    throw;
  }
}
Beispiel #19
0
DECLARE_EXPORT OperationItemDistribution::OperationItemDistribution(
  ItemDistribution* i, Buffer *src, Buffer* dest
  ) : itemdist(i)
{
  if (!i || !src || !dest)
    throw LogicException(
      "An OperationItemDistribution always needs to point to "
      "a ItemDistribution, a source buffer and a destination buffer"
      );
  stringstream o;
  o << "Ship " << dest->getItem()->getName() << " from " << src->getName() << " to " << dest->getName();
  setName(o.str());
  setDuration(i->getLeadTime());
  setSizeMultiple(i->getSizeMultiple());
  setSizeMinimum(i->getSizeMinimum());
  setLocation(dest->getLocation());
  setSource(i->getSource());
  setCost(i->getCost());
  setHidden(true);
  new FlowEnd(this, dest, 1);
  new FlowStart(this, src, -1);
  initType(metadata);

  // Insert in the list of ItemDistribution operations.
  // We keep the list sorted by the operation name.
  if (!i->firstOperation || getName() < i->firstOperation->getName())
  {
    // New head of the list
    nextOperation = i->firstOperation;
    i->firstOperation = this;
  }
  else
  {
    // Insert in the middle or at the tail
    OperationItemDistribution* o = i->firstOperation;
    while (o->nextOperation)
    {
      if (getName() < o->nextOperation->getName())
        break;
      o = o->nextOperation;
    }
    nextOperation = o->nextOperation;
    o->nextOperation = this;
  }
}
Beispiel #20
0
DECLARE_EXPORT LoadPlan::LoadPlan(OperationPlan *o, const Load *r)
{
  assert(o);
  ld = const_cast<Load*>(r);
  oper = o;
  start_or_end = START;

  // Update the resource field
  res = r->getResource();

  // Add to the operationplan
  nextLoadPlan = NULL;
  if (o->firstloadplan)
  {
    // Append to the end
    LoadPlan *c = o->firstloadplan;
    while (c->nextLoadPlan) c = c->nextLoadPlan;
    c->nextLoadPlan = this;
  }
  else
    // First in the list
    o->firstloadplan = this;

  // Insert in the resource timeline
  getResource()->loadplans.insert(
    this,
    ld->getLoadplanQuantity(this),
    ld->getLoadplanDate(this)
  );

  // Initialize the Python type
  initType(metadata);

  // For continuous resources, create a loadplan to mark
  // the end of the operationplan.
  if (getResource()->getType() != *ResourceBuckets::metadata)
    new LoadPlan(o, r, this);

  // Mark the operation and resource as being changed. This will trigger
  // the recomputation of their problems
  getResource()->setChanged();
  r->getOperation()->setChanged();
}
Beispiel #21
0
PeggingIterator::PeggingIterator(const Demand* d)
    : downstream(false), firstIteration(true), first(false), second_pass(false)
{
    initType(metadata);
    const Demand::OperationPlanList &deli = d->getDelivery();
    for (Demand::OperationPlanList::const_iterator opplaniter = deli.begin();
            opplaniter != deli.end(); ++opplaniter)
    {
        OperationPlan *t = (*opplaniter)->getTopOwner();
        updateStack(t, t->getQuantity(), 0.0, 0);
    }

    // Bring all pegging information to a second stack.
    // Only in this way can we avoid that the same operationplan is returned
    // multiple times
    while (operator bool())
    {
        /** Check if already found in the vector. */
        bool found = false;
        state& curtop = states.back();
        for (deque<state>::iterator it = states_sorted.begin(); it != states_sorted.end() && !found; ++it)
            if (it->opplan == curtop.opplan)
            {
                // Update existing element in sorted stack
                it->quantity += curtop.quantity;
                if (it->level > curtop.level)
                    it->level = curtop.level;
                found = true;
            }
        if (!found)
            // New element in sorted stack
            states_sorted.push_back( state(curtop.opplan, curtop.quantity, curtop.offset, curtop.level) );

        if (downstream)
            ++*this;
        else
            --*this;
    }

    // The normal iteration will use the sorted results
    second_pass = true;
}
Beispiel #22
0
PeggingIterator::PeggingIterator(const OperationPlan* opplan, bool b)
    : downstream(b), firstIteration(true), first(false), second_pass(false)
{
    initType(metadata);
    if (!opplan) return;
    if (opplan->getTopOwner()->getOperation()->getType() == *OperationSplit::metadata)
        updateStack(
            opplan,
            opplan->getQuantity(),
            0.0,
            0
        );
    else
        updateStack(
            opplan->getTopOwner(),
            opplan->getTopOwner()->getQuantity(),
            0.0,
            0
        );
}
Beispiel #23
0
PeggingDemandIterator::PeggingDemandIterator(const OperationPlan* opplan)
{
    initType(metadata);
    // Walk over all downstream operationplans till demands are found
    for (PeggingIterator p(opplan); p; ++p)
    {
        const OperationPlan* m = p.getOperationPlan();
        if (!m)
            continue;
        Demand* dmd = m->getTopOwner()->getDemand();
        if (!dmd || p.getQuantity() < ROUNDING_ERROR)
            continue;
        map<Demand*, double>::iterator i = dmds.lower_bound(dmd);
        if (i != dmds.end() && i->first == dmd)
            // Pegging to the same demand multiple times
            i->second += p.getQuantity();
        else
            // Adding demand
            dmds.insert(i, make_pair(dmd, p.getQuantity()));
    }
}
Beispiel #24
0
void
fileIntBindingInit()
{
    initType(FileIntType, "FileInt", fileIntFreeInstance);

    VALUE klass = rb_define_class("FileInt", rb_cIO);
    rb_define_alloc_func(klass, classAllocate<&FileIntType>);

    _rb_define_method(klass, "read", fileIntRead);
    _rb_define_method(klass, "getbyte", fileIntGetByte);
    _rb_define_method(klass, "binmode", fileIntBinmode);
    _rb_define_method(klass, "close", fileIntClose);

    _rb_define_module_function(rb_mKernel, "load_data", kernelLoadData);
    _rb_define_module_function(rb_mKernel, "save_data", kernelSaveData);

    /* We overload the built-in 'Marshal::load()' function to silently
     * insert our utf8proc that ensures all read strings will be
     * UTF-8 encoded */
    VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
    rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load");
    _rb_define_module_function(marsh, "load", _marshalLoad);
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int EMMPMInputParser::parseCLIArguments(int argc, char* argv[], EMMPM_Data* inputs)
{
  if ( NULL == inputs)
  {
    printf("The EMMPM_Inputs pointer was null. Returning early.\n");
    return -1;
  }

  TCLAP::CmdLine cmd("", ' ', EMMPMLib::Version::Complete().toStdString());

  TCLAP::ValueArg<std::string> in_inputFile("i", "inputfile", "Image File to be used as input", true, "", "");
  cmd.add(in_inputFile);
  TCLAP::ValueArg<std::string> in_outputFile("o", "outputfile", "The Image Output File", true, "", "");
  cmd.add(in_outputFile);

  TCLAP::ValueArg<float> in_beta("b", "beta", "Beta Value", false, 1.0, "1.0");
  cmd.add(in_beta);
  TCLAP::ValueArg<float> in_gamma("g", "gamma", "Gamma Value", false, 0.0f, "0.0");
  cmd.add(in_gamma);
  TCLAP::ValueArg<int> in_emIter("e", "emIter", "Number of EM Iterations", false, 5, "5");
  cmd.add(in_emIter);
  TCLAP::ValueArg<int> in_mpmIter("m", "mpmIter", "Number of MPM Iterations", false, 5, "5");
  cmd.add(in_mpmIter);
  TCLAP::ValueArg<int> in_numClasses("n", "numClasses", "The Number of classes or phases in the material", false, 2, "2");
  cmd.add(in_numClasses);
  TCLAP::SwitchArg in_verbose("v", "verbose", "Verbose Output", false);
  cmd.add(in_verbose);

  TCLAP::SwitchArg simAnneal("s", "simanneal", "Use Simulated Annealing", false);
  cmd.add(simAnneal);

  TCLAP::ValueArg<int> initType("z", "inittype", "The initialization algorithm that should be performed", false, 0, "1");
  cmd.add(initType);
  TCLAP::ValueArg<std::string> initcoords("", "coords", "The upper left (x,y) and lower right (x,y) pixel coordinate sets of each class to be used in the initialization algorithm where each set is separated by a colon ':'. An example is 487,192,507,212:0,332,60,392 for 2 class system.", false, "", "");
  cmd.add(initcoords);

  TCLAP::ValueArg<std::string> graytable( "", "graytable", "Comma separated list of grayscale values for each class. This can be used to combine classes together at file writing time.", false, "", "");
  cmd.add(graytable);

  TCLAP::ValueArg<float> beta_e("", "beta_e", "Gradient Penalty Weight", false, 0.0, "0.0");
  cmd.add(beta_e);

  TCLAP::ValueArg<float> beta_c("", "beta_c", "Curvature Penalty Weight", false, 0.0, "0.0");
  cmd.add(beta_c);
  TCLAP::ValueArg<float> rmax("", "rmax", "Maximum Radius for Curvature Morphalogical Filter", false, 15.0, "15.0");
  cmd.add(rmax);
  TCLAP::ValueArg<int> em_loop_delay("", "emLoopDelay", "Number of EM Loops to delay before applying the Morphological Filter", false, 1, "1");
  cmd.add(em_loop_delay);


  TCLAP::ValueArg<std::string> mv("", "mv", "Pairs of Mean,Sigma initial values for each class where each set is separated by a ':'. Example for 2 classes is: 121.3,22.8:205.2,45.0", false, "", "");
  cmd.add(mv);


  if (argc < 2)
  {
    std::cout << "EM/MPM Command Line Version " << cmd.getVersion() << std::endl;
    std::vector<std::string> args;
    args.push_back(argv[0]);
    args.push_back("-h");
    cmd.parse(args);
    return -1;
  }


  try
  {
    int error = 0;
    cmd.parse(argc, argv);
    inputs->in_beta = in_beta.getValue();
    for(int i = 0; i < EMMPM_MAX_CLASSES; i++)
    {
      inputs->w_gamma[i] = in_gamma.getValue();
    }
    inputs->mpmIterations = in_mpmIter.getValue();
    inputs->emIterations = in_emIter.getValue();
    inputs->classes = in_numClasses.getValue();
    inputs->verbose = in_verbose.getValue();
    inputs->simulatedAnnealing = simAnneal.getValue();

    inputs->input_file_name = copyFilenameToNewCharBuffer(in_inputFile.getValue() );
    if (inputs->input_file_name == NULL)
    {
      std::cout << "There was an error parsing the input file name. Did you use the '-i' argument to set an input file?" << std::endl;
      return -1;
    }

    inputs->output_file_name = copyFilenameToNewCharBuffer(in_outputFile.getValue() );
    if (inputs->output_file_name == NULL)
    {
      std::cout << "There was an error parsing the output file name. Did you use the '-o' argument to set an input file?" << std::endl;
      return -1;
    }

    if (inputs->initType == EMMPM_UserInitArea)
    {
      error = parseInitCoords(initcoords.getValue(), inputs);
      if (error < 0)
      {
        std::cout << "There was an error parsing the command line arguments for the initialization coordinates." << std::endl;
        return -1;
      }
    }
    if (inputs->initType == EMMPM_ManualInit)
    {
      error = parseMuSigmaValues(mv.getValue(), inputs);
      if (error < 0)
      {
        std::cout << "There was an error parsing the command line arguments for the mean and variance values" << std::endl;
        return -1;
      }
    }

    if (graytable.getValue().empty() == false)
    {
      error = parseGrayTable(graytable.getValue(), inputs);
      if (error < 0)
      {
        std::cout << "There was an error parsing the Gray Level Table." << std::endl;
        return -1;
      }
    }
    else // Create a default gray level table
    {
      int n = inputs->classes - 1;
      for (int value = 0; value < inputs->classes; ++value)
      {
        unsigned int argb = 0xFF000000; // Black
        unsigned char* ptr = reinterpret_cast<unsigned char*>(&argb);
        ptr[1] = value * 255 / n;
        ptr[2] = value * 255 / n;
        ptr[3] = value * 255 / n;
        inputs->colorTable[value] = argb;
      }
    }

    /* Parse the Gradient Penalty Weighting (Beta E) from the command line */
    if (beta_e.getValue() > 0.0)
    {
      inputs->useGradientPenalty = 1;
      inputs->beta_e = beta_e.getValue();
    }

    /* Parse the Curvature Penalty Arguments  */
    if (beta_c.getValue() > 0.0)
    {
      inputs->useCurvaturePenalty = 1;
      inputs->beta_c = beta_c.getValue();
      inputs->r_max = rmax.getValue();
      inputs->ccostLoopDelay = em_loop_delay.getValue();
    }
  }
  catch (TCLAP::ArgException& e)
  {
    std::cerr << " error: " << e.error() << " for arg " << e.argId() << std::endl;
    std::cout << "** Unknown Arguments. Displaying help listing instead. **" << std::endl;
    return -1;
  }
  return 0;
}
Beispiel #26
0
Vehicule::Vehicule(int deltaT, bool debug) {
    if (debug)
        std::cout << "Init VE" << std::endl;
    soc = 100;
    etatMouvActuel = BRANCHE_EN_CHARGE; // BRANCHE_EN_CHARGE
    etatMouvSuivant = BRANCHE_EN_CHARGE; // BRANCHE_EN_CHARGE
    distanceParcourue = 0;
    nbTrajetsEffectues = 0;
    willToCharge = true;
    typeVehicule = initType();
    position = (typeVehicule == VE_PARTICULIER) ? MAISON : TRAVAIL;
    modele = initModele(typeVehicule);
    capacite = stats_capaciteVehicule[modele];
    vitesse = initVitesse(); // en km/h
    consommation = capacite / stats_autonomieVehicule[modele];
    longueurTrajet = initLongueurTrajet();
    puissanceCharge = 3.5;
    if (debug)
        std::cout << "\t" << "Constantes terminées : VE de type " << typeVehicule << std::endl;
    
    socMin = 0;
    nbTrajets = initNbTrajets();
    if (debug)
        std::cout << "\t" << "Nombre trajets. OK" << std::endl;
    
    for (int h = 0; h < 3; h++) {
        accesBornes[h] = false;
    }
    initAccesBornes(accesBornes, typeVehicule);
    if (debug)
        std::cout << "\t" << "Accès bornes. OK" << std::endl;
    
    int dernierePosition(position);
    int dernierHoraire(0);
    bool consistant = true;
    if (debug)
        std::cout << "\t" << "Calcul des horaires et destinations" << std::endl;
    do {
        destinations.clear();
        horaireDepart.clear();
        for (int i(0); i < nbTrajets; i++) {
            if (debug)
                std::cout << "\t\t" << "Couple n°" << (i+1) << " sur " << nbTrajets << std::endl;
            int nouvelHoraire = initHoraireDepart(deltaT, dernierHoraire);
            if (debug)
                std::cout << "\t\t\t" << "Horaire. OK" << std::endl;
            int newDestination = giveDestination(typeVehicule, dernierePosition, nouvelHoraire, deltaT);
            if (debug)
                std::cout << "\t\t\t" << "Destination. OK" << std::endl;
            destinations.push_back(newDestination);
            horaireDepart.push_back(nouvelHoraire);
            dernierePosition = newDestination;
            dernierHoraire = (nouvelHoraire + (int)std::ceil((longueurTrajet / vitesse) * 60 / deltaT)) % (1440/deltaT);
            if ((nouvelHoraire + (int)std::ceil((longueurTrajet / vitesse) * 60 / deltaT)) < 1440 / deltaT)
                consistant = consistant && true;
            else
                consistant = false;
        }
    } while (/*!consistant || */!passeParUneBorne(destinations, accesBornes));
    
    if (debug && !checkOrdreHorairesDepart(horaireDepart))
        std::cout << "INCOHERENCE DANS LES HORAIRES" << std::endl;
    
    if (debug)
        std::cout << "\t" << "Destinations et horaires départ. OK" << std::endl;
    
    computeSocMin(deltaT);
    if (debug) {
        std::cout << "\t" << "SOC min. OK" << std::endl;
        std::cout << "  VE OK !" << std::endl << std::endl;
    }
}
Beispiel #27
0
PeggingDemandIterator::PeggingDemandIterator(const PeggingDemandIterator& c)
{
    initType(metadata);
    dmds.insert(c.dmds.begin(), c.dmds.end());
}