当前位置: 首页>>代码示例>>C++>>正文


C++ Formula类代码示例

本文整理汇总了C++中Formula的典型用法代码示例。如果您正苦于以下问题:C++ Formula类的具体用法?C++ Formula怎么用?C++ Formula使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Formula类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readFromFile

/**************************************************************************************************
 *                      IO
 * ***********************************************************************************************/
Formula IO::readFromFile(const std::string fileName){
    Formula result;
    uint numberVars;
    std::fstream data;
    data.open(fileName, std::ios::in);
    if(!data.is_open()){
        std::cout << "Could not open: " << fileName;
        exit(1);
    }
    while(!data.eof()){
        std::string line;
        getline(data, line);
        if(line.empty()) continue;
        if(line[0] == 'c' || line[0] == 'C') continue;
// Header line
        if(line[0] == 'p'){
            line = line.substr(line.find(" ")+1);
            line = line.substr(line.find(" ")+1);
            numberVars = std::stoi(line.substr(0, line.find(" ")));

            result.setNumberOfVariables(numberVars);
            continue;
        }

        result.addClauses(Clauses(line));


    }

    return result;
}
开发者ID:Fettpet,项目名称:SatSolver,代码行数:34,代码来源:io.cpp

示例2: impIClicked

void MainWindow::impIClicked()
{

    QList<QGraphicsItem *> selected_list = scene->selectedItems();
    Node* selected = (Node*)(selected_list.at(0));

    selected->setRule("impI");
    selected->update();

    Formula f = selected->getFormula();
    Formula op1 = ((Imp*)f.get())->getOperand1();
    Formula op2 = ((Imp*)f.get())->getOperand2();


    std::ostringstream stream;
    op2->printFormula(stream);
    qreal rect_width =  stream.str().length()*PARAMETER;
    qreal rect_height = 20;

    int rect_x = selected->getx() ;
    int rect_y = selected->gety() - 20 - depth/2;

    QVector<Formula> assumptions = selected->getAssumptions();
    assumptions.push_back(op1);
    Node* item = new Node( op2, rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item);

}
开发者ID:Shoocky,项目名称:Interaktivni-dokazivac,代码行数:28,代码来源:mainwindow.cpp

示例3: equalTo

 bool equalTo( const Formula & f) const
 {
   return f->getType() == this->getType() &&
     _op1->equalTo(((BinaryConjective *)f.get())->getOperand1())
     &&
     _op2->equalTo(((BinaryConjective *)f.get())->getOperand2());
 }
开发者ID:Shoocky,项目名称:Interaktivni-dokazivac,代码行数:7,代码来源:fol.hpp

示例4: Formula

/**
 * ((succ(_Y,_Z) & s(_X,_Z)) | theta__(_X,_Y)) -> s(_X,_Y)
 * @return 
 */
Formula HengZhang::createSuccAndSOrTheta__ImplS(const Formula& _originalFml) {
    //1 (succ(_Y,_Z)
    _term* term_y_z = Utils::combineTerms(m_vTermsY, m_vTermsZ);
    _formula* succ_y_z = Utils::compositeToAtom(m_nSymbolSucc, term_y_z);
    //2 s(_X,_Z)
    _term* term_x_z = Utils::combineTerms(m_vTermsX, m_vTermsZ);
    _formula* s_x_z = Utils::compositeToAtom(m_nSymbolS, term_x_z);
    //3 theta__(_X,_Y)
    Formula copyOriginalFml = _originalFml;
    map<int, string> mapPredicates = Vocabulary::instance().getAllIntensionPredicates();
    copyOriginalFml.doubleNegationPredicates(mapPredicates);
    _formula* theta__ = Utils::copyFormula(copyOriginalFml.getFormula());
    //4 s(_X,_Y)
    _term* term_x_y = Utils::combineTerms(m_vTermsX, m_vTermsY);
    _formula* s_x_y   = Utils::compositeToAtom(m_nSymbolS, term_x_y);

    //create structure
    _formula* ll = Utils::compositeByConnective(CONJ, succ_y_z, s_x_z);
    _formula* l = Utils::compositeByConnective(DISJ, ll, theta__);
    _formula* r = s_x_y;
    _formula* f = Utils::compositeByConnective(IMPL, l, r);
    
    Formula fml = Formula(f, false);
    return fml;
}
开发者ID:yzf,项目名称:Parser,代码行数:29,代码来源:HengZhang.cpp

