Changeset e1fe7e for src/Potentials/CompoundPotential.cpp
- Timestamp:
- Jun 27, 2014, 9:32:55 PM (11 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:
- 550f2a
- Parents:
- 16227a
- git-author:
- Frederik Heber <heber@…> (02/27/14 20:15:41)
- git-committer:
- Frederik Heber <heber@…> (06/27/14 21:32:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Potentials/CompoundPotential.cpp
r16227a re1fe7e 228 228 { 229 229 arguments_by_model_t partial_args; 230 // go through each model and have it filter out its arguments 230 // go through each model and have it filter out its arguments, this already 231 // returns a list of tuples associated with the specific model 231 232 for(models_t::const_iterator modeliter = models.begin(); 232 233 modeliter != models.end(); ++modeliter) { 233 234 FunctionModel::filter_t filterfunction = (*modeliter)->getSpecificFilter(); 234 arguments_t tempargs = filterfunction(arguments);235 list_of_arguments_t tempargs = filterfunction(arguments); 235 236 // then split up all the bunches, too. 236 arguments_t::const_iterator advanceiter = tempargs.begin(); 237 for (arguments_t::const_iterator argiter = tempargs.begin(); 238 argiter != tempargs.end(); argiter = advanceiter) { 239 advanceiter += (*modeliter)->getSpecificArgumentCount(); 237 for (list_of_arguments_t::const_iterator argiter = tempargs.begin(); 238 argiter != tempargs.end(); ++argiter) { 239 const arguments_t &args = *argiter; 240 240 partial_args.push_back( 241 241 std::make_pair( 242 242 *modeliter, 243 arg uments_t(argiter, advanceiter)243 args 244 244 ) 245 245 ); … … 251 251 252 252 CompoundPotential::arguments_by_model_t CompoundPotential::splitUpArgumentsByModels( 253 const arguments_t &arguments) const253 const list_of_arguments_t &listarguments) const 254 254 { 255 255 arguments_by_model_t partial_args; 256 arguments_t::const_iterator argiter = arguments.begin();257 256 particletypes_per_model_t::const_iterator typesiter = particletypes_per_model.begin(); 258 257 models_t::const_iterator modeliter = models.begin(); 259 258 260 // add constant model (which is always first model) with empty args if present259 /// add constant model (which is always first model) with empty args if present 261 260 if (typesiter->empty()) { 262 261 partial_args.push_back( … … 266 265 ++typesiter; 267 266 } 267 268 268 // then check other models 269 while (argiter != arguments.end()) { 269 /// we only have to check whether the current model still matches or whether 270 /// have to use the next model. 271 for (list_of_arguments_t::const_iterator argiter = listarguments.begin(); 272 argiter != listarguments.end(); ++argiter) { 273 const arguments_t &arguments = *argiter; 270 274 if (typesiter+1 != particletypes_per_model.end()) { 271 275 // check whether next argument bunch is for same model or different one … … 275 279 276 280 // we always expect N(N-1)/2 distances for N particle types 277 arguments_t::const_iterator enditer = argiter+(types.size()*(types.size()-1)/2); 278 arguments_t::const_iterator nextenditer = argiter+(nexttypes.size()*(nexttypes.size()-1)/2); 279 arguments_t args(argiter, enditer); 280 arguments_t nextargs(argiter, nextenditer); 281 if (types.size() < nexttypes.size()) { 282 if (areValidArguments(nexttypes, nextargs)) { 281 // check first from sizes alone 282 const size_t tuplesize = types.size()*(types.size()-1)/2; 283 const size_t nexttuplesize = nexttypes.size()*(nexttypes.size()-1)/2; 284 if ((tuplesize != nexttuplesize)) { 285 if ((arguments.size() == tuplesize) && areValidArguments(types, arguments)) { 286 // only former still matches, don't increment 287 partial_args.push_back( 288 std::make_pair(*modeliter, arguments) 289 ); 290 } else if ((arguments.size() == nexttuplesize) && areValidArguments(nexttypes, arguments)) { 283 291 // latter matches, increment 284 292 ++typesiter; 285 293 partial_args.push_back( 286 std::make_pair(*(++modeliter), arguments _t(argiter, nextenditer))294 std::make_pair(*(++modeliter), arguments) 287 295 ); 288 argiter = nextenditer; 289 } else if (areValidArguments(types, args)) { 290 // only former matches, don't increment 291 partial_args.push_back( 292 std::make_pair(*modeliter, arguments_t(argiter, enditer)) 293 ); 294 argiter = enditer; 295 } else 296 } else { 296 297 ASSERT(0, 297 "CompoundPotential::splitUpArgumentsByModels() - neither type matches its argument bunch."); 298 } else { 299 if (areValidArguments(types, args)) { 300 // only former matches, don't increment 301 partial_args.push_back( 302 std::make_pair(*modeliter, arguments_t(argiter, enditer)) 303 ); 304 argiter = enditer; 305 } else if (areValidArguments(nexttypes, nextargs)) { 306 // latter matches, increment 307 ++typesiter; 308 partial_args.push_back( 309 std::make_pair(*(++modeliter), arguments_t(argiter, nextenditer)) 310 ); 311 argiter = nextenditer; 298 "CompoundPotential::splitUpArgumentsByModels() - neither this model nor next model match (size) with current tuple."); 299 } 300 } else { // same size, now we have to check the types individually 301 size_t encodeValidity = 0; 302 encodeValidity += 1*areValidArguments(types, arguments); 303 encodeValidity += 2*areValidArguments(nexttypes, arguments); 304 305 switch (encodeValidity) { 306 case 1: 307 // only former still matches, don't increment 308 partial_args.push_back( 309 std::make_pair(*modeliter, arguments) 310 ); 311 break; 312 case 2: 313 ++typesiter; 314 partial_args.push_back( 315 std::make_pair(*(++modeliter), arguments) 316 ); 317 break; 318 case 0: 319 case 3: 320 default: 321 ASSERT(0, 322 "CompoundPotential::splitUpArgumentsByModels() - neither this model nor next model match (type) with current tuple."); 323 break; 312 324 } 313 325 } 314 326 } else { 315 327 const SerializablePotential::ParticleTypes_t &types = *typesiter; 316 // we always expect N(N-1)/2 distances for N particle types 317 arguments_t::const_iterator enditer = argiter+(types.size()*(types.size()-1)/2); 318 partial_args.push_back( 319 std::make_pair(*modeliter, arguments_t(argiter, enditer)) 320 ); 321 argiter = enditer; 328 if (areValidArguments(types, arguments)) { 329 // only former matches, don't increment 330 partial_args.push_back( 331 std::make_pair(*modeliter, arguments) 332 ); 333 } else { 334 ASSERT(0, 335 "CompoundPotential::splitUpArgumentsByModels() - last model does not match with current tuple."); 336 } 322 337 } 323 338 } … … 326 341 } 327 342 328 CompoundPotential::results_t CompoundPotential::operator()(const arguments_t &arguments) const 343 CompoundPotential::results_t CompoundPotential::operator()( 344 const list_of_arguments_t &listarguments) const 329 345 { 330 346 /// first, we have to split up the given arguments 331 347 arguments_by_model_t partial_args = 332 splitUpArgumentsByModels( arguments);348 splitUpArgumentsByModels(listarguments); 333 349 // print split up argument list for debugging 334 350 if (DoLog(4)) { … … 348 364 iter != partial_args.end(); ++iter) { 349 365 partial_results.push_back( 350 (*iter->first)(iter->second) 366 (*iter->first)( 367 FunctionModel::list_of_arguments_t(1, iter->second)) 351 368 ); 352 369 } … … 366 383 } 367 384 368 CompoundPotential::results_t CompoundPotential::parameter_derivative(const arguments_t &arguments, const size_t index) const 385 CompoundPotential::results_t CompoundPotential::parameter_derivative( 386 const list_of_arguments_t &listarguments, 387 const size_t index) const 369 388 { 370 389 // first, we have to split up the given arguments 371 390 arguments_by_model_t partial_args = 372 splitUpArgumentsByModels( arguments);391 splitUpArgumentsByModels(listarguments); 373 392 // then, with each bunch of arguments, we call the specific model 374 393 // get parameter dimensions per model … … 399 418 const size_t indexbase = (iter == dimensions.begin()) ? 0 : *(iter-1); 400 419 CompoundPotential::results_t results = 401 model->parameter_derivative(argiter->second, index-indexbase); 420 model->parameter_derivative( 421 FunctionModel::list_of_arguments_t(1, argiter->second), index-indexbase); 402 422 403 423 // either set results or add … … 462 482 // create initial returnfunction 463 483 FunctionModel::filter_t returnfunction = 464 boost::bind(&Helpers::returnEmpty Arguments);484 boost::bind(&Helpers::returnEmptyListArguments); 465 485 466 486 // every following fragments combines its arguments with the initial function … … 468 488 modeliter != models.end(); ++modeliter) { 469 489 returnfunction = 470 boost::bind(&Extractors::concatenate Arguments,490 boost::bind(&Extractors::concatenateListOfArguments, 471 491 boost::bind(returnfunction, _1), 472 492 boost::bind((*modeliter)->getSpecificFilter(), _1)
Note:
See TracChangeset
for help on using the changeset viewer.