Page 1 of 1

how the moco objectives are claculated

Posted: Wed Sep 07, 2022 10:40 am
by ostr1969
I succeed in calculating with MocoOutputGoal of metabolic probe by:

Code: Select all

    auto* metGoal = problem.addGoal<MocoOutputGoal>("met", 0.1);
    metGoal->setOutputPath("/metabolics|total_metabolic_rate");
    metGoal->setDivideByDisplacement(true);
    metGoal->setDivideByMass(true);
and I see the summary result at the solution printout. "objective_met=0.39"
Than i calculate the same output by:

Code: Select all

    TimeSeriesTable outputTable =
            analyzeMocoTrajectory<double>(model, solution,
            {  "/metabolics\\|total_metabolic_rate"});

When I try to integrate the storage result I get totally different value 184.64.
I didn't use divide by mass or divide by displacement.

Am I wrong in something here?

Re: how the moco objectives are claculated

Posted: Thu Sep 08, 2022 10:36 am
by ongcf
It looks like you used divide by mass and displacement in the first code block, which could account for the difference when you integrated and didn't divide by mass or displacement. Further, you have a weight of 0.1 in the first code block that changes the objective value by 1/10.

Re: how the moco objectives are claculated

Posted: Sat Sep 10, 2022 6:29 am
by ostr1969
I found the reason but I dont understand.
Where I read the model from file and compute analyzeMocoTrajectory I get one result
but when I use the model in the same procedure immediately after the solution I get anther solution
I had output for many other variables and there are all identical, all but the metabolics.

Code: Select all

...
 Model model = modelprocessor.process();
...
study.solve
...
//ONE OPTION 
      TimeSeriesTable outputTable01 =
            analyzeMocoTrajectory<double>(model, solution,
            { "/metabolics\\|total_metabolic_rate" });
    STOFileAdapter_<double>::write(outputTable01, "outputs01.sto");
//SECOND  OPTION
  model.print(modelfilename);
   Model model00(modelfilename);
    TimeSeriesTable outputTable00 =
            analyzeMocoTrajectory<double>(model00, solution00,
            { "/metabolics\\|total_metabolic_rate" });
    STOFileAdapter_<double>::write(outputTable00, "outputs02.sto");
What did I miss?