示例#1
0
文件: main.cpp 项目: rfloresx/AI
int main(){
	std::map<std::string,float> data = loadDistanceData("test1_1.txt");
	MyGraph graph = loadGraphData("test1_2.txt");
	std::list<std::string> list;
	heoristic(graph,"Arad", "Bucharest",data,list);
	for( std::string s : list){
		cout << s << " - ";
	}
	std::system("pause");
	return 0;
}
示例#2
0
FnData Calculator::compute(const QString & input)
{

    FnData output;

    // try to match with previous input
    if (input == PreviousOutput)
        return previousOutput;

    // try to match with integer
    bool isInt;
    int n = input.toInt(&isInt);
    if (isInt) {
        output.setInteger(n);
    }

    // try to match with variable
    else if (variableRegExp.exactMatch(input)) {

        output.setFailMessage(tr("Name Error: \"%1\" is not defined").arg(input));

        // check variable list for input - last _
        output = variableList.value(input.left(input.size() - 1),output);

    }

    // try to match with element
    else if (wordRegExp.exactMatch(input)) {

        output.setFailMessage(tr("Basis Error: %1 is not a word in the basis %2").arg(input).arg(basis));

        FnWord u(input);
        if (u.checkBasis(basis)) {
            u.tighten();
            output.setElement(u);
        }

    }

    // try to match with graph
    else if (graphRegExp.exactMatch(input)) {

        output = loadGraphData(input);

    }

    // try to match with morphism
    else if (morphismRegExp.exactMatch(input)) {

        output = loadMorphismData(input);

      }

    // try to match with list
    else if (listRegExp.exactMatch(input)){

        QString list = input.simplified();
        // remove [ and ]
        list.chop(1);
        list.remove(0,1);

        QStringList listData = breakAtTopLevel(list);
        output = compute(listData.takeFirst());
        foreach(QString listItem, listData) {
            output.addToList(compute(listItem));
        }