Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
CommWaitTransition mailbox is now valid
[simgrid.git] / src / kernel / lmm / maxmin.hpp
index 3cc65d62b0a910e8551cb989a4feeb5b46b1b6d9..be1e401ee15d12c93a15f6e320ea4739dc6ec976 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -7,6 +7,7 @@
 #define SURF_MAXMIN_HPP
 
 #include "simgrid/kernel/resource/Action.hpp"
+#include "simgrid/kernel/resource/Model.hpp"
 #include "simgrid/s4u/Link.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "xbt/asserts.h"
@@ -187,16 +188,18 @@ public:
  */
 class XBT_PUBLIC Constraint {
 public:
+  enum class SharingPolicy { NONLINEAR = 2, SHARED = 1, FATPIPE = 0 };
+
   Constraint() = delete;
   Constraint(resource::Resource* id_value, double bound_value);
 
   /** @brief Unshare a constraint. */
-  void unshare() { sharing_policy_ = s4u::Link::SharingPolicy::FATPIPE; }
+  void unshare() { sharing_policy_ = SharingPolicy::FATPIPE; }
 
   /** @brief Set how a constraint is shared  */
-  void set_sharing_policy(s4u::Link::SharingPolicy policy) { sharing_policy_ = policy; }
+  void set_sharing_policy(SharingPolicy policy, const s4u::NonLinearResourceCb& cb);
   /** @brief Check how a constraint is shared  */
-  s4u::Link::SharingPolicy get_sharing_policy() const { return sharing_policy_; }
+  SharingPolicy get_sharing_policy() const { return sharing_policy_; }
 
   /** @brief Get the usage of the constraint after the last lmm solve */
   double get_usage() const;
@@ -274,16 +277,18 @@ public:
   double remaining_ = 0.0;
   double usage_     = 0.0;
   double bound_;
+  double dynamic_bound_ = 0.0; //!< dynamic bound for this constraint, defined by user's callback
   // TODO MARTIN Check maximum value across resources at the end of simulation and give a warning is more than e.g. 500
   int concurrency_current_ = 0; /* The current concurrency */
   int concurrency_maximum_ = 0; /* The maximum number of (enabled and disabled) variables associated to the constraint
                                  * at any given time (essentially for tracing)*/
 
-  s4u::Link::SharingPolicy sharing_policy_ = s4u::Link::SharingPolicy::SHARED;
+  SharingPolicy sharing_policy_ = SharingPolicy::SHARED;
   int rank_; // Only used in debug messages to identify the constraint
   double lambda_               = 0.0;
   double new_lambda_           = 0.0;
   ConstraintLight* cnst_light_ = nullptr;
+  s4u::NonLinearResourceCb dyn_constraint_cb_;
 
 private:
   static int next_rank_;  // To give a separate rank_ to each constraint