- Timestamp:
- Feb 3, 2011, 9:51:19 AM (14 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:
- 1ee3b8d
- Parents:
- 081e5d
- git-author:
- Frederik Heber <heber@…> (01/06/11 12:28:31)
- git-committer:
- Frederik Heber <heber@…> (02/03/11 09:51:19)
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.cpp
r081e5d r6ff0c8 25 25 #include "World.hpp" 26 26 27 #include "RandomNumbers/RandomNumberGeneratorFactory.hpp" 27 #include "RandomNumbers/RandomNumberEngine.hpp" 28 #include "RandomNumbers/RandomNumberEngineFactory.hpp" 28 29 29 30 #include <iostream> … … 43 44 getParametersfromValueStorage(); 44 45 46 // create a new state for undo 45 47 CommandSetRandomNumbersEngineState *state = 46 48 new CommandSetRandomNumbersEngineState( 47 RandomNumberGeneratorFactory::getInstance().getEngineName(), 49 RandomNumberEngineFactory::getInstance().getCurrentTypeName(), 50 RandomNumberEngineFactory::getInstance().getPrototype().getseed(), 48 51 params); 49 RandomNumberGeneratorFactory::getInstance().setEngine(params.engine_type); 52 // set new default 53 RandomNumberEngineFactory::getInstance().setCurrentType(params.engine_type); 54 // set new seed if given, have to use ugly const_cast as prototype is not manipulable 55 if (params.seed != -1) { 56 RandomNumberEngine &engine = 57 const_cast<RandomNumberEngine &>( 58 RandomNumberEngineFactory::getInstance().getPrototype(params.engine_type) 59 ); 60 engine.seed(params.seed); 61 } 50 62 51 DoLog(0) && (Log() << Verbose(0) << " Engine of random number generatoris now: "52 << RandomNumber GeneratorFactory::getInstance().getEngineName() << std::endl);63 DoLog(0) && (Log() << Verbose(0) << "Default random number engine is now: " 64 << RandomNumberEngineFactory::getInstance().getCurrentTypeName() << std::endl); 53 65 54 66 return Action::state_ptr(state); … … 56 68 57 69 Action::state_ptr CommandSetRandomNumbersEngineAction::performUndo(Action::state_ptr _state) { 58 CommandSetRandomNumbersEngineState *state = assert_cast<CommandSetRandomNumbersEngineState*>(_state.get()); 70 CommandSetRandomNumbersEngineState *state = 71 assert_cast<CommandSetRandomNumbersEngineState*>(_state.get()); 59 72 73 // create a new state for redo 60 74 CommandSetRandomNumbersEngineState *newstate = 61 75 new CommandSetRandomNumbersEngineState( 62 RandomNumberGeneratorFactory::getInstance().getEngineName(), 76 RandomNumberEngineFactory::getInstance().getCurrentTypeName(), 77 RandomNumberEngineFactory::getInstance().getPrototype().getseed(), 63 78 state->params); 64 RandomNumberGeneratorFactory::getInstance().setEngine(state->old_engine_type); 79 // set new default 80 RandomNumberEngineFactory::getInstance().setCurrentType(state->old_engine_type); 81 RandomNumberEngine &engine = const_cast<RandomNumberEngine &>( 82 RandomNumberEngineFactory::getInstance().getPrototype(state->params.engine_type) 83 ); 84 // set new seed if given, have to use ugly const_cast as prototype is not manipulable 85 if (state->params.seed != -1) { 86 engine.seed(state->params.seed); 87 } 65 88 66 DoLog(0) && (Log() << Verbose(0) << " Engine of random number generatoris undone to: "67 << RandomNumber GeneratorFactory::getInstance().getEngineName() << std::endl);89 DoLog(0) && (Log() << Verbose(0) << "Default random number engine is undone to: " 90 << RandomNumberEngineFactory::getInstance().getCurrentTypeName() << std::endl); 68 91 69 92 return Action::state_ptr(newstate); -
src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.def
r081e5d r6ff0c8 12 12 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 13 13 // "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value 14 #define paramtypes (std::string) 15 #define paramtokens ("set-random-number-engine") 16 #define paramdescriptions ("name of the pseudo-random engine from boost::random") 17 # undef paramdefaults18 #define paramreferences (engine_type) 14 #define paramtypes (std::string)(int) 15 #define paramtokens ("set-random-number-engine")("random-number-seed") 16 #define paramdescriptions ("name of the pseudo-random engine from boost::random")("seed of the pseudo-random number sequence") 17 #define paramdefaults (NODEFAULT)("-1") 18 #define paramreferences (engine_type)(seed) 19 19 20 #define statetypes (std::string) 21 #define statereferences (old_engine_type) 20 #define statetypes (std::string)(int) 21 #define statereferences (old_engine_type)(old_seed) 22 22 23 23 // some defines for all the names, you may use ACTION, STATE and PARAMS -
src/RandomNumbers/RandomNumberEngine.hpp
r081e5d r6ff0c8 43 43 virtual void seed(unsigned int _seed)=0; 44 44 45 /** Getter for the generator's seed. 46 * 47 * @return _seed seed to set to 48 */ 49 virtual unsigned int getseed() const = 0; 50 45 51 /** Getter for smallest value the engine produces. 46 52 * … … 72 78 */ 73 79 RandomNumberEngine() {}; 74 75 /** Getter for the generator's seed.76 *77 * @note is only used internally for unit test.78 *79 * @return _seed seed to set to80 */81 virtual unsigned int getseed() const = 0;82 80 }; 83 81 -
src/RandomNumbers/RandomNumberEngineFactory.hpp
r081e5d r6ff0c8 27 27 class RandomNumberEngine; 28 28 class RandomNumberEngineFactoryUnitTest; 29 class CommandSetRandomNumbersEngineAction; 29 30 30 31 /** This is the Prototype factory class for random number engines. … … 43 44 friend class Singleton<RandomNumberEngineFactory>; 44 45 friend class RandomNumberEngineFactoryTest; 46 friend class CommandSetRandomNumbersEngineAction; 45 47 46 48 protected: -
src/RandomNumbers/RandomNumberEngineFactory.undef
r081e5d r6ff0c8 1 1 #ifdef RANDOMNUMBERENGINEFACTORY_DEF_ 2 2 3 #undef engine_seq 4 #undef engine_seq_a 3 5 #undef type_seq 4 6 #undef type_seq_size
Note:
See TracChangeset
for help on using the changeset viewer.