1 | /*!\file: CreateParametersControl.cpp
|
---|
2 | * \brief driver for creating parameters dataset, for control analysis.
|
---|
3 | */
|
---|
4 |
|
---|
5 | #undef __FUNCT__
|
---|
6 | #define __FUNCT__ "CreateParameters"
|
---|
7 |
|
---|
8 | #include "../../DataSet/DataSet.h"
|
---|
9 | #include "../../toolkits/toolkits.h"
|
---|
10 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
11 | #include "../../objects/objects.h"
|
---|
12 | #include "../../shared/shared.h"
|
---|
13 | #include "../Model.h"
|
---|
14 |
|
---|
15 | void CreateParametersControl(DataSet** pparameters,Model* model,ConstDataHandle model_handle){
|
---|
16 |
|
---|
17 | int i;
|
---|
18 |
|
---|
19 | DataSet* parameters=NULL;
|
---|
20 | Param* param = NULL;
|
---|
21 | int count;
|
---|
22 | int analysis_type;
|
---|
23 | int numberofdofspernode;
|
---|
24 |
|
---|
25 | double* fit=NULL;
|
---|
26 | double* optscal=NULL;
|
---|
27 | double* maxiter=NULL;
|
---|
28 | double* control_parameter=NULL;
|
---|
29 | double* vx_obs=NULL;
|
---|
30 | double* vy_obs=NULL;
|
---|
31 | double* u_g_obs=NULL;
|
---|
32 | double* p_g=NULL;
|
---|
33 |
|
---|
34 | /*Get parameters: */
|
---|
35 | parameters=*pparameters;
|
---|
36 | count=parameters->Size();
|
---|
37 |
|
---|
38 | /*control_type: */
|
---|
39 | count++;
|
---|
40 | param= new Param(count,"control_type",STRING);
|
---|
41 | param->SetString(model->control_type);
|
---|
42 | parameters->AddObject(param);
|
---|
43 |
|
---|
44 |
|
---|
45 | /*nsteps: */
|
---|
46 | count++;
|
---|
47 | param= new Param(count,"nsteps",INTEGER);
|
---|
48 | param->SetInteger(model->nsteps);
|
---|
49 | parameters->AddObject(param);
|
---|
50 |
|
---|
51 | /*tolx: */
|
---|
52 | count++;
|
---|
53 | param= new Param(count,"tolx",DOUBLE);
|
---|
54 | param->SetDouble(model->tolx);
|
---|
55 | parameters->AddObject(param);
|
---|
56 |
|
---|
57 | /*mincontrolconstraint: */
|
---|
58 | count++;
|
---|
59 | param= new Param(count,"mincontrolconstraint",DOUBLE);
|
---|
60 | param->SetDouble(model->mincontrolconstraint);
|
---|
61 | parameters->AddObject(param);
|
---|
62 |
|
---|
63 | /*maxcontrolconstraint: */
|
---|
64 | count++;
|
---|
65 | param= new Param(count,"maxcontrolconstraint",DOUBLE);
|
---|
66 | param->SetDouble(model->maxcontrolconstraint);
|
---|
67 | parameters->AddObject(param);
|
---|
68 |
|
---|
69 | /*epsvel: */
|
---|
70 | count++;
|
---|
71 | param= new Param(count,"epsvel",DOUBLE);
|
---|
72 | param->SetDouble(model->epsvel);
|
---|
73 | parameters->AddObject(param);
|
---|
74 |
|
---|
75 | /*meanvel: */
|
---|
76 | count++;
|
---|
77 | param= new Param(count,"meanvel",DOUBLE);
|
---|
78 | param->SetDouble(model->meanvel);
|
---|
79 | parameters->AddObject(param);
|
---|
80 |
|
---|
81 | /*Now, recover fit, optscal and maxiter as vectors: */
|
---|
82 | ModelFetchData((void**)&model->fit,NULL,NULL,model_handle,"fit","Matrix","Mat");
|
---|
83 | ModelFetchData((void**)&model->optscal,NULL,NULL,model_handle,"optscal","Matrix","Mat");
|
---|
84 | ModelFetchData((void**)&model->maxiter,NULL,NULL,model_handle,"maxiter","Matrix","Mat");
|
---|
85 |
|
---|
86 | count++;
|
---|
87 | param= new Param(count,"fit",DOUBLEVEC);
|
---|
88 | param->SetDoubleVec(model->fit,model->nsteps);
|
---|
89 | parameters->AddObject(param);
|
---|
90 |
|
---|
91 | count++;
|
---|
92 | param= new Param(count,"optscal",DOUBLEVEC);
|
---|
93 | param->SetDoubleVec(model->optscal,model->nsteps);
|
---|
94 | parameters->AddObject(param);
|
---|
95 |
|
---|
96 | count++;
|
---|
97 | param= new Param(count,"maxiter",DOUBLEVEC);
|
---|
98 | param->SetDoubleVec(model->maxiter,model->nsteps);
|
---|
99 | parameters->AddObject(param);
|
---|
100 |
|
---|
101 | xfree((void**)&model->fit);
|
---|
102 | xfree((void**)&model->optscal);
|
---|
103 | xfree((void**)&model->maxiter);
|
---|
104 |
|
---|
105 | /*Get vx_obs, vy_obs, and the parameter value: */
|
---|
106 | ModelFetchData((void**)&vx_obs,NULL,NULL,model_handle,"vx_obs","Matrix","Mat");
|
---|
107 | ModelFetchData((void**)&vy_obs,NULL,NULL,model_handle,"vy_obs","Matrix","Mat");
|
---|
108 | ModelFetchData((void**)&control_parameter,NULL,NULL,model_handle,model->control_type,"Matrix","Mat");
|
---|
109 |
|
---|
110 | u_g_obs=(double*)xcalloc(model->numberofnodes*2,sizeof(double));
|
---|
111 | if(vx_obs)for(i=0;i<model->numberofnodes;i++)u_g_obs[2*i+0]=vx_obs[i]/model->yts;
|
---|
112 | if(vy_obs)for(i=0;i<model->numberofnodes;i++)u_g_obs[2*i+1]=vy_obs[i]/model->yts;
|
---|
113 |
|
---|
114 | count++;
|
---|
115 | param= new Param(count,"velocity_observed",DOUBLEVEC);
|
---|
116 | param->SetDoubleVec(u_g_obs,2*model->numberofnodes,2);
|
---|
117 | parameters->AddObject(param);
|
---|
118 |
|
---|
119 | p_g=(double*)xcalloc(model->numberofnodes*2,sizeof(double));
|
---|
120 | for(i=0;i<model->numberofnodes;i++)p_g[2*i+0]=parameter[i];
|
---|
121 |
|
---|
122 | count++;
|
---|
123 | param= new Param(count,"parameter",DOUBLEVEC);
|
---|
124 | param->SetDoubleVec(p_g,model->numberofnodes,1);
|
---|
125 | parameters->AddObject(param);
|
---|
126 |
|
---|
127 | xfree((void**)&vx_obs);
|
---|
128 | xfree((void**)&vy_obs);
|
---|
129 | xfree((void**)&u_g_obs);
|
---|
130 | xfree((void**)&p_g);
|
---|
131 | xfree((void**)&control_parameter);
|
---|
132 |
|
---|
133 |
|
---|
134 | /*Assign output pointer: */
|
---|
135 | *pparameters=parameters;
|
---|
136 | }
|
---|
137 |
|
---|
138 |
|
---|