namespace alps { namespace scheduler { template <class WORKER> class SimpleMCFactory : public SimpleFactory<WORKER,MCSimulation> { public: SimpleMCFactory() {} }; class Worker { public: virtual void dostep()=0; virtual double work_done() const =0; virtual void start(); virtual void halt(); virtual bool change_parameter(const std::string& name, const alps::StringValue& value); protected: typedef boost::lagged_fibonacci607 random_type; random_type random; double random_real(double a=0., double b=1.,); int random_int(int a, int b); int random_int(int n); alps::Parameters parms; osiris::ProcessList where; }; class MCRun : public Worker { public: MCRun(const osiris::ProcessList& w, const alps::Parameters& p,int node); virtual void save(osiris::ODump& dump) const; virtual void load(osiris::IDump& dump) const; virtual void write_xml(const std::string& name, const std::string& dumpname="") const; alea::ObservableSet get_measurements() const; virtual bool is_thermalized() const=0; protected: alea::ObservableSet measurements; }; template <class G=lattice::graph_factory<>::graph_type> class LatticeMCRun : public MCRun, public graph_helper{ public: LatticeMCRun(const osiris::ProcessList& w,const alps::Parameters& p,int n); }; template <class G=graph_factory<>::graph_type, class I=short> class LatticeModelMCRun : public LatticeMCRun<G>, public model_helper<I> { public: LatticeModelMCRun(const ProcessList& w,const alps::Parameters& p,int n); bool has_sign_problem() const; }; }
is the constructor of a new Monte Carlo run.MCRun(const osiris::ProcessList& w, const alps::Parameters& p,int node;
The argument w gives the processor nodes on which the MCRun is created, and the argument node the index into this list in case of future multi-CPU simulations. The simulation parameters are given in
. These three arguments are passed to the factory and will just be passed on to the constructor here.
does one simulation step. This needs to be implemented by the user of the library.virtual void dostep()=0;
returns the fraction of work that is already done for the simulation. A value of one means that the simulation is finished. This also needs to be implemented by the user of the library.virtual double work_done() const =0;
is called at the start of the simulation and can be overriden to do some initial work.virtual void start();
is called at the end of the simulation and can be overriden to do some final work.virtual void halt();
is called when the user changes the parameter given by name to a new value. If the change is allowed or irrelevant the function should do the appropriate changes and return true, while false should be returned if the parameter change is not valid.virtual bool change_parameter(const std::string& name, const alps::StringValue& value);
should be overriden to save the user data into a checkpoint. In contrast to previous library versions the base class function MCRun::save should no longer be called from the derived user class.virtual void save(osiris::ODump& dump) const;
should be overrideen to read a Monte Carlo run from a checkpoint, if checkpointing support is desired.virtual void load(osiris::IDump& dump);
needs to be overridden to give a criterion for equilibration of the Monte Carlo simulation and to determine when real measurements should start.virtual bool is_thermalized() const=0;
returns the collected measurements.alea::ObservableSet get_measurements() const;
is the type of random number generator used.typedef boost::lagged_fibonacci607 random_type;
provides floating point random numbers in the range a to b, inclusive the limiting value a but excluding b.double random_real(double a=0., double b=1.);
provides integer random numbers in the range a to b, inclusive the limiting values a and b.int random_int(int a, int b);
provides integer random numbers in the range 0 to n-1, inclusive the limiting values 0 and n-1.int random_int(int n);
is the random number generatorrandom_type random;
the collected measurements into which measurements should be stored.alea::ObservableSet measurements;
The simulation parameters.alps::Parameters parms;
the processes of which the simulation is running. This is empty if the simulation has been loaded for evaluation purposes and no actual simulations will be performed.osiris::ProcessList where;
The constructor creates the graph from the following input parameters:LatticeMCRun(const osiris::ProcessList& w,const alps::Parameters& p,int n);
Parameter | Description |
LATTICE_LIBRARY | The path to an XML file containg lattice descriptions. It will be used to initialize a lattice library. The default is a file called "lattices.xml" in the current working directory. |
LATTICE | The name of the lattice or graph in the lattice library that will be constructed. |
GRAPH | A synonym for LATTICE. |
The constructor additionally creates the model from the following input parameters:LatticeModelMCRun(const osiris::ProcessList& w,const alps::Parameters& p,int n);
Parameter | Description |
MODEL_LIBRARY | The path to an XML file containg lattice descriptions. It will be used to initialize a model. The default is a file called "models.xml" in the current working directory. |
MODEL | The name of a model. |
returns true if the model might suffer from a sign problem.bool has_sign_problem() const;
copyright (c) 1994-2010 by Matthias Troyer
Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)