bool nevil::trial_controller::run()
{
  if (_current_generation < _max_generation_num)
  {
    if (_current_individual < _population_size)
    {
      if (_current_step == 0 && _current_individual != _population_size)
        _trial->reset();

      if (_current_step < _max_step_num)
      {
        _trial->update();
        ++_current_step;
      }
      else
      {
        ++_current_individual;
        _current_step = 0;
      }
    }
    else
    {
      _evaluate();
      ++_current_generation;
      _current_individual = 0;
      _current_step = 0;
      printf("-Trial %d: running generation %d\n", _trial_id, _current_generation);
    }
    return true;
  }

  _end();
  return false;
}
bool ScriptManager::executeScript(QString name) {
    if(name == "" || !hasScript(name)) {
        Logger::get().error("Cannot execute script \"" + name + "\": script not found.");
        return false;
    }

    return _evaluate(mScripts[name]);
}
void BandPass::_buildData(const BinMap& map, float scale, float /*offset*/) {
    int mapId = map.hash();
    _dataSets.insert(mapId, QVector<float>(map.numberBins()) );
    for( unsigned int i=0; i < map.numberBins(); ++i ) {
        _dataSets[mapId][i] = scale * _evaluate(map.binAssignmentNumber(i));
    }
    _zeroChannelsMap(map);
}
bool ScriptManager::evaluate(QString snippet, QString context) {
    return _evaluate(QScriptProgram(snippet, context));
}
Exemple #5
0
	virtual int evaluate(char* buf, int maxbuf) const {
		return _evaluate(buf, maxbuf,
				 RootExpression::timebase->getStride());
	}	
Exemple #6
0
	virtual int evaluate(char* buf, int maxbuf) const {
		return _evaluate(buf, maxbuf, 0);
	}
int main(int argc, char ** argv)
{
    // process options
    if(argc == 1 || (argc > 1 && strcmp(argv[1],"-h") == 0) ) {
        help(argv[0]);
        exit(0);
    }

    // Since the output of this program will be compared with
    // a master output file, turn off ICU message loading.
    MessageLoader::_useDefaultMsg = true;

    String testOption;
    String className;
    String nameSpace;

    for(int i = 0; i < argc; i++) {
        if((strcmp(argv[i],"-test") == 0) && (i+1 < argc))
            testOption = argv[i+1];
        if((strcmp(argv[i],"-className") == 0) && (i+1 < argc))
            className = argv[i+1];
        if((strcmp(argv[i],"-nameSpace") == 0) && (i+1 < argc))
            nameSpace = argv[i+1];
    }

    String lang("WQL");
    Array<CQLSelectStatement> _statements;

    // setup test environment
    // get the configuration variable PEGASUS_HOME
    const char* peg_home = getenv("PEGASUS_HOME");

    // get the makefile build config variable REPOSITORY_NAME
    const char* repo_name = getenv("REPOSITORY_NAME");


    if (peg_home == NULL)
        exit(-1);

    if (repo_name == NULL)
        repo_name = "repository";


    String repositoryDir(peg_home);
    repositoryDir.append("/");
    repositoryDir.append(repo_name);

    CIMNamespaceName _ns;
    if(nameSpace != String::EMPTY) {
        _ns = nameSpace;
    } else {
        cout << "Using root/SampleProvider as default namespace." << endl;
        _ns = String("root/SampleProvider");
    }

    CIMRepository* _rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _ctx(_ns, _rep);

    char text[1024];
    char* _text;

    // setup Test Instances
    Array<CIMInstance> _instances;
    if(className != String::EMPTY) {
        try {
            const CIMName _testclass(className);
            _instances = _rep->enumerateInstances( _ns, _testclass, true );  // deep inh true
        } catch(Exception& e) {
            cout << endl << endl
                 << "Exception: Invalid namespace/class: "
                 << e.getMessage() << endl << endl;
        }
    } else { // load default class names
        cout << endl << "Using default class names to test queries. " << endl << endl;
        const CIMName _testclass(String("QExpr_TestPropertyTypes"));
        const CIMName _testclass2(String("QExpr_TestElement"));
        try {
            _instances = _rep->enumerateInstances( _ns, _testclass, true ); // deep inh true
            _instances.appendArray(_rep->enumerateInstances( _ns, _testclass2, true )); // deep inh true
        } catch(Exception& e) {
            cout << endl << endl << "Exception: Invalid namespace/class: " << e.getMessage() << endl << endl;
        }
    }

    // setup input stream
    if(argc >= 2) {
        ifstream queryInputSource(argv[1]);
        if(!queryInputSource) {
            cout << "Cannot open input file.\n" << endl;
            return 1;
        }
        int cnt = 0;
        while(!queryInputSource.eof()) {
            queryInputSource.getline(text, 1024);
            char* _ptr = text;
            _text = strcat(_ptr,"\n");
            // check for comments and ignore
            // a comment starts with a # as the first non whitespace character on the line
            char _comment = '#';
            int i = 0;
            while(text[i] == ' ' || text[i] == '\t') i++; // ignore whitespace
            if(text[i] != _comment)
            {
                if(!(strlen(_text) < 2))
                {
                    String query(text);
                    if(query == "WQL:\n") lang = "WQL";
                    else if(query == "CQL:\n") lang = "CIM:CQL";
                    else
                    {
                        try
                        {
                            QueryExpression qexpr;

                            if(cnt % 2)
                            {
                                qexpr = QueryExpression(lang,query);
                                qexpr.setQueryContext(_ctx);
                            }
                            else
                            {
                                qexpr = QueryExpression(lang,query,_ctx);
                            }

                            cnt++;

                            SelectStatement* ss = qexpr.getSelectStatement();

                            String returnQuery = qexpr.getQuery();
                            PEGASUS_ASSERT(returnQuery == query);

                            String returnLang = qexpr.getQueryLanguage();
                            PEGASUS_ASSERT(returnLang == lang);

                            QueryExpression copy(qexpr);
                            PEGASUS_ASSERT(copy.getQuery() == qexpr.getQuery());
                            PEGASUS_ASSERT(copy.getQueryLanguage() == qexpr.getQueryLanguage());

                            _applyProjection(qexpr,_instances, testOption, lang);
                            _getPropertyList(qexpr,_instances, _ns, testOption,lang);
                            _validate(qexpr,lang, testOption);
                            _evaluate(qexpr,_instances, testOption,lang);
                        }
                        catch(Exception& e) {
                            cout << e.getMessage() << endl;
                        }
                        catch(...) {
                            cout << "CAUGHT ... BADNESS HAPPENED!!!" << endl;
                        }
                    }
                }
            }

            // while (!eof) behaves differently on HP-UX, seems
            // like it takes an extra iteration to hit eof.  This
            // leaves "text" with the previous value from
            // getline(..), which causes a duplicate parse of
            // the last select statement in the query file,
            // FIX: we clear text before doing another getline(..)
            text[0] = 0;
        }
        queryInputSource.close();
    } else {
        cout << "Invalid number of arguments.\n" << endl;
    }
    delete _rep;
    return 0;
}
Exemple #8
0
real_t MitchellFilter::evaluate(const Vector2 &pt) {
   return _evaluate(pt[0]) * _evaluate(pt[1]);
}
Exemple #9
0
 double polynomial::term::evaluate(const polynomial::term& t, const std::vector<double>& x)
 {
   return _evaluate(t, x);
 }