示例5: FormulaException

Formula Formula::differentiateWithRespectTo(std::string varName) {
	using AST::Expression::Expression;
	using AST::Expression::Text;
    using AST::Visitor::GetDerivativeVisitor;
    using AST::Visitor::StringifyVisitor;
    using AST::Visitor::SimplifyVisitor;

    if (formulaExpr == NULL) {
    	throw FormulaException("invalid formula");
    }

	std::unique_ptr<GetDerivativeVisitor> getDerivativeVisitorPtr(new GetDerivativeVisitor());
	std::unique_ptr<SimplifyVisitor> simplifyVisitorPtr(new SimplifyVisitor());
	std::unique_ptr<StringifyVisitor> stringifyVisitorPtr(new StringifyVisitor());

	getDerivativeVisitorPtr.get()->setDerivativeVariableName(varName);

    std::unique_ptr<Expression> derivativeExprPtr((Expression *)formulaExpr->accept(getDerivativeVisitorPtr.get()));
	std::unique_ptr<Expression> simplifiedDerivativeExprPtr((Expression *)derivativeExprPtr.get()->accept(simplifyVisitorPtr.get()));
    std::unique_ptr<Text> stringifiedDerivativeExprPtr((Text *)simplifiedDerivativeExprPtr.get()->accept(stringifyVisitorPtr.get()));

	Formula derivative;
    derivative.setFormulaString(stringifiedDerivativeExprPtr.get()->getContent());
    derivative.setFormulaExpr(simplifiedDerivativeExprPtr.release());

	return derivative;
}
开发者ID:svschub,项目名称:Symbolix,代码行数:27,代码来源:Formula.C

示例6: copyConsTest

void copyConsTest()
{
	char str[100];
	while (gets(str)) {
		Parser p(str);

		Formula *f = p.parse();
		f->print();
		puts("");
		
		Predicate *pred = f->getPredicate();
		Term *t = pred->getTermList()->getList()->at(0);

		puts("here");
		Term w = *t;
		w.print();
		puts("here");
		w.setName("chan");
		w.print();
		puts("");

		f->print();
		puts("");
	}
}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:25,代码来源:fotableau.cpp

示例7: formulaTest

void formulaTest()
{
	TermList *list = new TermList();
	list->addTerm(new Term(Term::VAR, "x"));
	list->addTerm(new Term(Term::VAR, NULL));
	list->addTerm(new Term(Term::CONS, "A"));
	Formula *f = new Formula(new Predicate("P", list));
	Formula *g = new Formula(f);
	Formula *q = new Formula(f, g, '&');
	
	Formula *r = new Formula(new Term(Term::VAR, NULL), q, Formula::UNIV);
	r->print();

	Term *x = new Term(Term::VAR, "xy");
	Term *y = new Term(Term::VAR, "x");

	TermList *list2 = new TermList();
	list2->addTerm(x);
	list2->addTerm(y);
	Term *f2 = new Term("f10", list2);
	Term *g2 = new Term("f10", list2);

	f2->print();
	puts("");
	g2->print();
	puts("");
	if (!(*f2 != *g2)) {
		printf("yes! equal!");
	}

}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:31,代码来源:fotableau.cpp

示例8: if

bool Prover::isClosed(queue<Formula*> &q, int tabCount)
{
	vector<Formula*> aList;
	vector<Formula*> ntAList;
	int sz = q.size();

	for (int i = 0; i < sz; ++i) {
		Formula *f = q.front();
		q.pop();
		q.push(f);
		if (f->isAtomic()) {
			aList.push_back(f);
		}
		else if (f->isNegated() && f->nextFormula->isAtomic()) {
			ntAList.push_back(f->nextFormula);
		}
	}

	for (int i = 0; i < aList.size(); i++) {
		Formula *f1 = aList.at(i);
		for (int j = 0; j < ntAList.size(); j++) {
			Formula *f2 = ntAList.at(j);
			if (!strcmp(f1->getPredicate()->getName(), f2->getPredicate()->getName())) {
				//if (isUnifiable(f1->getPredicate()->getTermList(), f2->getPredicate()->getTermList())) {
				if (isUnifiable(f1->getPredicate(), f2->getPredicate(), tabCount)) {
					return true;
				}
			}
		}
	}
	return false;
}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:32,代码来源:fotableau.cpp

