/** @{ @ingroup SURF_lmm */
-/**
- * @brief Get the value of the variable after the last lmm solve
- * @param var A variable
- * @return The value of the variable
- */
-XBT_PUBLIC(double) lmm_variable_getvalue(lmm_variable_t var);
-
-/**
- * @brief Get the maximum value of the variable (-1.0 if no maximum value)
- * @param var A variable
- * @return The bound of the variable
- */
-XBT_PUBLIC(double) lmm_variable_getbound(lmm_variable_t var);
-
-/**
- * @brief Set the concurrent share of the variable
- * @param var A variable
- * @param concurrency_share The new concurrency share
- */
-XBT_PUBLIC(void) lmm_variable_concurrency_share_set(lmm_variable_t var, short int concurrency_share);
-
-/**
- * @brief Get the numth constraint associated to the variable
- * @param sys The system associated to the variable (not used)
- * @param var A variable
- * @param num The rank of constraint we want to get
- * @return The numth constraint
- */
-XBT_PUBLIC(lmm_constraint_t) lmm_get_cnst_from_var(lmm_system_t sys, lmm_variable_t var, unsigned num);
-
-/**
- * @brief Get the weigth of the numth constraint associated to the variable
- * @param sys The system associated to the variable (not used)
- * @param var A variable
- * @param num The rank of constraint we want to get
- * @return The numth constraint
- */
-XBT_PUBLIC(double) lmm_get_cnst_weight_from_var(lmm_system_t sys, lmm_variable_t var, unsigned num);
-
-/**
- * @brief Get the number of constraint associated to a variable
- * @param sys The system associated to the variable (not used)
- * @param var A variable
- * @return The number of constraint associated to the variable
- */
-XBT_PUBLIC(int) lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
-
-/**
- * @brief Get the data associated to a variable
- * @param var A variable
- * @return The data associated to the variable
- */
-XBT_PUBLIC(void*) lmm_variable_id(lmm_variable_t var);
-
-/**
- * @brief Get the weight of a variable
- * @param var A variable
- * @return The weight of the variable
- */
-XBT_PUBLIC(double) lmm_get_variable_weight(lmm_variable_t var);
-
/**
* @brief Solve the lmm system
* @param sys The lmm system to solve
surf::Cpu* cpu = ws_vm->pimpl_cpu;
xbt_assert(cpu, "cpu-less host");
- double solved_value = ws_vm->pimpl_vm_->action_->getVariable()
- ->value; // this is X1 in comment above, what this VM got in the sharing on the PM
+ double solved_value = ws_vm->pimpl_vm_->action_->getVariable()->get_value(); // this is X1 in comment above, what
+ // this VM got in the sharing on the PM
XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->getCname(), ws_vm->pimpl_vm_->getPm()->getCname());
xbt_assert(cpu->model() == surf_cpu_model_vm);
model()->getMaxminSystem()->update_constraint_bound(constraint(), coresAmount_ * speed_.scale * speed_.peak);
while ((var = constraint()->get_variable(&elem))) {
- CpuCas01Action* action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
+ CpuCas01Action* action = static_cast<CpuCas01Action*>(var->get_id());
model()->getMaxminSystem()->update_variable_bound(action->getVariable(),
action->requestedCore() * speed_.scale * speed_.peak);
turnOff();
while ((var = cnst->get_variable(&elem))) {
- Action *action = static_cast<Action*>(lmm_variable_id(var));
+ Action* action = static_cast<Action*>(var->get_id());
if (action->getState() == Action::State::running ||
action->getState() == Action::State::ready ||
CpuAction* action = static_cast<CpuAction*>(actionHeapPop());
XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
if (TRACE_is_enabled()) {
- Cpu* cpu = static_cast<Cpu*>(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)->get_id());
- TRACE_surf_host_set_utilization(cpu->getCname(), action->getCategory(),
- lmm_variable_getvalue(action->getVariable()), action->getLastUpdate(),
- now - action->getLastUpdate());
+ Cpu* cpu = static_cast<Cpu*>(action->getVariable()->get_constraint(0)->get_id());
+ TRACE_surf_host_set_utilization(cpu->getCname(), action->getCategory(), action->getVariable()->get_value(),
+ action->getLastUpdate(), now - action->getLastUpdate());
}
action->finish(Action::State::done);
CpuAction& action = static_cast<CpuAction&>(*it);
++it; // increment iterator here since the following calls to action.finish() may invalidate it
if (TRACE_is_enabled()) {
- Cpu* cpu = static_cast<Cpu*>(lmm_get_cnst_from_var(getMaxminSystem(), action.getVariable(), 0)->get_id());
- TRACE_surf_host_set_utilization(cpu->getCname(), action.getCategory(),
- lmm_variable_getvalue(action.getVariable()), now - delta, delta);
+ Cpu* cpu = static_cast<Cpu*>(action.getVariable()->get_constraint(0)->get_id());
+ TRACE_surf_host_set_utilization(cpu->getCname(), action.getCategory(), action.getVariable()->get_value(),
+ now - delta, delta);
TRACE_last_timestamp_to_dump = now - delta;
}
- action.updateRemains(lmm_variable_getvalue(action.getVariable()) * delta);
+ action.updateRemains(action.getVariable()->get_value() * delta);
if (action.getMaxDuration() != NO_MAX_DURATION)
action.updateMaxDuration(delta);
- if (((action.getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
+ if (((action.getRemainsNoUpdate() <= 0) && (action.getVariable()->get_weight() > 0)) ||
((action.getMaxDuration() != NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
action.finish(Action::State::done);
}
updateRemains(getLastValue() * delta);
if (TRACE_is_enabled()) {
- Cpu* cpu = static_cast<Cpu*>(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)->get_id());
+ Cpu* cpu = static_cast<Cpu*>(getVariable()->get_constraint(0)->get_id());
TRACE_surf_host_set_utilization(cpu->getCname(), getCategory(), getLastValue(), getLastUpdate(),
now - getLastUpdate());
}
}
refreshLastUpdate();
- setLastValue(lmm_variable_getvalue(getVariable()));
+ setLastValue(getVariable()->get_value());
}
simgrid::xbt::signal<void(simgrid::surf::CpuAction*, Action::State)> CpuAction::onStateChange;
/** @brief returns a list of all CPUs that this action is using */
std::list<Cpu*> CpuAction::cpus() {
std::list<Cpu*> retlist;
- lmm_system_t sys = getModel()->getMaxminSystem();
- int llen = lmm_get_number_of_cnst_from_var(sys, getVariable());
+ int llen = getVariable()->get_number_of_constraint();
for (int i = 0; i < llen; i++) {
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
- Resource* resource = static_cast<Resource*>(lmm_get_cnst_from_var(sys, getVariable(), i)->get_id());
+ Resource* resource = static_cast<Resource*>(getVariable()->get_constraint(i)->get_id());
Cpu* cpu = dynamic_cast<Cpu*>(resource);
if (cpu != nullptr)
retlist.push_back(cpu);
double sg_surf_precision = 0.00001; /* Change this with --cfg=surf/precision:VALUE */
int sg_concurrency_limit = -1; /* Change this with --cfg=maxmin/concurrency-limit:VALUE */
-static int Global_debug_id = 1;
+int s_lmm_variable_t::Global_debug_id = 1;
int s_lmm_constraint_t::Global_debug_id = 1;
-static int lmm_can_enable_var(lmm_variable_t var);
-static int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var);
-
int s_lmm_element_t::get_concurrency() const
{
//Ignore element with weight less than one (e.g. cross-traffic)
lmm_element_t elem = (lmm_element_t)elemIt;
// We should have staged variables only if concurrency is reached in some constraint
xbt_assert(cnst->get_concurrency_limit() < 0 || elem->variable->staged_weight == 0 ||
- lmm_cnstrs_min_concurrency_slack(elem->variable) < elem->variable->concurrency_share,
+ elem->variable->get_min_concurrency_slack() < elem->variable->concurrency_share,
"should not have staged variable!");
}
{
XBT_IN("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)", this, id, sharing_weight, bound, number_of_constraints);
- lmm_variable_t var = (lmm_variable_t)xbt_mallocator_get(variable_mallocator);
- var->id = id;
- var->id_int = Global_debug_id++;
- var->cnsts.reserve(number_of_constraints);
- var->sharing_weight = sharing_weight;
- var->staged_weight = 0.0;
- var->bound = bound;
- var->concurrency_share = 1;
- var->value = 0.0;
- var->visited = visited_counter - 1;
- var->mu = 0.0;
- var->new_mu = 0.0;
- var->func_f = func_f_def;
- var->func_fp = func_fp_def;
- var->func_fpi = func_fpi_def;
-
- var->variable_set_hookup.next = nullptr;
- var->variable_set_hookup.prev = nullptr;
- var->saturated_variable_set_hookup.next = nullptr;
- var->saturated_variable_set_hookup.prev = nullptr;
-
+ lmm_variable_t var = static_cast<lmm_variable_t>(xbt_mallocator_get(variable_mallocator));
+ var->initialize(id, sharing_weight, bound, number_of_constraints, visited_counter - 1);
if (sharing_weight)
xbt_swag_insert_at_head(var, &variable_set);
else
var_free(var);
}
-double lmm_variable_getvalue(lmm_variable_t var)
-{
- return (var->value);
-}
-
-void lmm_variable_concurrency_share_set(lmm_variable_t var, short int concurrency_share)
-{
- var->concurrency_share=concurrency_share;
-}
-
-double lmm_variable_getbound(lmm_variable_t var)
-{
- return (var->bound);
-}
-
void s_lmm_system_t::expand(lmm_constraint_t cnst, lmm_variable_t var, double consumption_weight)
{
modified = 1;
check_concurrency();
}
-lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var, unsigned num)
-{
- if (num < var->cnsts.size())
- return (var->cnsts[num].constraint);
- else
- return nullptr;
-}
-
-double lmm_get_cnst_weight_from_var(lmm_system_t /*sys*/, lmm_variable_t var, unsigned num)
-{
- if (num < var->cnsts.size())
- return (var->cnsts[num].consumption_weight);
- else
- return 0.0;
-}
-
-int lmm_get_number_of_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var)
-{
- return (var->cnsts.size());
-}
-
lmm_variable_t s_lmm_constraint_t::get_variable(lmm_element_t* elem) const
{
if (*elem == nullptr) {
return nullptr;
}
-void *lmm_variable_id(lmm_variable_t var)
-{
- return var->id;
-}
-
static inline void saturated_constraint_set_update(double usage, int cnst_light_num,
dyn_light_t& saturated_constraint_set, double* min_usage)
{
update_modified_set(var->cnsts[0].constraint);
}
-/** \brief Measure the minimum concurrency slack across all constraints where the given var is involved */
-int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var)
+void s_lmm_variable_t::initialize(simgrid::surf::Action* id_value, double sharing_weight_value, double bound_value,
+ int number_of_constraints, unsigned visited_value)
+{
+ id = id_value;
+ id_int = s_lmm_variable_t::Global_debug_id++;
+ cnsts.reserve(number_of_constraints);
+ sharing_weight = sharing_weight_value;
+ staged_weight = 0.0;
+ bound = bound_value;
+ concurrency_share = 1;
+ value = 0.0;
+ visited = visited_value;
+ mu = 0.0;
+ new_mu = 0.0;
+ func_f = func_f_def;
+ func_fp = func_fp_def;
+ func_fpi = func_fpi_def;
+
+ variable_set_hookup.next = nullptr;
+ variable_set_hookup.prev = nullptr;
+ saturated_variable_set_hookup.next = nullptr;
+ saturated_variable_set_hookup.prev = nullptr;
+}
+
+int s_lmm_variable_t::get_min_concurrency_slack() const
{
int minslack = std::numeric_limits<int>::max();
- for (s_lmm_element_t const& elem : var->cnsts) {
+ for (s_lmm_element_t const& elem : cnsts) {
int slack = elem.constraint->get_concurrency_slack();
if (slack < minslack) {
// This is only an optimization, to avoid looking at more constraints when slack is already zero
return minslack;
}
-/* /Check if a variable can be enabled
- *
- * Make sure to set staged_weight before, if your intent is only to check concurrency
- */
-int lmm_can_enable_var(lmm_variable_t var){
- return var->staged_weight>0 && lmm_cnstrs_min_concurrency_slack(var)>=var->concurrency_share;
-}
-
//Small remark: In this implementation of lmm_enable_var and lmm_disable_var, we will meet multiple times with var when
// running sys->update_modified_set.
// A priori not a big performance issue, but we might do better by calling sys->update_modified_set within the for loops
// (after doing the first for enabling==1, and before doing the last for disabling==1)
void s_lmm_system_t::enable_var(lmm_variable_t var)
{
- xbt_assert(not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug) || lmm_can_enable_var(var));
+ xbt_assert(not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug) || var->can_enable());
var->sharing_weight = var->staged_weight;
var->staged_weight = 0;
lmm_element_t nextelem = (lmm_element_t)xbt_swag_getNext(elem, cnstr->disabled_element_set.offset);
- if (elem->variable->staged_weight > 0 && lmm_can_enable_var(elem->variable)) {
+ if (elem->variable->staged_weight > 0 && elem->variable->can_enable()) {
//Found a staged variable
//TODOLATER: Add random timing function to model reservation protocol fuzziness? Then how to make sure that
//staged variables will eventually be called?
//Are we enabling this variable?
if (enabling_var){
var->staged_weight = weight;
- int minslack = lmm_cnstrs_min_concurrency_slack(var);
+ int minslack = var->get_min_concurrency_slack();
if (minslack < var->concurrency_share) {
XBT_DEBUG("Staging var (instead of enabling) because min concurrency slack %i, with weight %f and concurrency"
" share %i", minslack, weight, var->concurrency_share);
XBT_OUT();
}
-double lmm_get_variable_weight(lmm_variable_t var)
-{
- return var->sharing_weight;
-}
-
void s_lmm_system_t::update_constraint_bound(lmm_constraint_t cnst, double bound)
{
modified = 1;
*
* When something prevents us from enabling a variable, we "stage" the weight that we would have like to set, so that as soon as possible we enable the variable with desired weight
*/
-struct s_lmm_variable_t {
+class s_lmm_variable_t {
+public:
+ void initialize(simgrid::surf::Action* id_value, double sharing_weight_value, double bound_value,
+ int number_of_constraints, unsigned visited_value);
+
+ /**
+ * @brief Get the value of the variable after the last lmm solve
+ * @return The value of the variable
+ */
+ double get_value() const { return value; }
+
+ /**
+ * @brief Get the maximum value of the variable (-1.0 if no maximum value)
+ * @return The bound of the variable
+ */
+ double get_bound() const { return bound; }
+
+ /**
+ * @brief Set the concurrent share of the variable
+ * @param concurrency_share The new concurrency share
+ */
+ void set_concurrency_share(short int value) { concurrency_share = value; }
+
+ /**
+ * @brief Get the numth constraint associated to the variable
+ * @param num The rank of constraint we want to get
+ * @return The numth constraint
+ */
+ lmm_constraint_t get_constraint(unsigned num) const { return num < cnsts.size() ? cnsts[num].constraint : nullptr; }
+
+ /**
+ * @brief Get the weigth of the numth constraint associated to the variable
+ * @param num The rank of constraint we want to get
+ * @return The numth constraint
+ */
+ double get_constraint_weight(unsigned num) const { return num < cnsts.size() ? cnsts[num].consumption_weight : 0.0; }
+
+ /**
+ * @brief Get the number of constraint associated to a variable
+ * @return The number of constraint associated to the variable
+ */
+ int get_number_of_constraint() const { return cnsts.size(); }
+
+ /**
+ * @brief Get the data associated to a variable
+ * @return The data associated to the variable
+ */
+ simgrid::surf::Action* get_id() const { return id; }
+
+ /**
+ * @brief Get the weight of a variable
+ * @return The weight of the variable
+ */
+ double get_weight() const { return sharing_weight; }
+
+ /** @brief Measure the minimum concurrency slack across all constraints where the given var is involved */
+ int get_min_concurrency_slack() const;
+
+ /** @brief Check if a variable can be enabled
+ * Make sure to set staged_weight before, if your intent is only to check concurrency
+ */
+ int can_enable() const { return staged_weight > 0 && get_min_concurrency_slack() >= concurrency_share; }
+
/* hookup to system */
s_xbt_swag_hookup_t variable_set_hookup;
s_xbt_swag_hookup_t saturated_variable_set_hookup;
double (*func_fp)(s_lmm_variable_t* var, double x); /* (f') */
double (*func_fpi)(s_lmm_variable_t* var, double x); /* (f')^{-1} */
/* \end{For Lagrange only} */
+
+private:
+ static int Global_debug_id;
};
inline void s_lmm_element_t::make_active()
NetworkCm02Action* action = static_cast<NetworkCm02Action*>(actionHeapPop());
XBT_DEBUG("Something happened to action %p", action);
if (TRACE_is_enabled()) {
- int n = lmm_get_number_of_cnst_from_var(maxminSystem_, action->getVariable());
+ int n = action->getVariable()->get_number_of_constraint();
for (int i = 0; i < n; i++){
- lmm_constraint_t constraint = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
+ lmm_constraint_t constraint = action->getVariable()->get_constraint(i);
NetworkCm02Link* link = static_cast<NetworkCm02Link*>(constraint->get_id());
- double value = lmm_variable_getvalue(action->getVariable())*
- lmm_get_cnst_weight_from_var(maxminSystem_, action->getVariable(), i);
+ double value = action->getVariable()->get_value() * action->getVariable()->get_constraint_weight(i);
TRACE_surf_link_set_utilization(link->getCname(), action->getCategory(), value, action->getLastUpdate(),
now - action->getLastUpdate());
}
maxminSystem_->update_variable_weight(action.getVariable(), action.weight_);
}
if (TRACE_is_enabled()) {
- int n = lmm_get_number_of_cnst_from_var(maxminSystem_, action.getVariable());
+ int n = action.getVariable()->get_number_of_constraint();
for (int i = 0; i < n; i++) {
- lmm_constraint_t constraint = lmm_get_cnst_from_var(maxminSystem_, action.getVariable(), i);
-
+ lmm_constraint_t constraint = action.getVariable()->get_constraint(i);
NetworkCm02Link* link = static_cast<NetworkCm02Link*>(constraint->get_id());
- TRACE_surf_link_set_utilization(link->getCname(), action.getCategory(),
- (lmm_variable_getvalue(action.getVariable()) *
- lmm_get_cnst_weight_from_var(maxminSystem_, action.getVariable(), i)),
- action.getLastUpdate(), now - action.getLastUpdate());
+ TRACE_surf_link_set_utilization(
+ link->getCname(), action.getCategory(),
+ (action.getVariable()->get_value() * action.getVariable()->get_constraint_weight(i)),
+ action.getLastUpdate(), now - action.getLastUpdate());
}
}
- if (not lmm_get_number_of_cnst_from_var(maxminSystem_, action.getVariable())) {
+ if (not action.getVariable()->get_number_of_constraint()) {
/* There is actually no link used, hence an infinite bandwidth. This happens often when using models like
* vivaldi. In such case, just make sure that the action completes immediately.
*/
action.updateRemains(action.getRemains());
}
- action.updateRemains(lmm_variable_getvalue(action.getVariable()) * delta);
+ action.updateRemains(action.getVariable()->get_value() * delta);
if (action.getMaxDuration() > NO_MAX_DURATION)
action.updateMaxDuration(delta);
- if (((action.getRemains() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
+ if (((action.getRemains() <= 0) && (action.getVariable()->get_weight() > 0)) ||
((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
action.finish(Action::State::done);
}
turnOff();
while ((var = constraint()->get_variable(&elem))) {
- Action *action = static_cast<Action*>( lmm_variable_id(var) );
+ Action* action = static_cast<Action*>(var->get_id());
if (action->getState() == Action::State::running ||
action->getState() == Action::State::ready) {
lmm_element_t nextelem = nullptr;
int numelem = 0;
while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) {
- NetworkCm02Action *action = static_cast<NetworkCm02Action*>(lmm_variable_id(var));
+ NetworkCm02Action* action = static_cast<NetworkCm02Action*>(var->get_id());
action->weight_ += delta;
if (not action->isSuspended())
model()->getMaxminSystem()->update_variable_weight(action->getVariable(), action->weight_);
latency_.peak = value;
while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) {
- NetworkCm02Action *action = static_cast<NetworkCm02Action*>(lmm_variable_id(var));
+ NetworkCm02Action* action = static_cast<NetworkCm02Action*>(var->get_id());
action->latCurrent_ += delta;
action->weight_ += delta;
if (action->rate_ < 0)
setMaxDuration(max_duration);
}
- if ((getRemainsNoUpdate() <= 0 && (lmm_get_variable_weight(getVariable()) > 0)) ||
+ if ((getRemainsNoUpdate() <= 0 && (getVariable()->get_weight() > 0)) ||
((max_duration > NO_MAX_DURATION) && (max_duration <= 0))) {
finish(Action::State::done);
heapRemove(getModel()->getActionHeap());
}
refreshLastUpdate();
- setLastValue(lmm_variable_getvalue(getVariable()));
+ setLastValue(getVariable()->get_value());
}
}
std::list<LinkImpl*> NetworkAction::links()
{
std::list<LinkImpl*> retlist;
- lmm_system_t sys = getModel()->getMaxminSystem();
- int llen = lmm_get_number_of_cnst_from_var(sys, getVariable());
+ int llen = getVariable()->get_number_of_constraint();
for (int i = 0; i < llen; i++) {
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
- Resource* resource = static_cast<Resource*>(lmm_get_cnst_from_var(sys, getVariable(), i)->get_id());
+ Resource* resource = static_cast<Resource*>(getVariable()->get_constraint(i)->get_id());
LinkImpl* link = dynamic_cast<LinkImpl*>(resource);
if (link != nullptr)
retlist.push_back(link);
}
}
XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.getRemains(),
- lmm_variable_getvalue(action.getVariable()) * delta);
- action.updateRemains(lmm_variable_getvalue(action.getVariable()) * delta);
+ action.getVariable()->get_value() * delta);
+ action.updateRemains(action.getVariable()->get_value() * delta);
if (action.getMaxDuration() > NO_MAX_DURATION)
action.updateMaxDuration(delta);
* If it's not done, it may have failed.
*/
- if (((action.getRemains() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
+ if (((action.getRemains() <= 0) && (action.getVariable()->get_weight() > 0)) ||
((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
action.finish(Action::State::done);
} else {
/* Need to check that none of the model has failed */
int i = 0;
- lmm_constraint_t cnst = lmm_get_cnst_from_var(maxminSystem_, action.getVariable(), i);
+ lmm_constraint_t cnst = action.getVariable()->get_constraint(i);
while (cnst != nullptr) {
i++;
void* constraint_id = cnst->get_id();
action.finish(Action::State::failed);
break;
}
- cnst = lmm_get_cnst_from_var(maxminSystem_, action.getVariable(), i);
+ cnst = action.getVariable()->get_constraint(i);
}
}
}
model()->getMaxminSystem()->update_constraint_bound(constraint(), speed_.peak * speed_.scale);
while ((var = constraint()->get_variable(&elem))) {
- Action* action = static_cast<Action*>(lmm_variable_id(var));
+ Action* action = static_cast<Action*>(var->get_id());
model()->getMaxminSystem()->update_variable_bound(action->getVariable(), speed_.scale * speed_.peak);
}
latency_.peak = value;
while ((var = constraint()->get_variable(&elem))) {
- action = static_cast<L07Action*>(lmm_variable_id(var));
+ action = static_cast<L07Action*>(var->get_id());
action->updateBound();
}
}
for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
StorageAction& action = static_cast<StorageAction&>(*it);
++it; // increment iterator here since the following calls to action.finish() may invalidate it
- action.updateRemains(lrint(lmm_variable_getvalue(action.getVariable()) * delta));
+ action.updateRemains(lrint(action.getVariable()->get_value() * delta));
if (action.getMaxDuration() > NO_MAX_DURATION)
action.updateMaxDuration(delta);
- if (((action.getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
+ if (((action.getRemainsNoUpdate() <= 0) && (action.getVariable()->get_weight() > 0)) ||
((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
action.finish(Action::State::done);
}
action->updateRemainingLazy(now);
double min = -1;
- double share = lmm_variable_getvalue(action->getVariable());
+ double share = action->getVariable()->get_value();
if (share > 0) {
double time_to_completion;
double min = -1;
for (Action& action : *getRunningActionSet()) {
- double value = lmm_variable_getvalue(action.getVariable());
+ double value = action.getVariable()->get_value();
if (value > 0) {
if (action.getRemains() > 0)
value = action.getRemainsNoUpdate() / value;
double Action::getBound() const
{
- return (variable_) ? lmm_variable_getbound(variable_) : 0;
+ return variable_ ? variable_->get_bound() : 0;
}
void Action::setBound(double bound)
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
-#define PRINT_VAR(var) XBT_DEBUG(#var " = %g",lmm_variable_getvalue(var))
+#define PRINT_VAR(var) XBT_DEBUG(#var " = %g", (var)->get_value())
#define SHOW_EXPR(expr) XBT_DEBUG(#expr " = %g",expr)
/* ______ */
lagrange_solve(Sys);
double max_deviation = 0.0;
- max_deviation = std::max(max_deviation, fabs(lmm_variable_getvalue(R_1) - x));
- max_deviation = std::max(max_deviation, fabs(lmm_variable_getvalue(R_3) - x));
- max_deviation = std::max(max_deviation, fabs(lmm_variable_getvalue(R_2) - (b - a + x)));
- max_deviation = std::max(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
+ max_deviation = std::max(max_deviation, fabs(R_1->get_value() - x));
+ max_deviation = std::max(max_deviation, fabs(R_3->get_value() - x));
+ max_deviation = std::max(max_deviation, fabs(R_2->get_value() - (b - a + x)));
+ max_deviation = std::max(max_deviation, fabs(R_1_2_3->get_value() - (a - x)));
if (max_deviation > 0.00001) { // Legacy value used in lagrange.c
XBT_WARN("Max Deviation from optimal solution : %g", max_deviation);
XBT_WARN("Found x = %1.20f", x);
- XBT_WARN("Deviation from optimal solution (R_1 = %g): %1.20f", x, lmm_variable_getvalue(R_1) - x);
- XBT_WARN("Deviation from optimal solution (R_2 = %g): %1.20f", b - a + x,
- lmm_variable_getvalue(R_2) - (b - a + x));
- XBT_WARN("Deviation from optimal solution (R_3 = %g): %1.20f", x, lmm_variable_getvalue(R_3) - x);
- XBT_WARN("Deviation from optimal solution (R_1_2_3 = %g): %1.20f", a - x,
- lmm_variable_getvalue(R_1_2_3) - (a - x));
+ XBT_WARN("Deviation from optimal solution (R_1 = %g): %1.20f", x, R_1->get_value() - x);
+ XBT_WARN("Deviation from optimal solution (R_2 = %g): %1.20f", b - a + x, R_2->get_value() - (b - a + x));
+ XBT_WARN("Deviation from optimal solution (R_3 = %g): %1.20f", x, R_3->get_value() - x);
+ XBT_WARN("Deviation from optimal solution (R_1_2_3 = %g): %1.20f", a - x, R_1_2_3->get_value() - (a - x));
}
}
var[i] = Sys->variable_new(NULL, 1.0, -1.0, nb_elem);
//Have a few variables with a concurrency share of two (e.g. cross-traffic in some cases)
int concurrency_share = 1 + int_random(max_share);
- lmm_variable_concurrency_share_set(var[i],concurrency_share);
+ var[i]->set_concurrency_share(concurrency_share);
for (int j = 0; j < nb_cnst; j++)
used[j] = 0;