Пример #1
0
bool VACBinaryConstraint::revise (VACVariable* var, Value v) {
  bool wipeout = false;
  VACVariable* xi = (VACVariable*) getVar(0);
  VACVariable* xj = (VACVariable*) getVar(1);
  Value sup = getSupport(var,v);
  Value minsup = sup;
  if(var != xi) {  xi = (VACVariable*)getVar(1); xj = (VACVariable*)getVar(0); }
  Cost cost, minCost = wcsp->getUb();

  if(xj->canbe(sup)) {
	  if(xj->getVACCost(sup) != MIN_COST) { wipeout = xj->removeVAC(sup);  }
	  else {
		  if (getVACCost(xi,xj,v,sup) == MIN_COST) {
		    return false;
		  }
	  }
  }

  for (EnumeratedVariable::iterator it = xj->lower_bound(sup); it != xj->end(); ++it) {
	  Value w = *it;
	  if(xj->getVACCost(w) != MIN_COST) { wipeout = xj->removeVAC(w); xj->queueVAC(); }
	  else {
	      cost = getVACCost(xi,xj,v, w);
	      if (cost == MIN_COST) {
	      	setSupport(xi,v,w);
	        return false;
	      } else if (cost < minCost) {
	      	  minCost = cost;
	          minsup = w;
	      }
	  }
  }
  for (EnumeratedVariable::iterator it = xj->begin(); it != xj->lower_bound(sup); ++it) {
	  Value w = *it;
	  if(xj->getVACCost(w) != MIN_COST) { wipeout = xj->removeVAC(w); xj->queueVAC(); }
	  else {
	      cost = getVACCost(xi,xj,v, w);
	      if (cost == MIN_COST) {
	      	setSupport(xi,v,w);
	        return false;
	      } else if (cost < minCost) {
	      	  minCost = cost;
	          minsup = w;
	      }
	  }
  }

  setSupport(xi,v,minsup);
  return true;
}
/*!
 * \brief ClientSessionData::on_support() will set number of Supports for a session
 * \param value
 */
void ClientSessionData::on_support(uint value)
{
    setSupport(value);
}
Пример #3
0
void Film::chargement(QDomElement & element)
{
    QDomNodeList pluton = element.elementsByTagName("nom");
    if(pluton.size() > 0)
    {
        setNom(pluton.at(0).toElement().text());
    }
    else
    {
        throw QString("Il manque le nom");
    }

    pluton = element.elementsByTagName("genre");

    if(pluton.size() > 0)
    {
        setGenre(pluton.at(0).toElement().text());
    }
    else
    {
        throw QString("Il manque le genre");
    }

    pluton = element.elementsByTagName("date");

    if(pluton.size() > 0)
    {
        setDate(QDate::fromString(pluton.at(0).toElement().text(), "d/M/yyyy"));
    }
    else
    {
        throw QString("Il manque la date");
    }

    pluton = element.elementsByTagName("vue");
    if(pluton.size() > 0)
    {
        setFini(pluton.at(0).toElement().text().toInt());
    }
    else
    {
        throw QString("Il manque fini");
    }

    pluton = element.elementsByTagName("url");
    if(pluton.size() > 0)
    {
        setUrl(QUrl(pluton.at(0).toElement().text()));
    }
    else
    {
        throw QString("Il manque l'url");
    }

    pluton = element.elementsByTagName("realisateur");

    if(pluton.size() > 0)
    {
        setRealisateur(pluton.at(0).toElement().text());
    }
    else
    {
        throw QString("Il manque le réalisateur");
    }

    pluton = element.elementsByTagName("scenariste");

    if(pluton.size() > 0)
    {
        setScenariste(pluton.at(0).toElement().text());
    }
    else
    {
        throw QString("Il manque le scenariste");
    }

    pluton = element.elementsByTagName("support");
    if(pluton.size() > 0)
    {
        setSupport((Film::Support)pluton.at(0).toElement().text().toInt());
    }
    else
    {
        throw QString("Il manque le support");
    }

    pluton = element.elementsByTagName("duree");

    if(pluton.size() > 0)
    {
        setDuree(QTime::fromString(pluton.at(0).toElement().text()));
    }
    else
    {
        throw QString("Il manque la durée");
    }

    pluton = element.elementsByTagName("acteur");

    for(int terra = 0; terra < pluton.size(); terra ++)
    {
        addActeur(pluton.at(terra).toElement().text());
    }

    pluton = element.elementsByTagName("type");

    if(pluton.size() > 0)
    {
        setType(pluton.at(0).toElement().text());
    }
    qDebug()<<"Chargement "<<nom()<<"ok";

}