示例9: func_multiple_operations

//
// Function: MULTIPLE.OPERATIONS
//
Value func_multiple_operations(valVector args, ValueCalc *, FuncExtra *e)
{
    if (args.count() != 3 && args.count() != 5)
        return Value::errorVALUE(); // invalid number of parameters

    for (int i = 0; i < args.count(); i++) {
        if (e->ranges[i].col1 == -1 || e->ranges[i].row1 == -1)
            return Value::errorVALUE();
    }

    CellStorage *s = e->sheet->cellStorage();

    // get formula to evaluate
    int formulaCol = e->ranges[0].col1;
    int formulaRow = e->ranges[0].row1;
    Formula formula = s->formula(formulaCol, formulaRow);
    if (!formula.isValid())
        return Value::errorVALUE();

    CellIndirection cellIndirections;
    cellIndirections.insert(Cell(e->sheet, e->ranges[1].col1, e->ranges[1].row1), Cell(e->sheet, e->ranges[2].col1, e->ranges[2].row1));
    if (args.count() > 3) {
        cellIndirections.insert(Cell(e->sheet, e->ranges[3].col1, e->ranges[3].row1), Cell(e->sheet, e->ranges[4].col1, e->ranges[4].row1));
    }

    return formula.eval(cellIndirections);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:30,代码来源:reference.cpp

示例10: Formula

Formula* Formula::getDelta(Term *newFunc)
{
	Formula *f;
	Term *v;
	if (this->type == EXIST) {
		f = this->nextFormula;
		v = this->qVar;
	}
	else {
		f = new Formula(this->nextFormula->getNext());
		v = this->nextFormula->getQVar();
	}

	if (newFunc == NULL) {

		TermList *list = new TermList();
		f->getFreeVarList(list);

		newFunc = new Term(NULL, list);

	}

	f->replace(v, newFunc);
	return f;


}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:27,代码来源:fotableau.cpp

示例11: Formula

void EspressoData::add(EspressoCover &f, Formula::State state)
{
    if (origFormula) {
        Formula *formula = new Formula(*origFormula, f.cover);
        formula->setState(state);
        steps.push_back(formula);
    }
}
开发者ID:Abby3017,项目名称:bmin,代码行数:8,代码来源:espressodata.cpp

示例12: func_isformula

// Function: ISFORMULA
Value func_isformula(valVector /*args*/, ValueCalc */*calc*/, FuncExtra *e)
{
    const Calligra::Sheets::Region &region = e->regions[0];
    QPoint p = region.firstRange().topLeft();
    CellStorage *s = region.firstSheet()->cellStorage();
    Formula formula = s->formula(p.x(), p.y());
    return Value(formula.isValid());
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:9,代码来源:information.cpp

示例13: SetUseValuesFromTriggerTime

bool AntimonyEvent::SetUseValuesFromTriggerTime(const Formula& form)
{
  if (!form.IsBoolean()) {
    g_registry.SetError("Unable to use '" + form.ToDelimitedStringWithEllipses(".") + "': only 'true' or 'false' may be used to set the value of 'fromTrigger' on an event.");
    return true;
  }
  m_useValuesFromTriggerTime = form.GetBoolean();
  return false;
}
开发者ID:mgaldzic,项目名称:antimony,代码行数:9,代码来源:event.cpp

示例14: SetInitialValue

bool AntimonyEvent::SetInitialValue(const Formula& form)
{
  if (!form.IsBoolean()) {
    g_registry.SetError("Unable to use '" + form.ToDelimitedStringWithEllipses(".") + "': only 'true' or 'false' may be used to set the value of 't0' (the initial value) of an event.");
    return true;
  }
  m_initialValue = form.GetBoolean();
  return false;
}
开发者ID:mgaldzic,项目名称:antimony,代码行数:9,代码来源:event.cpp

示例15: SetPersistent

bool AntimonyEvent::SetPersistent(const Formula& form)
{
  if (!form.IsBoolean()) {
    g_registry.SetError("Unable to use '" + form.ToDelimitedStringWithEllipses(".") + "': only 'true' or 'false' may be used to set the value of 'persistent' on an event.");
    return true;
  }
  m_persistent = form.GetBoolean();
  return false;
}
开发者ID:mgaldzic,项目名称:antimony,代码行数:9,代码来源:event.cpp


注:本文中的Formula类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。