Exemplo n.º 1
0
void CTLCheck::check(Vars &v, Model &m, Formula &f, BitStore *bs,
										 bool printFormulas, bool showProgress)
{
#undef pt
#define pt(a) //pr(a)

	f_ = f;
	model_ = &m;
	vars_ = &v;

	sfAlias_.clear();
	stateFlags_.clear();
	sfOrder_.clear();
	pvWarn_.clear();

	showProgress_ = showProgress;

	if (bs)
		bs->clear();

	ASSERT(f_.isCTL());

	prepareModel();
	if (model().defined()) {

		// reduce formula to minimal set of connectives
		f_.reduce();
		pt(("CTLCheck, checking formula\n    %s\n==> %s\n",f.s(),f_.s()));
		extractSubformulas();

		for (int i = 0; i < sfOrder_.length(); i++)
			processFormula(sfOrder_[i]);

		if (printFormulas) {
			for (int i = 0; i < model().states(); i++) {
				int name = model().stateName(i);
				Cout << "State #" << name << ":\n";
				for (int j = 0; j < sfOrder_.length(); j++) {
					int form = sfOrder_[j];
					if (getFlag(i,form)) {
						Cout << "  ";
						f_.print(form,false);
						Cout << "\n";
					}
				}
				Cout << "\n";
			}
		}

		if (bs) {
			int satFormula = sfOrder_.last();

			for (int i = 0; i < model().states(); i++)
				if (getFlag(i,satFormula))
					bs->set(i);
			pt((" satisfying states: %s\n",bs->s() ));
		}
	}
}
Exemplo n.º 2
0
QDomElement OOoReportBuilder::processDetail(const QDomElement &rowDetail)
{
    QDomElement lastElement = rowDetail;

    if (rowDetail.isNull() || reportBand(rowDetail) != Detail)
        return QDomElement();

    QString textCell = cellText(rowDetail.firstChild().toElement());
    textCell.remove(QRegExp("\\{|\\}|detail"));
    int modelId = textCell.toInt() - 1;

    if (modelId < m_models.count() - 1) {
        rowDetail.parentNode().removeChild(rowDetail);
        return lastElement.previousSibling().toElement();
    }

    QAbstractItemModel *model = m_models.at(modelId);

    for (int i = 0; i < model->rowCount(); i++) {
        QDomElement tmpRow = rowDetail.cloneNode(true).toElement();

        QDomElement cell = tmpRow.firstChild().toElement();
        cell = cell.nextSibling().toElement();

        while (!cell.isNull()) {
            QString str = cellText(cell);

            if (!str.isEmpty()) {
                str.remove(QRegExp("\\{|\\}"));

                if (!QString::compare(str,"rowno",Qt::CaseInsensitive)) {
                    setText(cell,QString::number(i));
                } else if (str[0] == 'P') {

                    QVariant var = processParams(str.mid(2));
                    if (var.type() == QVariant::Double) {
                        setText(cell,var.toDouble());
                    } else {
                        setText(cell,var.toString());
                    }
                } else {
                    QRegExp rx("col\\d{1,2}");

                    if (rx.indexIn(str) == 0) {
                        int colNo = str.remove(QRegExp("col")).toInt();
                        QVariant var = model->data(model->index(i,colNo));
                        if (colNo <= model->columnCount() - 1) {
                            if (var.type() == QVariant::Double) {
                                setText(cell, var.toDouble());
                            } else
                                setText(cell, var.toString());
                        } else
                            setText(cell,"Err");
                    } else
                        setText(cell,str);
                }
            }

            if (cell.attributes().contains("table:formula")) {
                QString formula = processFormula(cell.attribute("table:formula"), i);
                cell.setAttribute("table:formula",formula);
            }

            cell = cell.nextSibling().toElement();
        }

        lastElement = rowDetail.parentNode().insertBefore(tmpRow,rowDetail).toElement();
    }

    rowDetail.parentNode().removeChild(rowDetail);
    return lastElement;
}