- simgrid::instr::Type* ret = new simgrid::instr::Type(name, name, "", TYPE_CONTAINER, father);
- if (father == nullptr) {
- rootType = ret;
- } else {
- XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), father->getCname(),
- father->getId());
- ret->logContainerTypeDefinition();
- }
- return ret;
+void VariableType::instr_event(double now, double delta, const char* resource, double value)
+{
+ /* To trace resource utilization, we use AddEvent and SubEvent only. This implies to add a SetEvent first to set the
+ * initial value of all variables for subsequent adds/subs. If we don't do so, the first AddEvent would be added to a
+ * non-determined value, hence causing analysis problems.
+ */
+
+ // to check if variables were previously set to 0, otherwise paje won't simulate them
+ static std::set<std::string, std::less<>> platform_variables;
+
+ // create a key considering the resource and variable, and check if key exists in the global map:
+ // if it doesn't, set the variable to zero.
+ if (platform_variables.emplace(std::string(resource) + get_name()).second)
+ set_event(now, 0);
+
+ add_event(now, value);
+ sub_event(now + delta, value);