2222 */
2323
2424#pragma once
25+
2526#include < geode/stochastic/common.hpp>
26- // #include <geode/stochastic/sampling/mcmc/metropolis_hasting_sampler.hpp>
27- // #include <geode/stochastic/sampling/mcmc/models/energy_term_collection.hpp>
27+
2828#include < geode/stochastic/sampling/mcmc/helpers/simulation_monitor.hpp>
2929#include < geode/stochastic/spatial/object_sets.hpp>
3030
@@ -46,7 +46,7 @@ namespace geode
4646 std::string realisations_prefix{ " pattern_" };
4747 index_t realisations_print_frequency{ 100 };
4848
49- std::string output_folder{ " . " };
49+ std::string output_folder{ std::filesystem::current_path (). string () };
5050 };
5151
5252 class SimulationPrinter
@@ -59,7 +59,7 @@ namespace geode
5959
6060 // Print statistics to the configured statistics file
6161 void print_statistics (
62- const std::vector< double >& stats, absl::string_view header )
62+ const std::vector< double >& stats, absl::string_view header ) const
6363 {
6464 if ( !config_.print_statistics )
6565 return ;
@@ -72,9 +72,10 @@ namespace geode
7272
7373 template < typename ObjectType >
7474 void print_object_sets ( const ObjectSets< ObjectType >& object_sets,
75- index_t realization_id )
75+ index_t realization_id ) const
7676 {
77- if ( !config_.print_realisations )
77+ if ( !config_.print_realisations
78+ || realization_id % config_.realisations_print_frequency != 0 )
7879 return ;
7980
8081 const auto filename =
@@ -96,7 +97,7 @@ namespace geode
9697 }
9798 }
9899 void print_statistics_summary ( const StatisticsMonitor& monitor,
99- absl::string_view energy_term_names )
100+ absl::string_view energy_term_names ) const
100101 {
101102 if ( !config_.print_statistics_summary )
102103 return ;
@@ -109,16 +110,17 @@ namespace geode
109110 std::ofstream file = open_file_with_dirs ( summary_path );
110111 file << " # Summary statistics\n " ;
111112 file << energy_term_names.data () << " \n " ;
112- file << absl::StrCat ( " # Count:\n " , monitor.count , " \n " );
113113 file << absl::StrCat (
114- " # Means:\n " , absl::StrJoin ( monitor.means , " ; " ), " \n " );
114+ " # Count:\n " , monitor.statiscal_count (), " \n " );
115+ file << absl::StrCat (
116+ " # Means:\n " , absl::StrJoin ( monitor.means (), " ; " ), " \n " );
115117 file << absl::StrCat ( " # Variances:\n " ,
116- absl::StrJoin ( monitor.variances , " ; " ), " \n " );
118+ absl::StrJoin ( monitor.variances () , " ; " ), " \n " );
117119 }
118120
119121 private:
120122 void write_header_if_new (
121- absl::string_view filename, absl::string_view header )
123+ absl::string_view filename, absl::string_view header ) const
122124 {
123125 namespace fs = std::filesystem;
124126 fs::path file_path{ std::string ( filename ) };
@@ -148,7 +150,8 @@ namespace geode
148150
149151 return file;
150152 }
151- const std::string& create_statistics_file ( absl::string_view header )
153+ const std::string& create_statistics_file (
154+ absl::string_view header ) const
152155 {
153156 stats_file_path_ = ( std::filesystem::path ( config_.output_folder )
154157 / config_.statistics_filename )
@@ -165,7 +168,7 @@ namespace geode
165168
166169 private:
167170 SimulationPrinterConfigurator config_;
168- std::optional< std::string > stats_file_path_;
171+ mutable std::optional< std::string > stats_file_path_;
169172 };
170173
171174} // namespace geode
0 commit comments