Exemplo n.º 1
0
void ParameterScanWorker::run()
{
    workerStarted();

    //The user may have aborted the minization... check here..
    if(mHost.isBeingTerminated())
    {
        //user did set the terminate flag to true.. discard any data and get out of the
        //plugin execute code..
        RRPLOG(lInfo)<<"The ParameterScanWorker was terminated.. aborting";
        workerFinished();
        return;
    }

    //Create arrayed data
    ArrayedParameter para(mHost.mParameter.getValueReference());

    StringList selList(mHost.mSelectionList.getValue());

    RoadRunner rr;
    rr.load(mHost.mSBML.getValue());

    //Make sure time is the first column in the selectin list
    if(selList.size() && compareNoCase(selList[0], "time") != true)
    {
        selList.InsertAt(0,"time");
    }
    rr.setSelections(selList);

    TelluriumData& data =     mHost.mOutputData.getValueReference();
    data.clear();
    for(int i = 0; i < para.getNumberOfIncrements() + 1; i++)
    {
        rr::SimulateOptions options;
        options.flags |= rr::SimulateOptions::RESET_MODEL;
        options.start = mHost.mStartTime.getValue();
        options.duration =  mHost.mEndTime.getValue() - mHost.mStartTime.getValue();
        options.steps = mHost.mNumberOfPointsPerSimulation.getValue() - 1;

        //Set parameter
        rr.setValue(para.getName(), para.getCurrentValue());
        const RoadRunnerData *rrData = rr.simulate(&options);
        TelluriumData *temp = new TelluriumData(*rrData);
        data.append(*temp);
        delete temp;
        para.increment();
    }

    //The Arrayed parameter need to be added to the data.
    data.setArrayedParameter(para);
    workerFinished();
}