Changeset 05f437 for src/LevMartester.cpp
- Timestamp:
- Feb 27, 2013, 12:39:15 PM (12 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- d76ce74
- Parents:
- e36ba2
- git-author:
- Frederik Heber <heber@…> (11/30/12 16:46:30)
- git-committer:
- Frederik Heber <heber@…> (02/27/13 12:39:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/LevMartester.cpp
re36ba2 r05f437 221 221 222 222 // Afterwards we go through all of this type and gather the distance and the energy value 223 Fragment::charges_t h2o;224 h2o += 8,1,1;225 TrainingData AngleData(226 boost::bind(&Extractors::gatherDistancesFromFragment,227 boost::bind(&Fragment::getPositions, _1),228 boost::bind(&Fragment::getCharges, _1),229 boost::cref(h2o),230 _2)231 );232 AngleData(homologies.getHomologousGraphs(graph));233 LOG(1, "INFO: I gathered the following training data: " << AngleData);234 // NOTICE that distance are in bohrradi as they come from MPQC!235 236 // now perform the function approximation by optimizing the model function237 FunctionModel::parameters_t params(PairPotential_Angle::MAXPARAMS, 0.);238 params[PairPotential_Angle::energy_offset] =239 AngleData.getTrainingOutputAverage()[0];// -1.;240 params[PairPotential_Angle::spring_constant] = 2e+0*rand()/(double)RAND_MAX - 1.;// 1.;241 params[PairPotential_Angle::equilibrium_distance] = 1e+0*rand()/(double)RAND_MAX;// 0.2;242 223 PairPotential_Angle::ParticleTypes_t types = 243 224 boost::assign::list_of<PairPotential_Angle::ParticleType_t> … … 245 226 ; 246 227 PairPotential_Angle angle(types); 247 LOG(0, "INFO: Initial parameters are " << params << "."); 248 angle.setParameters(params); 228 Fragment::charges_t h2o; 229 h2o += 8,1,1; 230 TrainingData AngleData(angle.getFragmentSpecificExtractor(h2o)); 231 AngleData(homologies.getHomologousGraphs(graph)); 232 LOG(1, "INFO: I gathered the following training data: " << AngleData); 233 // NOTICE that distance are in bohrradi as they come from MPQC! 234 235 // now perform the function approximation by optimizing the model function 249 236 FunctionModel &model = angle; 250 237 FunctionApproximation approximator(AngleData, model); 251 238 if (model.isBoxConstraint() && approximator.checkParameterDerivatives()) { 252 239 // we set parameters here because we want to test with default ones 253 angle.setParameters(params); 240 srand((unsigned)time(0)); // seed with current time 241 model.setParametersToRandomInitialValues(AngleData); 242 LOG(0, "INFO: Initial parameters are " << angle.getParameters() << "."); 254 243 approximator(FunctionApproximation::ParameterDerivative); 255 244 } else { … … 275 264 Fragment::charges_t h2o; 276 265 h2o += 8,1; 277 TrainingData MorseData(278 boost::bind(&Extractors::gatherDistancesFromFragment,279 boost::bind(&Fragment::getPositions, _1),280 boost::bind(&Fragment::getCharges, _1),281 boost::cref(h2o),282 _2)283 );284 MorseData(homologies.getHomologousGraphs(graph));285 LOG(1, "INFO: I gathered the following training data: " << MorseData);286 // NOTICE that distance are in bohrradi as they come from MPQC!287 288 // now perform the function approximation by optimizing the model function289 266 PairPotential_Morse::ParticleTypes_t types = 290 267 boost::assign::list_of<PairPotential_Morse::ParticleType_t> … … 292 269 ; 293 270 PairPotential_Morse morse(types); 271 TrainingData MorseData(morse.getFragmentSpecificExtractor(h2o)); 272 MorseData(homologies.getHomologousGraphs(graph)); 273 LOG(1, "INFO: I gathered the following training data: " << MorseData); 274 // NOTICE that distance are in bohrradi as they come from MPQC! 275 276 // now perform the function approximation by optimizing the model function 294 277 FunctionModel &model = morse; 295 FunctionApproximation approximator(MorseData, model); 296 FunctionModel::triplefunction_t triplefunction = 297 boost::bind(&getTripleFromArgument, boost::cref(MorseData.getTrainingInputs()), _1, _2); 278 FunctionApproximation approximator(MorseData, model); // we only give CC distance, hence 1 input dim 298 279 if (model.isBoxConstraint() && approximator.checkParameterDerivatives()) { 299 280 // we set parameters here because we want to test with default ones 300 281 srand((unsigned)time(0)); // seed with current time 301 282 model.setParametersToRandomInitialValues(MorseData); 302 model.setTriplefunction(triplefunction); 303 LOG(0, "INFO: Initial parameters are " << model.getParameters() << "."); 283 LOG(0, "INFO: Initial parameters are " << morse.getParameters() << "."); 304 284 approximator(FunctionApproximation::ParameterDerivative); 305 285 } else { … … 325 305 Fragment::charges_t h2o; 326 306 h2o += 8,1,1; 327 TrainingData TersoffData(328 boost::bind(&Extractors::gatherDistancesFromFragment,329 boost::bind(&Fragment::getPositions, _1),330 boost::bind(&Fragment::getCharges, _1),331 boost::cref(h2o),332 _2)333 );334 // TrainingData::extractor_t(&Extractors::gatherAllSymmetricDistances) // gather first carbon pair335 // );336 TersoffData( homologies.getHomologousGraphs(graph) );337 LOG(1, "INFO: I gathered the following training data: " << TersoffData);338 // NOTICE that distance are in bohrradi as they come from MPQC!339 340 // now perform the function approximation by optimizing the model function341 boost::function< std::vector<FunctionModel::arguments_t>(const argument_t &, const double)> triplefunction =342 boost::bind(&getTripleFromArgument, boost::cref(TersoffData.getTrainingInputs()), _1, _2);343 307 SaturationPotential::ParticleTypes_t types = 344 308 boost::assign::list_of<SaturationPotential::ParticleType_t> 345 309 (8)(1) 346 310 ; 347 348 311 SaturationPotential saturation(types); 312 TrainingData TersoffData(saturation.getFragmentSpecificExtractor(h2o)); 313 boost::function< std::vector<FunctionModel::arguments_t>(const argument_t &, const double)> triplefunction = 314 boost::bind(&getTripleFromArgument, boost::cref(TersoffData.getTrainingInputs()), _1, _2); 315 saturation.setTriplefunction(triplefunction); 316 317 TersoffData( homologies.getHomologousGraphs(graph) ); 318 LOG(1, "INFO: I gathered the following training data: " << TersoffData); 319 // NOTICE that distance are in bohrradi as they come from MPQC! 320 321 // now perform the function approximation by optimizing the model function 349 322 FunctionModel &model = saturation; 350 323 FunctionApproximation approximator(TersoffData, model); // CH4 has 5 atoms, hence 5*4/2 distances … … 353 326 srand((unsigned)time(0)); // seed with current time 354 327 model.setParametersToRandomInitialValues(TersoffData); 355 model.setTriplefunction(triplefunction);356 328 approximator(FunctionApproximation::ParameterDerivative); 357 329 } else { … … 362 334 LOG(0, "RESULT: " << saturation << "."); 363 335 364 // std::cout << "\tsaturationparticle:";365 // std::cout << "\tparticle_type=C,";366 // std::cout << "\tA=" << params[SaturationPotential::A] << ",";367 // std::cout << "\tB=" << params[SaturationPotential::B] << ",";368 // std::cout << "\tlambda=" << params[SaturationPotential::lambda] << ",";369 // std::cout << "\tmu=" << params[SaturationPotential::mu] << ",";370 // std::cout << "\tbeta=" << params[SaturationPotential::beta] << ",";371 // std::cout << "\tn=" << params[SaturationPotential::n] << ",";372 // std::cout << "\tc=" << params[SaturationPotential::c] << ",";373 // std::cout << "\td=" << params[SaturationPotential::d] << ",";374 // std::cout << "\th=" << params[SaturationPotential::h] << ",";375 //// std::cout << "\toffset=" << params[SaturationPotential::offset] << ",";376 // std::cout << "\tR=" << saturation.R << ",";377 // std::cout << "\tS=" << saturation.S << ";";378 // std::cout << std::endl;379 380 336 // check L2 and Lmax error against training set 381 337 LOG(1, "INFO: L2sum = " << TersoffData.getL2Error(model)
Note:
See TracChangeset
for help on using the changeset viewer.