1 /* Copyright (c) 2004-2022. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "src/kernel/lmm/maxmin.hpp"
10 #include <eigen3/Eigen/Dense>
16 class XBT_PUBLIC BmfSystem : public System {
19 void solve() final { bottleneck_solve(); }
22 void bottleneck_solve();
25 std::unordered_map<int, std::vector<int>> get_alloc(const Eigen::VectorXd& fair_sharing, bool initial) const;
26 double get_resource_capacity(int resource, const std::vector<int>& bounded_players) const;
27 Eigen::VectorXd equilibrium(const std::unordered_map<int, std::vector<int>>& alloc) const;
29 void set_fair_sharing(const std::unordered_map<int, std::vector<int>>& alloc, const Eigen::VectorXd& rho,
30 Eigen::VectorXd& fair_sharing) const;
32 template <typename T> std::string debug_eigen(const T& obj) const;
33 template <typename T> std::string debug_vector(const std::vector<T>& vector) const;
34 std::string debug_alloc(const std::unordered_map<int, std::vector<int>>& alloc) const;
36 * @brief Check if allocation is BMF
38 * To be a bmf allocation it must:
39 * - respect the capacity of all resources
40 * - saturate at least 1 resource
41 * - every player receives maximum share in at least 1 saturated resource
42 * @param rho Allocation
43 * @return true if BMF false otherwise
45 bool is_bmf(const Eigen::VectorXd& rho) const;
47 int max_iteration_ = 10;
49 Eigen::MatrixXd maxA_;
50 std::unordered_map<int, Variable*> idx2Var_;
52 std::unordered_map<const Constraint*, int> cnst2idx_;
53 static constexpr int NO_RESOURCE = -1; //!< flag to indicate player has selected no resource
58 } // namespace simgrid