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* param_g=NULL;
|
---|
30 |
|
---|
31 | double* vx_obs=NULL;
|
---|
32 | double* vy_obs=NULL;
|
---|
33 | double* u_g_obs=NULL;
|
---|
34 |
|
---|
35 | double* vx=NULL;
|
---|
36 | double* vy=NULL;
|
---|
37 | double* vz=NULL;
|
---|
38 | double* u_g=NULL;
|
---|
39 |
|
---|
40 | /*Get parameters: */
|
---|
41 | parameters=*pparameters;
|
---|
42 | count=parameters->Size();
|
---|
43 |
|
---|
44 | /*control_type: */
|
---|
45 | count++;
|
---|
46 | param= new Param(count,"control_type",STRING);
|
---|
47 | param->SetString(model->control_type);
|
---|
48 | parameters->AddObject(param);
|
---|
49 |
|
---|
50 | /*nsteps: */
|
---|
51 | count++;
|
---|
52 | param= new Param(count,"nsteps",INTEGER);
|
---|
53 | param->SetInteger(model->nsteps);
|
---|
54 | parameters->AddObject(param);
|
---|
55 |
|
---|
56 | /*tolx: */
|
---|
57 | count++;
|
---|
58 | param= new Param(count,"tolx",DOUBLE);
|
---|
59 | param->SetDouble(model->tolx);
|
---|
60 | parameters->AddObject(param);
|
---|
61 |
|
---|
62 | /*mincontrolconstraint: */
|
---|
63 | count++;
|
---|
64 | param= new Param(count,"mincontrolconstraint",DOUBLE);
|
---|
65 | param->SetDouble(model->mincontrolconstraint);
|
---|
66 | parameters->AddObject(param);
|
---|
67 |
|
---|
68 | /*maxcontrolconstraint: */
|
---|
69 | count++;
|
---|
70 | param= new Param(count,"maxcontrolconstraint",DOUBLE);
|
---|
71 | param->SetDouble(model->maxcontrolconstraint);
|
---|
72 | parameters->AddObject(param);
|
---|
73 |
|
---|
74 | /*epsvel: */
|
---|
75 | count++;
|
---|
76 | param= new Param(count,"epsvel",DOUBLE);
|
---|
77 | param->SetDouble(model->epsvel);
|
---|
78 | parameters->AddObject(param);
|
---|
79 |
|
---|
80 | /*meanvel: */
|
---|
81 | count++;
|
---|
82 | param= new Param(count,"meanvel",DOUBLE);
|
---|
83 | param->SetDouble(model->meanvel);
|
---|
84 | parameters->AddObject(param);
|
---|
85 |
|
---|
86 | /*Now, recover fit, optscal and maxiter as vectors: */
|
---|
87 | ModelFetchData((void**)&model->fit,NULL,NULL,model_handle,"fit","Matrix","Mat");
|
---|
88 | ModelFetchData((void**)&model->optscal,NULL,NULL,model_handle,"optscal","Matrix","Mat");
|
---|
89 | ModelFetchData((void**)&model->maxiter,NULL,NULL,model_handle,"maxiter","Matrix","Mat");
|
---|
90 |
|
---|
91 | count++;
|
---|
92 | param= new Param(count,"fit",DOUBLEVEC);
|
---|
93 | param->SetDoubleVec(model->fit,model->nsteps);
|
---|
94 | parameters->AddObject(param);
|
---|
95 |
|
---|
96 | count++;
|
---|
97 | param= new Param(count,"optscal",DOUBLEVEC);
|
---|
98 | param->SetDoubleVec(model->optscal,model->nsteps);
|
---|
99 | parameters->AddObject(param);
|
---|
100 |
|
---|
101 | count++;
|
---|
102 | param= new Param(count,"maxiter",DOUBLEVEC);
|
---|
103 | param->SetDoubleVec(model->maxiter,model->nsteps);
|
---|
104 | parameters->AddObject(param);
|
---|
105 |
|
---|
106 | xfree((void**)&model->fit);
|
---|
107 | xfree((void**)&model->optscal);
|
---|
108 | xfree((void**)&model->maxiter);
|
---|
109 |
|
---|
110 | /*Get vx, vx_obs, vy, vy_obs, and the parameter value: */
|
---|
111 | ModelFetchData((void**)&vx,NULL,NULL,model_handle,"vx","Matrix","Mat");
|
---|
112 | ModelFetchData((void**)&vy,NULL,NULL,model_handle,"vy","Matrix","Mat");
|
---|
113 | ModelFetchData((void**)&vz,NULL,NULL,model_handle,"vz","Matrix","Mat");
|
---|
114 | ModelFetchData((void**)&vx_obs,NULL,NULL,model_handle,"vx_obs","Matrix","Mat");
|
---|
115 | ModelFetchData((void**)&vy_obs,NULL,NULL,model_handle,"vy_obs","Matrix","Mat");
|
---|
116 | ModelFetchData((void**)&control_parameter,NULL,NULL,model_handle,model->control_type,"Matrix","Mat");
|
---|
117 |
|
---|
118 | u_g=(double*)xcalloc(model->numberofnodes*3,sizeof(double));
|
---|
119 | if(vx)for(i=0;i<model->numberofnodes;i++)u_g[3*i+0]=vx[i]/model->yts;
|
---|
120 | if(vy)for(i=0;i<model->numberofnodes;i++)u_g[3*i+1]=vy[i]/model->yts;
|
---|
121 | if(vz)for(i=0;i<model->numberofnodes;i++)u_g[3*i+2]=vz[i]/model->yts;
|
---|
122 |
|
---|
123 | count++;
|
---|
124 | param= new Param(count,"u_g",DOUBLEVEC);
|
---|
125 | param->SetDoubleVec(u_g,3*model->numberofnodes,3);
|
---|
126 | parameters->AddObject(param);
|
---|
127 |
|
---|
128 | u_g_obs=(double*)xcalloc(model->numberofnodes*2,sizeof(double));
|
---|
129 | if(vx_obs)for(i=0;i<model->numberofnodes;i++)u_g_obs[2*i+0]=vx_obs[i]/model->yts;
|
---|
130 | if(vy_obs)for(i=0;i<model->numberofnodes;i++)u_g_obs[2*i+1]=vy_obs[i]/model->yts;
|
---|
131 |
|
---|
132 | count++;
|
---|
133 | param= new Param(count,"u_g_obs",DOUBLEVEC);
|
---|
134 | param->SetDoubleVec(u_g_obs,2*model->numberofnodes,2);
|
---|
135 | parameters->AddObject(param);
|
---|
136 |
|
---|
137 | param_g=(double*)xcalloc(model->numberofnodes,sizeof(double));
|
---|
138 | for(i=0;i<model->numberofnodes;i++)param_g[i]=control_parameter[i];
|
---|
139 |
|
---|
140 | count++;
|
---|
141 | param= new Param(count,"param_g",DOUBLEVEC);
|
---|
142 | param->SetDoubleVec(param_g,model->numberofnodes,1);
|
---|
143 | parameters->AddObject(param);
|
---|
144 |
|
---|
145 | xfree((void**)&vx);
|
---|
146 | xfree((void**)&vy);
|
---|
147 | xfree((void**)&vz);
|
---|
148 | xfree((void**)&u_g);
|
---|
149 | xfree((void**)&vx_obs);
|
---|
150 | xfree((void**)&vy_obs);
|
---|
151 | xfree((void**)&u_g_obs);
|
---|
152 | xfree((void**)¶m_g);
|
---|
153 | xfree((void**)&control_parameter);
|
---|
154 |
|
---|
155 | /*Assign output pointer: */
|
---|
156 | *pparameters=parameters;
|
---|
157 | }
|
---|