示例#1
0
文件: widget.cpp 项目: mik9/mmethod
void Widget::mainProcedure(double** tempA, double* tempB, double* tempF)
{
    //перевірка нетут, або взагалі непотрібна
//    if(!(nEq<nArgs))
//    {
//        QMessageBox::critical(NULL,tr(""),tr("Невірні дані\nКількість невідомих повинна бути строго більше кількості рівнянь."),QMessageBox::Ok);
//        return;
//    }
    //перевіряємо обмеження
    for(int i=0;i<nEq;i++)
    {
        if(tempB[i]<0)
        {
            QMessageBox::critical(NULL,tr(""),tr("Невірні дані\nПеревірте вектор В."),QMessageBox::Ok);
            return;
        }
    }
    if(direction==tr("min"))
    {
        for(int i=0;i<nArgs;i++)
            tempF[i]=-tempF[i];
    }
    //чистимо минулі данні
    deleteData();

    //відправляємо дані на аналіз та створення першої симплекс таблиці
    genFirstSTable(tempA,tempF,tempB,rel);
    //запускаємо обчислення
    m_result=calc();
    showHideInput(false);
    fillTables();
    p2->setChecked(false);
}
示例#2
0
void Function::fillTables(map<string, StateObsAct*>& mymap,
        const vector<string>& insttokens, const vector<double>& probttokensdouble) {
    bool simple = true;
    bool seestar = false;

    // this method should stop if a '-' or '*' is found.
    // in this case, it will call filLTables with the new parameters
    for (unsigned int i = 0; i < insttokens.size() && !seestar; i++) {

        if (insttokens[i] == "*" || insttokens[i] == "-") {
            seestar = true;
            simple = false;
            vector<string> allCombinations;
            if (i != insttokens.size() - 1) {
                if (mymap.find(parents[i]) != mymap.end()) {
                    allCombinations = mymap[parents[i]]->getValueEnum(); // get all the various enumerations
                } else {
                    cerr<<"Couldn't find mapping for:"<<parents[i]<<endl;
                    cerr<<"Please check XML file again."<<endl;
                    exit(-1);
                }
            } else {
                if (mymap.find(vnameCurr) != mymap.end()) {
                    allCombinations = mymap[vnameCurr]->getValueEnum();
                } else {
                    cerr<<"Couldn't find mapping for:"<<vnameCurr<<endl;
                    cerr<<"Please check XML file again."<<endl;
                    exit(-1);
                }
            }//end of if

            // multiple fillTables will be called, populating the table with entries
            for (unsigned int j = 0; j < allCombinations.size(); j++) {

                // replace an '-' or '*' with a string
                vector<string> temp = insttokens;
                string s(allCombinations[j]);
                temp.erase(temp.begin() + i);
                temp.insert(temp.begin() + i, s);

                // split the probtables if the input is a -
                // recursive calls
                if (insttokens[i] == "-") {
                    // splitTable will allocate the probability tokens to the correct parent
                    // note that one parent may still has more than one probability token
                    // assuming parents = action, X, parentA, parentB,
                    // and parentA has 2 elements a1,a2, while parentB has two elements,b1,2
                    // <Instance>action x - -</Instance>
                    // <ProbTable> x1 x2 x3 x4 </ProbTable>
                    // in this case,
                    // for the first iteration, when our program detects the first '-'
                    // x1 and x2 are allocated to the first element of the first '-', namely a1
                    // while x3 and x4 are allocated to the second element of the first '-,', namely a2


                    vector<double> st = splitTable(probttokensdouble, allCombinations.size(), j);
                    fillTables(mymap, temp, st);
                } else {
                    fillTables(mymap, temp, probttokensdouble);
                }
            }//end of for
        }//end of if
    }//end of for

    if (probttokensdouble.size() > 1)
        simple = false;

    //Base Case
    if (simple) {
        // simple means without * or -
        // separate the insttokens into the "tokens of parents" and "itself"
        // pass to simpleInsert
        string myself = insttokens.back();

        // Note new_insttokens size is now 1 less than insttokens
        vector<string> new_insttokens;
        new_insttokens.resize(insttokens.size() - 1);
        copy(insttokens.begin(), insttokens.end()-1, new_insttokens.begin());

        simpleSparseInsert(mymap, new_insttokens, myself, probttokensdouble.front());
    }
}
示例#3
0
文件: widget.cpp 项目: EXL/MSN-Parser
MsnParser::MsnParser(QObject *parent) :
    QObject(parent)
{
    dateRange = y_76_99;
    fillTables();
}