Skip to content

Commit ab482cc

Browse files
Merge pull request #21 from ubc-systopia/fix-nonconvergence
Fix issues with scope updates
2 parents 46cb1ab + c3acbce commit ab482cc

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/libgosdt/src/dispatch/dispatch.cpp

+19-11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ bool Optimizer::dispatch(Message const &message, unsigned int id) {
1818

1919
vertex_accessor vertex;
2020
bool inserted = store_self(task.capture_set(), task, vertex);
21+
// if this subproblem already existed, we still have to update the scope
22+
if (!inserted) {
23+
vertex -> second.scope(message.scope);
24+
}
2125

2226
store_children(vertex->second, id);
2327

@@ -166,10 +170,11 @@ bool Optimizer::load_children(Task &task, Bitmask const &signals, unsigned int i
166170
lower = std::min(lower, std::get<1>(*iterator));
167171
upper = std::min(upper, std::get<2>(*iterator));
168172
}
169-
if (lower > task.upperscope()) { return false; } // if lower is > upperscope, then lower may not be a true lower bound b/c of line 160.
170-
// (In this case, base objective and all splits are all above upper scope, and
171-
// no splits were used to update the bounds, though the splits may still have been
172-
// better than the base risk).
173+
if (lower > task.upperscope()) {
174+
return task.update(m_config, task.upperscope(), upper, optimal_feature);
175+
} // ^ if lower is > upperscope, then lower may not be a true lower bound b/c of line 160.
176+
// (In this case, base objective and all splits are all above upper scope,
177+
// but we do not know the exact lower bound)
173178
return task.update(m_config, lower, upper, optimal_feature);
174179
}
175180

@@ -188,9 +193,6 @@ bool Optimizer::store_self(Bitmask const &identifier, Task const &value, vertex_
188193
void Optimizer::store_children(Task &task, unsigned int id) {
189194
bound_accessor bounds;
190195
bool inserted = m_graph.bounds.insert(bounds, task.capture_set());
191-
if (!inserted) {
192-
return;
193-
}
194196
int optimal_feature = -1;
195197
float lower = task.base_objective(), upper = task.base_objective();
196198
Bitmask const &features = task.feature_set();
@@ -221,7 +223,10 @@ void Optimizer::store_children(Task &task, unsigned int id) {
221223
split_lower = left.lowerbound() + right.lowerbound();
222224
split_upper = left.upperbound() + right.upperbound();
223225
}
224-
bounds->second.push_back(std::tuple<int, float, float>(j, split_lower, split_upper));
226+
if (inserted) {
227+
// If we're visiting children for the first time in our graph, store bounds
228+
bounds->second.push_back(std::tuple<int, float, float>(j, split_lower, split_upper));
229+
}
225230
if (split_lower > task.upperscope()) {
226231
continue;
227232
}
@@ -232,8 +237,11 @@ void Optimizer::store_children(Task &task, unsigned int id) {
232237
upper = std::min(upper, split_upper);
233238
}
234239
}
235-
if (lower > task.upperscope()) { return; } // similar reason to check on line 169. If all children out of scope,
236-
// and base risk out of scope, don't update bound.
240+
if (lower > task.upperscope()) {
241+
task.update(m_config, task.upperscope(), upper, optimal_feature);
242+
return;
243+
} // ^ similar reason to check in load_children. Don't know exact lb,
244+
// just that it exceeds the upperscope()
237245
task.update(m_config, lower, upper, optimal_feature);
238246
}
239247

@@ -267,7 +275,7 @@ void Optimizer::signal_exploiters(adjacency_accessor &parents, Task &self, unsig
267275
self.uncertainty() > 0) {
268276
continue;
269277
}
270-
m_local_states[id].outbound_message.exploitation(self.capture_set(), // sender tile
278+
m_local_states[id].outbound_message.exploitation(self.capture_set(), // sender tile
271279
iterator->first, // recipient tile
272280
iterator->second.first, // recipient features
273281
self.support() - self.lowerbound()); // priority

0 commit comments

Comments
 (0)