Skip to content

Commit 78dce49

Browse files
add strauss mutitype
1 parent a91337a commit 78dce49

3 files changed

Lines changed: 65 additions & 68 deletions

File tree

include/geode/stochastic/sampling/mcmc/models/components/pairwise_term.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ namespace geode
155155
// continue;
156156
// }
157157
// if( neigh_obj_id.set_id == obj_id.set_id
158-
// && neigh_obj_id.id <= obj_id.id )
158+
// && neigh_obj_id.index <= obj_id.index )
159159
//{
160160
// continue;
161161
// }

tests/stochastic/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ add_geode_test(
135135
OpenGeode::basic
136136
OpenGeode::geometry
137137
${PROJECT_NAME}::stochastic
138-
UNSTABLE
139138
)
140139

141140

tests/stochastic/sampling/mcmc/test-mh-strauss.cpp

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -249,71 +249,69 @@ namespace
249249
geode::Logger::info( "--> SUCCESS!" );
250250
}
251251

252-
// void test_multitype_strauss()
253-
// {
254-
// geode::Logger::info(
255-
// "TEST - MH MULTITYPE STRAUSS (with inter-set interactions)" );
256-
//
257-
// geode::RandomEngine engine;
258-
// engine.set_seed( "@mh-test-multi-STRAUSS@" );
259-
//
260-
// geode::BoundingBox2D box;
261-
// box.add_point( geode::Point2D{ { 0.0, 0.0 } } );
262-
// box.add_point( geode::Point2D{ { 10.0, 10.0 } } );
263-
//
264-
// for( const auto config : geode::Range{ gamma_values.size() } )
265-
// {
266-
// // --- Sets
267-
// SetDescription set01{ "set01", 1.0, 3.0, 1.0 };
268-
// SetDescription set02{ "set02", 3.0, 0.5, 1.0 };
269-
// SetDescription set03{ "set03", 4.0, 1.0, 1.0 };
270-
//
271-
// // --- Density terms
272-
// PoissonDensityDescription d01{ "set01", 0.1, 10.0 };
273-
// PoissonDensityDescription d02{ "set02", 0.4, 40.0 };
274-
// PoissonDensityDescription d03{ "set03", 0.3, 30.0 };
275-
//
276-
// // --- Pairwise interactions
277-
// // 1. Intra-type (repulsion within same set)
278-
// PairwiseInteractionDescription intra01{ { "set01" }, 1.5, 1.2,
279-
// /*geode::PairwiseInteraction::SCOPE::INTRA,*/ 10.0 };
280-
// PairwiseInteractionDescription intra02{ { "set02" }, 1.2, 1.0,
281-
// /*geode::PairwiseInteraction::SCOPE::INTRA,*/ 20.0 };
282-
//
283-
// // 2. Inter-type (attraction or exclusion between sets)
284-
// PairwiseInteractionDescription inter12{ { "set01", "set02"
285-
// }, 2.5,
286-
// 1.5, /*geode::PairwiseInteraction::SCOPE::INTER,*/ 15.0 };
287-
// PairwiseInteractionDescription inter23{ { "set02", "set03"
288-
// }, 1.0,
289-
// 1.0, /*geode::PairwiseInteraction::SCOPE::INTER,*/ 25.0 };
290-
//
291-
// StraussSimulationRunner runner( box );
292-
// runner.add_set_descriptor( set01 );
293-
// runner.add_set_descriptor( set02 );
294-
// runner.add_set_descriptor( set03 );
295-
//
296-
// runner.add_density_descriptor( d01 );
297-
// runner.add_density_descriptor( d02 );
298-
// runner.add_density_descriptor( d03 );
299-
//
300-
// runner.add_interaction_descriptor( intra01 );
301-
// runner.add_interaction_descriptor( intra02 );
302-
// runner.add_interaction_descriptor( inter12 );
303-
// runner.add_interaction_descriptor( inter23 );
304-
//
305-
// runner.initialize();
306-
//
307-
// constexpr geode::index_t steps = 1000;
308-
// constexpr geode::index_t nb_realizations = 500;
309-
//
310-
// auto stats = runner.run_print_and_monitor(
311-
// "multi_strauss_stats", engine, steps, nb_realizations );
312-
// runner.check_statistics( stats );
313-
// }
314-
//
315-
// geode::Logger::info( "--> SUCCESS!" );
316-
// }
252+
void test_multitype_strauss()
253+
{
254+
geode::Logger::info(
255+
"TEST - MH MULTITYPE STRAUSS (with inter-set interactions)" );
256+
257+
geode::RandomEngine engine;
258+
engine.set_seed( "@mh-test-multi-STRAUSS@" );
259+
260+
geode::BoundingBox2D box;
261+
box.add_point( geode::Point2D{ { 0.0, 0.0 } } );
262+
box.add_point( geode::Point2D{ { 10.0, 10.0 } } );
263+
264+
std::array< double, 3 > gamma_values{ 0, 0.5, 1.0 };
265+
std::array< double, 3 > nb_points01{ 3.4, 5, 10.0 };
266+
std::array< double, 3 > nb_points02{ 14, 21, 40.0 };
267+
std::array< double, 3 > nb_points03{ 11, 16, 30. };
268+
std::array< double, 3 > nb_interactions01{ 0, 15, 95 };
269+
std::array< double, 3 > nb_interactions02{ 16, 41, 171 };
270+
271+
for( const auto config : geode::Range{ gamma_values.size() } )
272+
{
273+
// --- Sets
274+
SetDescription set01{ "set01", 1.0, 3.0, 1.0 };
275+
SetDescription set02{ "set02", 3.0, 0.5, 1.0 };
276+
SetDescription set03{ "set03", 4.0, 1.0, 1.0 };
277+
278+
// --- Density terms
279+
PoissonDensityDescription d01{ "set01", 0.1, nb_points01[config] };
280+
PoissonDensityDescription d02{ "set02", 0.4, nb_points02[config] };
281+
PoissonDensityDescription d03{ "set03", 0.3, nb_points03[config] };
282+
283+
// --- Pairwise interactions
284+
// 1. Intra-type (repulsion within same set)
285+
PairwiseInteractionDescription intra01{ { "set01", "set02",
286+
"set03" },
287+
gamma_values[config], 1., nb_interactions01[config] };
288+
PairwiseInteractionDescription intra02{ { "set02" }, 1., 2.,
289+
nb_interactions02[config] };
290+
291+
StraussSimulationRunner runner( box );
292+
runner.add_set_descriptor( set01 );
293+
runner.add_set_descriptor( set02 );
294+
runner.add_set_descriptor( set03 );
295+
296+
runner.add_density_descriptor( d01 );
297+
runner.add_density_descriptor( d02 );
298+
runner.add_density_descriptor( d03 );
299+
300+
runner.add_interaction_descriptor( intra01 );
301+
runner.add_interaction_descriptor( intra02 );
302+
303+
runner.initialize();
304+
305+
constexpr geode::index_t steps = 1000;
306+
constexpr geode::index_t nb_realizations = 500;
307+
308+
auto stats = runner.run_print_and_monitor(
309+
"multi_strauss_stats", engine, steps, nb_realizations );
310+
runner.check_statistics( stats );
311+
}
312+
313+
geode::Logger::info( "--> SUCCESS!" );
314+
}
317315
} // namespace
318316

319317
int main()
@@ -323,7 +321,7 @@ int main()
323321
geode::StochasticLibrary::initialize();
324322
geode::Logger::set_level( geode::Logger::LEVEL::debug );
325323
test_single_type_strauss();
326-
// test_multitype_strauss();
324+
test_multitype_strauss();
327325
return 0;
328326
}
329327
catch( ... )

0 commit comments

Comments
 (0)