Skip to content

Instantly share code, notes, and snippets.

@aeantipov
Last active August 29, 2015 14:07
Show Gist options
  • Save aeantipov/b7f01f7964ce972798cb to your computer and use it in GitHub Desktop.
Save aeantipov/b7f01f7964ce972798cb to your computer and use it in GitHub Desktop.
reduce_test
#include <alps/mc/mcbase.hpp>
#include <alps/mc/mcmpiadapter.hpp>
#include <alps/mc/api.hpp>
#include <alps/accumulator.hpp>
#include <alps/params.hpp>
#include <alps/utility/stop_callback.hpp>
class sim1 : public alps::mcbase {
public:
sim1(parameters_type const & p, std::size_t seed_offset = 0):
alps::mcbase(p, seed_offset),
nsweeps(p["nsweeps"]),
count(0)
{
measurements <<
alps::accumulator::RealObservable("e1") <<
alps::accumulator::SignedRealObservable("e2"); /// <- Here is the bug
}
void update() { count++; }
void measure() { measurements["e1"] << 1.0; measurements["e2"] << 1.0; }
double fraction_completed() const { return double (count/nsweeps); }
private:
int nsweeps;
int count;
};
int main(int argc, char* argv[])
{
boost::mpi::environment env(argc, argv);
boost::mpi::communicator comm;
alps::params p;
p["nsweeps"] = 100;
alps::mcmpiadapter<sim1> sim (p,comm, alps::check_schedule(0.001, 60));
sim.run(alps::stop_callback(1));
alps::results_type<sim1>::type res = alps::collect_results(sim);
std::cout << res << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment