예제 #1
0
void nmWorker::createModelData(TelluriumData* _data)
{
    TelluriumData& data = *(_data);
    TelluriumData* expData = (TelluriumData*) mHost.mExperimentalData.getValueHandle();

    Properties& outParas =  * (Properties*) mHost.mOutputParameterList.getValueHandle();
    int nrOfParameters = outParas.count();

    //We now have the parameters
    StringList selList("time");
    selList.append(mHost.mModelDataSelectionList.getValue());

    data.reSize(expData->rSize(), selList.count());
    mHost.mRRI->reset();
    mHost.mRRI->setSelections(selList);

    for(int i = 0; i < nrOfParameters; i++)
    {
        mHost.mRRI->setValue(outParas[i]->getName(),  * (double*) outParas[i]->getValueHandle());
    }

    rr::SimulateOptions options;
    options.start       = expData->getTimeStart();
    options.duration    = expData->getTimeEnd() - expData->getTimeStart();
    options.steps       = expData->rSize() - 1;

    options.flags = options.flags | rr::SimulateOptions::RESET_MODEL;

    if(mHost.mRRI->simulate(&options))
    {
        data = * (mHost.mRRI->getSimulationResult());
    }
}
예제 #2
0
double nmWorker::getChi(const Properties& parameters)
{
    Log(lDebug)<<"Getting chisquare using parameters: "<<parameters;
    //Reset RoadRunner
    mHost.mRRI->reset();

    for(int i = 0; i < parameters.count(); i++)
    {
        Property<double> *para = (Property<double>*) (parameters[i]);
        mHost.mRRI->setValue(para->getName(), para->getValue());
    }

    TelluriumData* expData = (TelluriumData*) mHost.mExperimentalData.getValueHandle();
    rr::SimulateOptions options;
    options.start       = expData->getTimeStart();
    options.duration    = expData->getTimeEnd() - expData->getTimeStart();
    options.steps       = expData->rSize() - 1;

    options.flags = options.flags | rr::SimulateOptions::RESET_MODEL;

    rr::RoadRunnerData *modelData = NULL;
    if(mHost.mRRI->simulate(&options))
    {
        modelData = mHost.mRRI->getSimulationResult();
    }

    TelluriumData& obsData      = *(TelluriumData*) mHost.mExperimentalData.getValuePointer();
    Plugin* chi                 = mHost.mPM->getPlugin("tel_chisquare");

    Property<TelluriumData>* para =  dynamic_cast<Property<TelluriumData>*>(chi->getProperty("ExperimentalData"));
    para->setValue(obsData);

    para =  dynamic_cast<Property<TelluriumData>*>(chi->getProperty("ModelData"));
    para->setValue(TelluriumData(*(modelData)));

    Property<int>* intPara =  dynamic_cast< Property<int>* >(chi->getProperty("NrOfModelParameters"));
    intPara->setValue(getNumberOfParameters());

    //Calculate Chi square
    chi->execute();
    Property<double>* chiSquare =  dynamic_cast< Property<double>* >(chi->getProperty("ChiSquare"));
    return chiSquare->getValue();
}