Esempio n. 1
0
 void MetaModel::associateUsername(QString username)
 {
    QSqlRecord rec = this->record(0);
    rec.setValue("username", username);
    this->setRecord(0,rec);
    revise();
 }
Esempio n. 2
0
    CSPSolution& AC3Preprocessor::preprocess( CSPSolution& sol )
    {
        printf("ac-3 started\n");

        queue<vars> q;
        vars a;

        printf("adding all tuples to queue\n");
        for( unsigned int i = 0; i < sol.problem->variables.size(); i++ )
        {
            for( unsigned int j = i+1; j < sol.problem->variables.size(); j++ )
            {
                vector<Constraint*>::iterator cnstr;
                for( cnstr = sol.problem->constraints.begin(); cnstr != sol.problem->constraints.end(); cnstr++ )
                {
                    unsigned int idx0 = (*cnstr)->scope[0];
                    unsigned int idx1 = (*cnstr)->scope[1];
                    if( (*cnstr)->scope.size() == 2 &&
                          ( ( idx0 == i && idx1 == j ) || ( idx1 == i && idx0 == j ) ) )
                    {
                        q.push( make_pair( i, j ) );
                        q.push( make_pair( j, i ) );
                    }
                }
            }
        }

        while(q.size()!=0)
        {
           vars vartuple = q.front(); q.pop();
           unsigned int idx0 = vartuple.first;

           if( revise( sol, vartuple ) )
           {
                for( unsigned int i = 0; i < sol.problem->variables.size(); i++ )
                {
                    if( i != idx0 ) q.push( make_pair( i, idx0 ) );
                }
           }
        }

        printf("ac-3 done\n");
        return sol;
    }