Changeset 6226
- Timestamp:
- 10/11/10 10:05:52 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
r6213 r6226 43 43 parameters->AddObject(new DoubleParam(MeanVelEnum,iomodel->meanvel)); 44 44 parameters->AddObject(new DoubleParam(CmNoiseDmpEnum,iomodel->cm_noisedmp)); 45 parameters->AddObject(new DoubleParam(CmMinEnum,iomodel->cm_min)); 46 parameters->AddObject(new DoubleParam(CmMaxEnum,iomodel->cm_max)); 45 47 46 parameters->AddObject(new BoolParam(CmGradientEnum,iomodel->cm_gradient)); 48 47 … … 50 49 IoModelFetchData(&iomodel->cm_responses,NULL,NULL,iomodel_handle,"cm_responses"); 51 50 IoModelFetchData(&iomodel->cm_jump,NULL,NULL,iomodel_handle,"cm_jump"); 51 IoModelFetchData(&iomodel->cm_min,NULL,NULL,iomodel_handle,"cm_min"); 52 IoModelFetchData(&iomodel->cm_max,NULL,NULL,iomodel_handle,"cm_max"); 52 53 IoModelFetchData(&iomodel->optscal,NULL,NULL,iomodel_handle,"optscal"); 53 54 IoModelFetchData(&iomodel->maxiter,NULL,NULL,iomodel_handle,"maxiter"); … … 55 56 parameters->AddObject(new DoubleVecParam(CmResponsesEnum,iomodel->cm_responses,iomodel->nsteps)); 56 57 parameters->AddObject(new DoubleVecParam(CmJumpEnum,iomodel->cm_jump,iomodel->nsteps)); 57 parameters->AddObject(new DoubleVecParam(OptScalEnum,iomodel->optscal,iomodel->nsteps)); 58 parameters->AddObject(new DoubleMatParam(OptScalEnum,iomodel->optscal,iomodel->nsteps,iomodel->num_control_type)); 59 parameters->AddObject(new DoubleVecParam(CmMinEnum,iomodel->cm_min,iomodel->num_control_type)); 60 parameters->AddObject(new DoubleVecParam(CmMaxEnum,iomodel->cm_max,iomodel->num_control_type)); 58 61 parameters->AddObject(new DoubleVecParam(MaxIterEnum,iomodel->maxiter,iomodel->nsteps)); 59 62 60 63 xfree((void**)&iomodel->cm_responses); 61 64 xfree((void**)&iomodel->cm_jump); 65 xfree((void**)&iomodel->cm_min); 66 xfree((void**)&iomodel->cm_max); 62 67 xfree((void**)&iomodel->optscal); 63 68 xfree((void**)&iomodel->maxiter); -
issm/trunk/src/c/objects/Elements/Penta.cpp
r6222 r6226 1134 1134 int* control_type=NULL; 1135 1135 Input* input=NULL; 1136 double cm_min,cm_max; 1136 double *cm_min=NULL; 1137 double *cm_max=NULL; 1137 1138 1138 1139 /*retrieve some parameters: */ 1139 this->parameters->FindParam(&cm_min, CmMinEnum);1140 this->parameters->FindParam(&cm_max, CmMaxEnum);1140 this->parameters->FindParam(&cm_min,NULL,CmMinEnum); 1141 this->parameters->FindParam(&cm_max,NULL,CmMaxEnum); 1141 1142 this->parameters->FindParam(&num_controls,NumControlsEnum); 1142 1143 this->parameters->FindParam(&control_type,NULL,ControlTypeEnum); … … 1155 1156 1156 1157 ((ControlInput*)input)->UpdateValue(scalar); 1157 input->Constrain(cm_min ,cm_max);1158 input->Constrain(cm_min[i],cm_max[i]); 1158 1159 if (save_parameter) ((ControlInput*)input)->SaveValue(); 1159 1160 -
issm/trunk/src/c/objects/Elements/Tria.cpp
r6222 r6226 1342 1342 int* control_type=NULL; 1343 1343 Input* input=NULL; 1344 double cm_min,cm_max; 1344 double *cm_min=NULL; 1345 double *cm_max=NULL; 1345 1346 1346 1347 /*retrieve some parameters: */ 1347 this->parameters->FindParam(&cm_min, CmMinEnum);1348 this->parameters->FindParam(&cm_max, CmMaxEnum);1348 this->parameters->FindParam(&cm_min,NULL,CmMinEnum); 1349 this->parameters->FindParam(&cm_max,NULL,CmMaxEnum); 1349 1350 this->parameters->FindParam(&num_controls,NumControlsEnum); 1350 1351 this->parameters->FindParam(&control_type,NULL,ControlTypeEnum); … … 1364 1365 1365 1366 ((ControlInput*)input)->UpdateValue(scalar); 1366 input->Constrain(cm_min ,cm_max);1367 input->Constrain(cm_min[i],cm_max[i]); 1367 1368 if (save_parameter) ((ControlInput*)input)->SaveValue(); 1368 1369 -
issm/trunk/src/c/objects/IoModel.cpp
r6213 r6226 88 88 xfree((void**)&this->weights); 89 89 xfree((void**)&this->cm_jump); 90 xfree((void**)&this->cm_min); 91 xfree((void**)&this->cm_max); 90 92 xfree((void**)&this->optscal); 91 93 xfree((void**)&this->maxiter); … … 166 168 IoModelFetchData(&this->tolx,iomodel_handle,"tolx"); 167 169 IoModelFetchData(&this->cm_noisedmp,iomodel_handle,"cm_noisedmp"); 168 IoModelFetchData(&this->cm_min,iomodel_handle,"cm_min");169 IoModelFetchData(&this->cm_max,iomodel_handle,"cm_max");170 170 IoModelFetchData(&this->cm_gradient,iomodel_handle,"cm_gradient"); 171 171 IoModelFetchData(&this->eps_res,iomodel_handle,"eps_res"); … … 306 306 this->maxiter=NULL; 307 307 this->cm_noisedmp=0; 308 this->cm_min= 0;309 this->cm_max= 0;308 this->cm_min=NULL; 309 this->cm_max=NULL; 310 310 this->cm_gradient=0; 311 311 this->verbose=0; -
issm/trunk/src/c/objects/IoModel.h
r6213 r6226 114 114 double stokesreconditioning; 115 115 double cm_noisedmp; 116 double 117 double 116 double* cm_min; 117 double* cm_max; 118 118 int cm_gradient;; 119 119 -
issm/trunk/src/c/objects/Params/DoubleParam.cpp
r6213 r6226 167 167 } 168 168 /*}}}*/ 169 /*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/ 170 void DoubleParam::GetParameterValue(double** pdoublearray,int* pM){ 171 #ifdef _SERIAL_ 172 double* output=NULL; 173 174 output=(double*)xmalloc(1*sizeof(double)); 175 *output=(double)value; 176 177 /*Assign output podoubleers:*/ 178 if(pM) *pM=1; 179 *pdoublearray=output; 180 #else 181 ISSMERROR("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToString(enum_type)); 182 #endif 183 } 184 /*}}}*/ 185 /*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){{{1*/ 186 void DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){ 187 #ifdef _SERIAL_ 188 double* output=NULL; 189 190 output=(double*)xmalloc(1*sizeof(double)); 191 *output=(double)value; 192 193 /*Assign output podoubleers:*/ 194 if(pM) *pM=1; 195 if(pN) *pN=1; 196 *pdoublearray=output; 197 #else 198 ISSMERROR("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToString(enum_type)); 199 #endif 200 } 201 /*}}}*/ 169 202 /*FUNCTION DoubleParam::SetMatlabField{{{1*/ 170 203 #ifdef _SERIAL_ -
issm/trunk/src/c/objects/Params/DoubleParam.h
r6213 r6226 56 56 void GetParameterValue(char** pstring){ISSMERROR("Double param of enum %i (%s) cannot return a string",enum_type,EnumToString(enum_type));} 57 57 void GetParameterValue(char*** pstringarray,int* pM){ISSMERROR("Double param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToString(enum_type));} 58 void GetParameterValue(double** pdoublearray,int* pM) {ISSMERROR("Double param of enum %i (%s) cannot return a double array",enum_type,EnumToString(enum_type));}59 void GetParameterValue(double** pdoublearray,int* pM, int* pN) {ISSMERROR("Double param of enum %i (%s) cannot return a double array",enum_type,EnumToString(enum_type));}58 void GetParameterValue(double** pdoublearray,int* pM); 59 void GetParameterValue(double** pdoublearray,int* pM, int* pN); 60 60 void GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){ISSMERROR("Double param of enum %i (%s) cannot return a matrix array",enum_type,EnumToString(enum_type));} 61 61 void GetParameterValue(Vec* pvec){ISSMERROR("Double param of enum %i (%s) cannot return a Vec",enum_type,EnumToString(enum_type));} -
issm/trunk/src/c/solutions/control_core.cpp
r6213 r6226 30 30 int* control_type = NULL; 31 31 double* responses=NULL; 32 double* optscal=NULL;33 32 double* maxiter=NULL; 34 33 double* cm_jump=NULL; … … 52 51 femmodel->parameters->FindParam(&control_type,NULL,ControlTypeEnum); 53 52 femmodel->parameters->FindParam(&responses,NULL,CmResponsesEnum); 54 femmodel->parameters->FindParam(&optscal,NULL,OptScalEnum);55 53 femmodel->parameters->FindParam(&maxiter,NULL,MaxIterEnum); 56 54 femmodel->parameters->FindParam(&cm_jump,NULL,CmJumpEnum); … … 107 105 108 106 _printf_("%s\n"," updating parameter using optimized search scalar..."); //true means update save controls 109 InputControlUpdatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,search_scalar *optscal[n],true);107 InputControlUpdatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,search_scalar,true); 110 108 111 109 if(controlconvergence(J,responses,eps_cm,n)) break; … … 133 131 xfree((void**)&control_type); 134 132 xfree((void**)&responses); 135 xfree((void**)&optscal);136 133 xfree((void**)&maxiter); 137 134 xfree((void**)&cm_jump); -
issm/trunk/src/c/solutions/gradient_core.cpp
r6213 r6226 16 16 17 17 /*parameters: */ 18 bool control_steady; 19 int num_controls; 20 int* control_type=NULL; 21 int verbose; 18 bool control_steady; 19 int verbose; 20 int num_controls; 21 int *control_type = NULL; 22 double *optscal_list = NULL; 22 23 23 24 /*Intermediaries*/ … … 30 31 femmodel->parameters->FindParam(&num_controls,NumControlsEnum); 31 32 femmodel->parameters->FindParam(&control_type,NULL,ControlTypeEnum); 33 femmodel->parameters->FindParam(&optscal_list,NULL,NULL,OptScalEnum); 32 34 femmodel->parameters->FindParam(&verbose,VerboseEnum); 33 35 … … 51 53 VecFree(&gradient); 52 54 55 /*Scale gradient for current step and current parameter*/ 56 VecScale(new_gradient,optscal_list[num_controls*step+i]); 57 53 58 /*plug back into inputs: */ 54 59 ControlInputSetGradientx(femmodel-> elements,femmodel-> nodes, femmodel-> vertices,femmodel-> loads, femmodel-> materials, femmodel->parameters,control_type[i],new_gradient); -
issm/trunk/src/c/solutions/objectivefunctionC.cpp
r6213 r6226 30 30 FemModel *femmodel = NULL; 31 31 int n; 32 double *optscal = NULL;33 32 double *responses = NULL; 34 33 int solution_type; … … 43 42 n=optargs->n; 44 43 45 femmodel->parameters->FindParam(&optscal,NULL,OptScalEnum);46 44 femmodel->parameters->FindParam(&responses,NULL,CmResponsesEnum); 47 45 femmodel->parameters->FindParam(&isstokes,IsStokesEnum); … … 61 59 62 60 /*update parameter according to scalar: */ //false means: do not save control 63 InputControlUpdatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,search_scalar *optscal[n],false);61 InputControlUpdatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,search_scalar,false); 64 62 65 63 /*Run diagnostic with updated inputs: */ … … 82 80 /*Free ressources:*/ 83 81 xfree((void**)&responses); 84 xfree((void**)&optscal);85 82 return J; 86 83 } -
issm/trunk/src/m/model/ismodelselfconsistent.m
r6176 r6226 170 170 end 171 171 %}}} 172 %SCALAR {{{173 if ~isscalar(md.control_type),174 error('model not consistent: md.control_type should be a scalar');175 end176 %}}}177 172 %PARAMETEROUTPUT {{{1 178 173 if md.numoutput~=length(md.parameteroutput), … … 344 339 345 340 %CONTROL TYPE 346 if ~isnumeric(md.control_type), 347 error('model not consistent: control_type should be an enum'); 348 end 341 num_controls=numel(md.control_type); 349 342 checkvalues(md,{'control_type'},[DhDtEnum DragCoefficientEnum RheologyBbarEnum VxEnum VyEnum]); 350 343 351 344 %LENGTH CONTROL FIELDS 352 fields={'maxiter',' optscal','cm_responses','cm_jump'};345 fields={'maxiter','cm_responses','cm_jump'}; 353 346 checksize(md,fields,[md.nsteps 1]); 347 fields={'optscal'}; 348 checksize(md,fields,[md.nsteps num_controls]); 349 fields={'cm_min','cm_max'}; 350 checksize(md,fields,[num_controls 1]); 354 351 355 352 %RESPONSES -
issm/trunk/src/m/model/marshall.m
r6214 r6226 119 119 WriteData(fid,md.maxiter,'Mat','maxiter'); 120 120 WriteData(fid,md.cm_noisedmp,'Scalar','cm_noisedmp'); 121 WriteData(fid,md.cm_min,' Scalar','cm_min');122 WriteData(fid,md.cm_max,' Scalar','cm_max');121 WriteData(fid,md.cm_min,'Mat','cm_min'); 122 WriteData(fid,md.cm_max,'Mat','cm_max'); 123 123 WriteData(fid,md.cm_gradient,'Integer','cm_gradient'); 124 124 WriteData(fid,md.eps_res,'Scalar','eps_res'); -
issm/trunk/src/m/solutions/control_core.m
r6214 r6226 13 13 solution_type=femmodel.parameters.SolutionType; 14 14 responses=femmodel.parameters.CmResponses; 15 optscal=femmodel.parameters.OptScal;16 15 maxiter=femmodel.parameters.MaxIter; 17 16 cm_jump=femmodel.parameters.CmJump; … … 66 65 67 66 displaystring('\n%s',[' updating parameter using optimized search scalar:']); 68 [femmodel.elements,femmodel.nodes,femmmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters]=InputControlUpdate(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,search_scalar *optscal(n),1);67 [femmodel.elements,femmodel.nodes,femmmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters]=InputControlUpdate(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,search_scalar,1); 69 68 70 69 disp([' value of misfit J after optimization #' num2str(n) ':' num2str(J(n))]); -
issm/trunk/src/m/solutions/gradient_core.m
r6214 r6226 25 25 control_type=femmodel.parameters.ControlType; 26 26 control_steady=femmodel.parameters.ControlSteady; 27 optscal=femmodel.parameters.OptScal; 27 28 28 29 for i=1:num_controls, … … 45 46 end 46 47 48 %Scale Gradient 49 new_gradient=optscal(step,i)*new_gradient; 50 47 51 %plug back into inputs: 48 52 [femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters]=ControlInputSetGradient(femmodel.elements,femmodel.nodes, femmodel.vertices,femmodel.loads, femmodel.materials, femmodel.parameters,control_type(i),new_gradient); -
issm/trunk/src/m/solutions/objectivefunctionC.m
r6214 r6226 4 4 conserve_loads=true; 5 5 %recover some parameters 6 optscal=femmodel.parameters.OptScal(n);7 6 response=femmodel.parameters.CmResponses(n); 8 7 analysis_type=femmodel.parameters.AnalysisType; … … 20 19 21 20 %Use search scalar to shoot parameter in the gradient direction: 22 [femmodel.elements,femmodel.nodes,femmmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters]=InputControlUpdate(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,search_scalar *optscal,0);21 [femmodel.elements,femmodel.nodes,femmmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters]=InputControlUpdate(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,search_scalar,0); 23 22 24 23 %Run diagnostic with updated inputs:
Note:
See TracChangeset
for help on using the changeset viewer.