if (A_(cnst_idx, player_idx) <= 0.0)
continue;
- double rate = fair_sharing[cnst_idx] / A_(cnst_idx, player_idx);
+ double rate = fair_sharing[cnst_idx] / maxA_(cnst_idx, player_idx);
if (min_rate == -1 || rate < min_rate) {
selected_resource = cnst_idx;
min_rate = rate;
if (rho[player] < 0) { // negative rho doesn't make sense, consider the resource is saturated in this case
fair_sharing[r] = get_maxmin_share(r);
} else {
- fair_sharing[r] = A_(r, player) * rho[player];
+ fair_sharing[r] = maxA_(r, player) * rho[player];
}
} else { // nobody selects this resource, fair_sharing depends on resource saturation
// resource r is saturated (A[r,*] * rho > C), divide it among players
REQUIRE(double_equals(rho_2->get_value(), 3, sg_maxmin_precision));
}
+ SECTION("Variable penalty with bounds: thread bug")
+ {
+ /*
+ * Detected by exec-thread.
+ * Fair-sharing vector depends on the penalty too.
+ */
+
+ /* don't change the order of creation, important to trigger the bug */
+ lmm::Constraint* sys_cnst = Sys.constraint_new(nullptr, 4e8);
+ lmm::Variable* rho_2 = Sys.variable_new(nullptr, .25, 4e8, 1);
+ lmm::Variable* rho_1 = Sys.variable_new(nullptr, 1, 1e8, 1);
+ Sys.expand(sys_cnst, rho_2, 1);
+ Sys.expand(sys_cnst, rho_1, 1);
+ Sys.solve();
+
+ REQUIRE(double_equals(rho_1->get_value(), 8e7, sg_maxmin_precision));
+ REQUIRE(double_equals(rho_2->get_value(), 3.2e8, sg_maxmin_precision));
+ }
+
Sys.variable_free_all();
}