@@ -37,7 +37,7 @@ namespace geode
3737 public:
3838 explicit PairwiseTerm ( std::string_view name,
3939 double gamma,
40- absl::flat_hash_set < uuid > targeted_set_ids,
40+ std::vector < uuid > targeted_set_ids,
4141 std::unique_ptr< PairwiseInteraction< ObjectType > > interaction )
4242 : EnergyTerm< ObjectType >(
4343 name, gamma, std::move( targeted_set_ids ) ),
@@ -59,8 +59,9 @@ namespace geode
5959 return 0.0 ;
6060 }
6161 double delta = 0.0 ;
62- const auto neighbors = state.neighbors ( new_object.object ,
63- interaction_->neighborhood_searching_distance () );
62+ const auto neighbors =
63+ state.neighbors ( new_object.object , this ->targeted_set_ids (),
64+ interaction_->neighborhood_searching_distance () );
6465 for ( const auto & neigh_id : neighbors )
6566 {
6667 geode::ObjectRef< ObjectType > neigh_object{
@@ -83,8 +84,9 @@ namespace geode
8384 ObjectRef< ObjectType > object_to_remove{
8485 state.get_object ( object_id ), object_id.set_id
8586 };
86- const auto neighbors = state.neighbors (
87- object_id, interaction_->neighborhood_searching_distance () );
87+ const auto neighbors =
88+ state.neighbors ( object_id, this ->targeted_set_ids (),
89+ interaction_->neighborhood_searching_distance () );
8890 for ( auto neigh_id : neighbors )
8991 {
9092 ObjectRef< ObjectType > neigh_object{
@@ -111,8 +113,9 @@ namespace geode
111113 ObjectRef< ObjectType > object_to_remove{
112114 state.get_object ( old_object_id ), old_object_id.set_id
113115 };
114- const auto old_neighbors = state.neighbors ( old_object_id,
115- interaction_->neighborhood_searching_distance () );
116+ const auto old_neighbors =
117+ state.neighbors ( old_object_id, this ->targeted_set_ids (),
118+ interaction_->neighborhood_searching_distance () );
116119 for ( auto neigh_id : old_neighbors )
117120 {
118121 ObjectRef< ObjectType > neigh_object{
@@ -123,8 +126,9 @@ namespace geode
123126 }
124127
125128 // Add new object's interactions
126- const auto new_neighbors = state.neighbors ( new_object.object ,
127- interaction_->neighborhood_searching_distance () );
129+ const auto new_neighbors =
130+ state.neighbors ( new_object.object , this ->targeted_set_ids (),
131+ interaction_->neighborhood_searching_distance () );
128132 for ( auto neigh_id : new_neighbors )
129133 {
130134 if ( old_object_id == neigh_id )
@@ -143,36 +147,33 @@ namespace geode
143147 double statistic ( const ObjectSets< ObjectType >& state ) const override
144148 {
145149 double sum = 0.0 ;
146- this ->for_each_targeted_object ( state, [&]( const ObjectId&
147- obj_id ) {
148- const auto & cur_obj = state.get_object ( obj_id );
149- const auto neighbors =
150- state.get_all_object (); // state.neighbors( obj_id, 1.1 );
151- for ( const auto & neigh_obj_id : neighbors )
152- {
153- // if( neigh_obj_id.set_id < obj_id.set_id )
154- // {
155- // continue;
156- // }
157- // if( neigh_obj_id.set_id == obj_id.set_id
158- // && neigh_obj_id.index <= obj_id.index )
159- // {
160- // continue;
161- // }
162-
163- if ( neigh_obj_id == obj_id )
164- {
165- continue ;
166- }
150+ this ->for_each_targeted_object (
151+ state, [&]( const ObjectId& obj_id ) {
152+ const auto & cur_obj = state.get_object ( obj_id );
167153 ObjectRef< ObjectType > object{ cur_obj, obj_id.set_id };
168- ObjectRef< ObjectType > neigh_object{
169- state.get_object ( neigh_obj_id ), neigh_obj_id.set_id
170- };
154+ const auto neighbors =
155+ state.neighbors ( obj_id, this ->targeted_set_ids (),
156+ interaction_->neighborhood_searching_distance () );
157+ for ( const auto & neigh_obj_id : neighbors )
158+ {
159+ if ( neigh_obj_id.set_id < obj_id.set_id )
160+ {
161+ continue ;
162+ }
163+ if ( neigh_obj_id.set_id == obj_id.set_id
164+ && neigh_obj_id.index <= obj_id.index )
165+ {
166+ continue ;
167+ }
168+ ObjectRef< ObjectType > neigh_object{
169+ state.get_object ( neigh_obj_id ),
170+ neigh_obj_id.set_id
171+ };
171172
172- sum += interaction_->evaluate ( object, neigh_object );
173- }
174- } );
175- return sum / 2 . ;
173+ sum += interaction_->evaluate ( object, neigh_object );
174+ }
175+ } );
176+ return sum;
176177 }
177178
178179 private:
0 commit comments