michaelis_menten.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
27 
39 #include <acado_gnuplot.hpp>
40 
41 
42 int main( ){
43 
45 
46  // INTRODUCE THE VARIABLES:
47  // -------------------------
48  Parameter V ;
49  Parameter km;
50 
51 
52  // READ THE MEASUREMENT FROM A DATA FILE:
53  // --------------------------------------
54  DMatrix m; m.read( "michaelis_menten_data.txt" );
55 
56 
57  // DEFINE A MEASUREMENT FUNCTION:
58  // ------------------------------
59  Function h; // the measurement function
60 
61  int i;
62  for( i = 0; i < (int) m.getNumRows(); i++ )
63  h << V*m(i,0)/(km + m(i,0)) - m(i,1);
64 
65 
66  // DEFINE A PARAMETER ESTIMATION PROBLEM:
67  // --------------------------------------
68  NLP nlp;
69  nlp.minimizeLSQ( h );
70 
71  nlp.subjectTo( 0.0 <= V <= 2.0 );
72  nlp.subjectTo( 0.0 <= km <= 2.0 );
73 
74 
75  // DEFINE AN OPTIMIZATION ALGORITHM AND SOLVE THE ESTIMATION PROBLEM:
76  // ------------------------------------------------------------------
77  ParameterEstimationAlgorithm algorithm(nlp);
78  algorithm.solve();
79 
80 
81  VariablesGrid parameters;
82  algorithm.getParameters( parameters );
83 
84  return 0;
85 
86  // GET THE VARIANCE COVARIANCE IN THE SOLUTION:
87  // ---------------------------------------------
88  DMatrix var;
89  algorithm.getParameterVarianceCovariance( var );
90 
91  double LSSE = 2.0*algorithm.getObjectiveValue();
92  double MSE = LSSE/( m.getNumRows() - 2.0 ); // m.getNumRows() == number of measurements
93  // 2 == number of parameters
94 
95  var *= MSE; // rescale the variance-covariance with the MSE factor.
96 
97 
98  // PRINT THE RESULT ON THE TERMINAL:
99  // -----------------------------------------------------------------------
100  printf("\n\nResults for the parameters: \n");
101  printf("-----------------------------------------------\n");
102  printf(" V = %.3e +/- %.3e \n", parameters(0,0), sqrt( var(0,0) ) );
103  printf(" km = %.3e +/- %.3e \n", parameters(0,1), sqrt( var(1,1) ) );
104  printf("-----------------------------------------------\n\n\n");
105 
106  return 0;
107 }
108 
109 
110 
Allows to setup and evaluate a general function based on SymbolicExpressions.
Definition: function_.hpp:59
IntermediateState sqrt(const Expression &arg)
#define USING_NAMESPACE_ACADO
Provides a time grid consisting of vector-valued optimization variables at each grid point...
int main()
returnValue getParameters(VariablesGrid &u_) const
returnValue subjectTo(const DifferentialEquation &differentialEquation_)
Definition: ocp.cpp:153
returnValue getParameterVarianceCovariance(DMatrix &pVar)
User-interface to formulate and solve parameter estimation problems.
returnValue minimizeLSQ(const DMatrix &S, const Function &h, const DVector &r)
Definition: ocp.cpp:244
Data class for defining static optimization problems.
Definition: nlp.hpp:47
double getObjectiveValue(const char *fileName) const
virtual returnValue read(std::istream &_stream)
Definition: matrix.cpp:419
unsigned getNumRows() const
Definition: matrix.hpp:185
virtual returnValue solve()


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:54