Changeset 11306
- Timestamp:
- 02/02/12 11:31:06 (13 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/solutions/control_core.cpp
r11302 r11306 34 34 35 35 /*intermediary: */ 36 double search_scalar= 0;36 double search_scalar=1; 37 37 OptArgs optargs; 38 38 OptPars optpars; … … 84 84 femmodel->parameters->SetParam(step_responses,1,num_responses,StepResponsesEnum); 85 85 86 /*In case we are running a steady state control method, compute new temperature field using new parameter distribution:*/86 /*In steady state inversion, compute new temperature field now*/ 87 87 if(solution_type==SteadystateSolutionEnum) solutioncore(femmodel); 88 88 89 89 _printf_(VerboseControl(),"%s\n"," compute adjoint state:"); 90 90 adjointcore(femmodel); 91 gradient_core(femmodel,n,search_scalar );91 gradient_core(femmodel,n,search_scalar==0); 92 92 93 93 /*Return gradient if asked: */ … … 100 100 optpars.maxiter=(int)maxiter[n]; optpars.cm_jump=cm_jump[n]; 101 101 BrentSearch(&search_scalar,J+n,&optpars,&objectivefunctionC,&optargs); 102 //OptimalSearch(&search_scalar,J+n,&optpars,&objectivefunctionC,&optargs);103 102 104 103 _printf_(VerboseControl(),"%s\n"," updating parameter using optimized search scalar"); //true means update save controls … … 116 115 for(i=0;i<num_controls;i++) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type[i]); 117 116 femmodel->results->AddObject(new DoubleVecExternalResult(femmodel->results->Size()+1,JEnum,J,nsteps,1,0)); 118 //femmodel->results->AddObject(new StringExternalResult(femmodel->results->Size()+1,InversionControlParametersEnum,EnumToStringx(control_type),1,0));119 117 } 120 118 -
issm/trunk-jpl/src/c/solutions/gradient_core.cpp
r11303 r11306 13 13 #include "../solvers/solvers.h" 14 14 15 16 void gradient_core(FemModel* femmodel,int step, double search_scalar){ //step defaults to 0, search_scalar defaults to 0 15 void gradient_core(FemModel* femmodel,int step,bool orthogonalize){ 17 16 18 17 /*parameters: */ … … 40 39 Gradjx(&gradient, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters, control_type[i]); 41 40 42 if ( step>0 && search_scalar==0){41 if (orthogonalize){ 43 42 _printf_(VerboseControl()," orthogonalization\n"); 44 43 ControlInputGetGradientx(&old_gradient,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,control_type[i]); … … 53 52 if(norm_grad<=0) _error_("||∂J/∂α||∞ = 0 gradient norm of J with respect to %s is zero",EnumToStringx(control_type[i])); 54 53 if(isnan(norm_grad))_error_("||∂J/∂α||∞ = NaN gradient norm of J with respect to %s is NaN" ,EnumToStringx(control_type[i])); 55 if(i==0 || (optscal_list[num_controls*step+i]/norm_grad)<optscal)optscal=optscal_list[num_controls*step+i]/norm_grad;54 optscal=optscal_list[num_controls*step+i]/norm_grad; 56 55 57 56 /*plug back into inputs: */ -
issm/trunk-jpl/src/c/solutions/solutions.h
r11286 r11306 15 15 void adjointdiagnostic_core(FemModel* femmodel); 16 16 void adjointbalancethickness_core(FemModel* femmodel); 17 void gradient_core(FemModel* femmodel,int step=0, double search_scalar=0);17 void gradient_core(FemModel* femmodel,int n=0,bool orthogonalize=false); 18 18 void diagnostic_core(FemModel* femmodel); 19 19 void hydrology_core(FemModel* femmodel); -
issm/trunk-jpl/src/m/solutions/control_core.m
r11302 r11306 25 25 %Initialize misfits with a vector of zeros 26 26 J=zeros(nsteps,1); 27 search_scalar= 0;27 search_scalar=1; 28 28 29 29 %Get core from solution type … … 42 42 femmodel.parameters.StepResponses=responses(n,:); 43 43 44 %In case we are running a steady state control method, compute new temperature field using new parameter distribution:44 %In steady state inversion, compute new temperature field now 45 45 if (solution_type==SteadystateSolutionEnum) 46 46 femmodel=steadystate_core(femmodel); … … 50 50 eval(['femmodel=' adjointcore '(femmodel);']); 51 51 52 femmodel=gradient_core(femmodel,n,search_scalar );52 femmodel=gradient_core(femmodel,n,search_scalar==0); 53 53 54 54 %Return gradient if asked -
issm/trunk-jpl/src/m/solutions/gradient_core.m
r11303 r11306 11 11 if nargin==3, 12 12 step=varargin{1}; 13 search_scalar=varargin{2};13 orthogonalize=varargin{2}; 14 14 elseif nargin==1 15 15 step=0; 16 search_scalar=0;;16 orthogonalize=false; 17 17 else 18 18 help gradient_core … … 31 31 grad=Gradj(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,control_type(i)); 32 32 33 if (step>1 && search_scalar==0),33 if orthogonalize, 34 34 issmprintf(VerboseControl,'%s',[' orthogonalization']); 35 35 old_gradient=ControlInputGetGradient(femmodel.elements,femmodel.nodes, femmodel.vertices,femmodel.loads, femmodel.materials,femmodel.parameters,control_type(i)); … … 43 43 if(norm_grad<=0), error(['||∂J/∂α||∞ = 0 gradient norm of J with respect to ' EnumToString(control_type(i)) ' is zero']); end 44 44 if(isnan(norm_grad)), error(['||∂J/∂α||∞ = NaN gradient norm of J with respect to ' EnumToString(control_type(i)) ' is NaN' ]); end 45 if(i==1 | (gradient_scaling_list(step,i)/norm_grad)<gradient_scaling) gradient_scaling=gradient_scaling_list(step,i)/norm_grad; end45 gradient_scaling=gradient_scaling_list(step,i)/norm_grad; 46 46 47 47 %plug back into inputs:
Note:
See TracChangeset
for help on using the changeset viewer.