Changeset 11357


Ignore:
Timestamp:
02/08/12 07:30:01 (13 years ago)
Author:
Mathieu Morlighem
Message:

improved tao: added options from matlab model and returns all model output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/solutions/controltao_core.cpp

    r11322 r11357  
    2626        /*TAO*/
    2727        int        ierr;
    28         int        num_controls;
     28        int        num_controls,solution_type;
     29        int        nsteps,maxiter;
    2930        AppCtx     user;
    3031        TaoSolver  tao;
     32        int       *dummy          = NULL;
    3133        int       *control_list   = NULL;
    3234        Vec        X              = NULL;
     
    4143
    4244        /*Recover some parameters*/
     45        femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
    4346        femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
    4447        femmodel->parameters->FindParam(&control_list,NULL,InversionControlParametersEnum);
     48        femmodel->parameters->FindParam(&nsteps,InversionNstepsEnum);
     49        femmodel->parameters->FindParam(&dummy,NULL,NULL,InversionMaxiterPerStepEnum);
     50        maxiter=nsteps*dummy[0]; xfree((void**)&dummy);
    4551
    4652        /*Initialize TAO*/
     
    5460
    5561        /*Prepare all TAO parameters*/
    56         TaoSetMaximumFunctionEvaluations(tao,50);
    57         TaoSetMaximumIterations(tao,10);
     62        TaoSetMaximumFunctionEvaluations(tao,maxiter);
     63        TaoSetMaximumIterations(tao,nsteps);
    5864        TaoSetTolerances(tao,0.,0.,0.,0.,0.);
    5965
     
    7884                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_list[i]);
    7985        }
     86
     87        /*Finalize*/
     88        _printf_(VerboseControl(),"%s\n","   preparing final solution");
     89        femmodel->parameters->SetParam(false,InversionIscontrolEnum); //needed to turn control result output in solutioncore
     90        void (*solutioncore)(FemModel*)=NULL;
     91        CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
     92        solutioncore(femmodel);
    8093
    8194        /*Clean up and return*/
     
    119132        /*Compute objective function*/
    120133        CostFunctionx(fcn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
    121         _printf_(true,"f(x)=%g\n",*fcn);
    122134
    123135        /*Compute gradient*/
     
    125137        VecCopy(gradient,G); VecFree(&gradient);
    126138        VecScale(G,-1.);
    127         //VecView(G,PETSC_VIEWER_STDOUT_WORLD);
    128139
    129140        /*Clean-up and return*/
Note: See TracChangeset for help on using the changeset viewer.