Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
BMF: fix cloud-capping tests.
authorBruno Donassolo <bruno.donassolo@inria.fr>
Wed, 16 Mar 2022 17:21:24 +0000 (18:21 +0100)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Fri, 18 Mar 2022 08:24:44 +0000 (09:24 +0100)
src/kernel/lmm/bmf.cpp
src/kernel/lmm/bmf_test.cpp

index 0abe968..4d6b88a 100644 (file)
@@ -276,18 +276,12 @@ bool BmfSolver::get_alloc(const Eigen::VectorXd& fair_sharing, const allocation_
 void BmfSolver::set_fair_sharing(const allocation_map_t& alloc, const Eigen::VectorXd& rho,
                                  Eigen::VectorXd& fair_sharing) const
 {
-  std::vector<int> bounded_players = get_bounded_players(alloc);
-
   for (int r = 0; r < fair_sharing.size(); r++) {
     auto it = alloc.find(r);
     if (it != alloc.end()) {              // resource selected by some player, fair share depends on rho
       int player = *(it->second.begin()); // equilibrium assures that every player receives the same, use one of them to
                                           // calculate the fair sharing for resource r
-      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] = maxA_(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
       double consumption_r = A_.row(r) * rho;
@@ -295,7 +289,7 @@ void BmfSolver::set_fair_sharing(const allocation_map_t& alloc, const Eigen::Vec
       if (consumption_r > 0.0) {
         fair_sharing[r] = get_maxmin_share(r);
       } else {
-        fair_sharing[r] = get_resource_capacity(r, bounded_players);
+        fair_sharing[r] = C_[r];
       }
     }
   }
@@ -355,6 +349,7 @@ Eigen::VectorXd BmfSolver::solve()
   XBT_DEBUG("A:\n%s", debug_eigen(A_).c_str());
   XBT_DEBUG("maxA:\n%s", debug_eigen(maxA_).c_str());
   XBT_DEBUG("C:\n%s", debug_eigen(C_).c_str());
+  XBT_DEBUG("phi:\n%s", debug_eigen(phi_).c_str());
 
   /* no flows to share, just returns */
   if (A_.cols() == 0)
index 5d04c03..3238c0e 100644 (file)
@@ -587,6 +587,55 @@ TEST_CASE("kernel::bmf Bugs", "[kernel-bmf-bug]")
     Sys.expand_add(sys_cnst, rho_3, 1.91268e+11);
     Sys.solve();
   }
+  SECTION("DadOu's bug: complete matrix")
+  {
+    constexpr int cnsts = 71;
+    constexpr int flows = 3;
+
+    Eigen::MatrixXd A(cnsts, flows);
+    A << 0, 0, 0, 0, 0, 0, 0, 0, 1.84467e+19, 1.91268e+11, 1.84467e+19, 1.84467e+19, 0, 0, 1.84467e+19, 0, 1.84467e+19,
+        0, 0, 1.84467e+19, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0,
+        4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11,
+        0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 1.256e+09, 0, 0, 2.2372e+10, 0, 0,
+        2.2684e+10, 0, 0, 2.2588e+10, 0, 0, 2.3188e+10, 0, 0, 2.228e+10, 0, 0, 2.058e+10, 0, 0, 2.2684e+10, 0, 0,
+        2.2824e+10, 0, 0, 2.2976e+10, 0, 0, 2.2632e+10, 0, 0, 2.2584e+10, 0, 0, 2.2736e+10, 0, 0, 2.2616e+10, 0, 0,
+        2.0828e+10, 0, 0, 2.3184e+10, 0, 0, 2.2524e+10, 0, 0, 2.278e+10, 0, 0, 2.2164e+10, 0, 0, 1.26e+09, 0, 0,
+        2.1872e+10, 0, 0, 1.4e+09, 0, 0, 2.3184e+10, 0, 0, 8.52e+08, 0, 0, 2.2268e+10, 0, 0, 1.756e+09, 0, 0,
+        2.0636e+10, 0, 0, 3.4e+09, 0, 0, 2.2576e+10, 0, 0, 1.352e+09, 0, 0, 2.2832e+10, 0, 0, 1.2e+09, 0, 0, 2.3092e+10,
+        0, 0, 9.48e+08, 0, 0, 2.2436e+10, 0, 0, 1.4e+09, 0, 0, 2.2572e+10, 0, 0, 1.452e+09, 0, 0, 2.2692e+10, 0, 0,
+        1.3e+09, 0, 0, 2.2832e+10, 0, 0, 1.2e+09, 0, 0, 2.1232e+10, 0, 0, 2.804e+09, 0, 0, 2.3184e+10, 0, 0,
+        8.56001e+08, 0, 0, 2.2512e+10, 0, 0, 1.5e+09, 0, 0;
+
+    Eigen::MatrixXd maxA(cnsts, flows);
+    maxA << 0, 0, 0, 0, 0, 0, 0, 0, 1.84467e+19, 3.1e+09, 1.84467e+19, 1.84467e+19, 0, 0, 1.84467e+19, 0, 1.84467e+19,
+        0, 0, 1.84467e+19, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 1, 4.975e+11, 0, 0,
+        4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11,
+        0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 4.975e+11, 0, 0, 1.256e+09, 0, 0, 3.504e+09, 0, 0,
+        3.056e+09, 0, 0, 3.1e+09, 0, 0, 2.952e+09, 0, 0, 2.404e+09, 0, 0, 2.304e+09, 0, 0, 2.556e+09, 0, 0, 2.4e+09, 0,
+        0, 2.804e+09, 0, 0, 2.552e+09, 0, 0, 2.408e+09, 0, 0, 2.9e+09, 0, 0, 2.4e+09, 0, 0, 2.256e+09, 0, 0, 3.504e+09,
+        0, 0, 3.244e+09, 0, 0, 2.556e+09, 0, 0, 2.952e+09, 0, 0, 1.26e+09, 0, 0, 2.552e+09, 0, 0, 1.4e+09, 0, 0,
+        3.244e+09, 0, 0, 8.52e+08, 0, 0, 2.556e+09, 0, 0, 1.756e+09, 0, 0, 2.256e+09, 0, 0, 3.4e+09, 0, 0, 2.6e+09, 0,
+        0, 1.352e+09, 0, 0, 2.952e+09, 0, 0, 1.2e+09, 0, 0, 2.452e+09, 0, 0, 9.48e+08, 0, 0, 2.804e+09, 0, 0, 1.4e+09,
+        0, 0, 3.1e+09, 0, 0, 1.452e+09, 0, 0, 2.404e+09, 0, 0, 1.3e+09, 0, 0, 2.952e+09, 0, 0, 1.2e+09, 0, 0, 3.056e+09,
+        0, 0, 2.804e+09, 0, 0, 2.4e+09, 0, 0, 8.56001e+08, 0, 0, 2.9e+09, 0, 0, 1.5e+09, 0, 0;
+
+    Eigen::VectorXd C(cnsts);
+    C << 3.2e+20, 3.2e+20, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20,
+        3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20, 3.2e+20, 1.83484e+10,
+        2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09,
+        2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10,
+        2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10,
+        2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10,
+        2.5e+09, 1.83484e+10, 2.5e+09, 1.83484e+10;
+
+    Eigen::VectorXd phi(flows);
+    phi << 1.35273, 2.27328e-10, 2.27328e-10;
+
+    std::vector<bool> shared(cnsts, true);
+    lmm::BmfSolver solver(A, maxA, C, shared, phi);
+    auto rho = solver.solve();
+    REQUIRE((rho.array() > 0).all());
+  }
 
   SECTION("is_bmf bug: all limited by bound")
   {
@@ -609,6 +658,26 @@ TEST_CASE("kernel::bmf Bugs", "[kernel-bmf-bug]")
     REQUIRE(double_equals(rho_2->get_value(), 3, sg_maxmin_precision));
   }
 
+  SECTION("s4u-cloud-capping bug: all limited by bound extra case")
+  {
+    /*
+     * Inspired by s4u-cloud-capping test.
+     * Step 9: "Put an activity on a PM and an activity on the VM capped by 10%."
+     * Extracted from original test.
+     * The sum of bounds for 1 resource is smaller than C.
+     */
+
+    lmm::Constraint* sys_cnst = Sys.constraint_new(nullptr, 7.6296e+07);
+    lmm::Variable* rho_1      = Sys.variable_new(nullptr, 1, 7.6296e+06, 1);
+    lmm::Variable* rho_2      = Sys.variable_new(nullptr, 1, 3.8148e+07, 1);
+
+    Sys.expand_add(sys_cnst, rho_1, 1);
+    Sys.expand_add(sys_cnst, rho_2, 1);
+    Sys.solve();
+    REQUIRE(double_equals(rho_1->get_value(), 7.6296e+06, sg_maxmin_precision));
+    REQUIRE(double_equals(rho_2->get_value(), 3.8148e+07, sg_maxmin_precision));
+  }
+
   SECTION("Variable penalty with bounds: thread bug")
   {
     /*