Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add battery plugin and fix DAG doc
authorAdrien <adrien.gougeon@ens-rennes.fr>
Fri, 31 Mar 2023 11:54:07 +0000 (11:54 +0000)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 31 Mar 2023 11:54:07 +0000 (11:54 +0000)
35 files changed:
MANIFEST.in
docs/source/Plugins.rst
docs/source/Tutorial_DAG.rst
docs/source/img/battery_degradation.svg [new file with mode: 0644]
docs/source/img/dag.svg [moved from docs/source/tuto_dag/img/dag.svg with 100% similarity]
docs/source/img/dag1.svg [moved from docs/source/tuto_dag/img/dag1.svg with 100% similarity]
docs/source/img/dag2.svg [moved from docs/source/tuto_dag/img/dag2.svg with 100% similarity]
docs/source/tuto_dag/dag_lab1.cpp [deleted file]
docs/source/tuto_dag/dag_lab2-1.cpp [deleted file]
docs/source/tuto_dag/dag_lab2-2.cpp [deleted file]
docs/source/tuto_dag/dag_lab2-3.cpp [deleted file]
docs/source/tuto_dag/small_platform.xml [deleted file]
examples/cpp/CMakeLists.txt
examples/cpp/battery-degradation/plot_battery_degradation.py [new file with mode: 0644]
examples/cpp/battery-degradation/s4u-battery-degradation.cpp [new file with mode: 0644]
examples/cpp/battery-degradation/s4u-battery-degradation.tesh [new file with mode: 0644]
examples/cpp/battery-energy/s4u-battery-energy.cpp [new file with mode: 0644]
examples/cpp/battery-energy/s4u-battery-energy.tesh [new file with mode: 0644]
examples/cpp/battery-simple/s4u-battery-simple.cpp [new file with mode: 0644]
examples/cpp/battery-simple/s4u-battery-simple.tesh [new file with mode: 0644]
examples/cpp/dag-from-dax-simple/dag.xml [moved from docs/source/tuto_dag/simple_dax.xml with 100% similarity]
examples/cpp/dag-from-dax-simple/s4u-dag-from-dax-simple.cpp [new file with mode: 0644]
examples/cpp/dag-from-dax-simple/s4u-dag-from-dax-simple.tesh [new file with mode: 0644]
examples/cpp/dag-from-dot-simple/dag.dot [moved from docs/source/tuto_dag/simple_dot.dot with 100% similarity]
examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.cpp [new file with mode: 0644]
examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.tesh [new file with mode: 0644]
examples/cpp/dag-from-json-simple/dag.json [moved from docs/source/tuto_dag/simple_json.json with 100% similarity]
examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.cpp [new file with mode: 0644]
examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.tesh [new file with mode: 0644]
examples/cpp/dag-tuto/s4u-dag-tuto.cpp [new file with mode: 0644]
examples/cpp/dag-tuto/s4u-dag-tuto.tesh [new file with mode: 0644]
examples/platforms/battery_platform.xml [new file with mode: 0644]
include/simgrid/plugins/battery.hpp [new file with mode: 0644]
src/plugins/battery.cpp [new file with mode: 0644]
tools/cmake/DefinePackages.cmake

index 9ae7ec1..1edd9e2 100644 (file)
@@ -162,6 +162,13 @@ include examples/cpp/app-masterworkers/s4u-app-masterworkers.tesh
 include examples/cpp/app-masterworkers/s4u-app-masterworkers_d.xml
 include examples/cpp/app-token-ring/s4u-app-token-ring.cpp
 include examples/cpp/app-token-ring/s4u-app-token-ring.tesh
+include examples/cpp/battery-degradation/plot_battery_degradation.py
+include examples/cpp/battery-degradation/s4u-battery-degradation.cpp
+include examples/cpp/battery-degradation/s4u-battery-degradation.tesh
+include examples/cpp/battery-energy/s4u-battery-energy.cpp
+include examples/cpp/battery-energy/s4u-battery-energy.tesh
+include examples/cpp/battery-simple/s4u-battery-simple.cpp
+include examples/cpp/battery-simple/s4u-battery-simple.tesh
 include examples/cpp/cloud-capping/s4u-cloud-capping.cpp
 include examples/cpp/cloud-capping/s4u-cloud-capping.tesh
 include examples/cpp/cloud-migration/s4u-cloud-migration.cpp
@@ -199,14 +206,23 @@ include examples/cpp/dag-comm/s4u-dag-comm.cpp
 include examples/cpp/dag-comm/s4u-dag-comm.tesh
 include examples/cpp/dag-failure/s4u-dag-failure.cpp
 include examples/cpp/dag-failure/s4u-dag-failure.tesh
+include examples/cpp/dag-from-dax-simple/dag.xml
+include examples/cpp/dag-from-dax-simple/s4u-dag-from-dax-simple.cpp
+include examples/cpp/dag-from-dax-simple/s4u-dag-from-dax-simple.tesh
 include examples/cpp/dag-from-dax/s4u-dag-from-dax.cpp
 include examples/cpp/dag-from-dax/s4u-dag-from-dax.tesh
 include examples/cpp/dag-from-dax/simple_dax_with_cycle.xml
 include examples/cpp/dag-from-dax/smalldax.xml
+include examples/cpp/dag-from-dot-simple/dag.dot
+include examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.cpp
+include examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.tesh
 include examples/cpp/dag-from-dot/dag.dot
 include examples/cpp/dag-from-dot/dag_with_cycle.dot
 include examples/cpp/dag-from-dot/s4u-dag-from-dot.cpp
 include examples/cpp/dag-from-dot/s4u-dag-from-dot.tesh
+include examples/cpp/dag-from-json-simple/dag.json
+include examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.cpp
+include examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.tesh
 include examples/cpp/dag-io/s4u-dag-io.cpp
 include examples/cpp/dag-io/s4u-dag-io.tesh
 include examples/cpp/dag-scheduling/Montage_25.xml
@@ -214,6 +230,8 @@ include examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp
 include examples/cpp/dag-scheduling/s4u-dag-scheduling.tesh
 include examples/cpp/dag-simple/s4u-dag-simple.cpp
 include examples/cpp/dag-simple/s4u-dag-simple.tesh
+include examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+include examples/cpp/dag-tuto/s4u-dag-tuto.tesh
 include examples/cpp/dht-chord/s4u-dht-chord-node.cpp
 include examples/cpp/dht-chord/s4u-dht-chord.cpp
 include examples/cpp/dht-chord/s4u-dht-chord.hpp
@@ -1678,6 +1696,10 @@ include docs/source/app_smpi.rst
 include docs/source/application.rst
 include docs/source/community.rst
 include docs/source/conf.py
+include docs/source/img/battery_degradation.svg
+include docs/source/img/dag.svg
+include docs/source/img/dag1.svg
+include docs/source/img/dag2.svg
 include docs/source/img/design-scheduling-parallel.svg
 include docs/source/img/design-scheduling-simulatedtime.svg
 include docs/source/img/design-scheduling-wallclock.svg
@@ -1699,17 +1721,6 @@ include docs/source/img/zoom_comm.drawio
 include docs/source/img/zoom_comm.svg
 include docs/source/index.rst
 include docs/source/intl.rst
-include docs/source/tuto_dag/dag_lab1.cpp
-include docs/source/tuto_dag/dag_lab2-1.cpp
-include docs/source/tuto_dag/dag_lab2-2.cpp
-include docs/source/tuto_dag/dag_lab2-3.cpp
-include docs/source/tuto_dag/img/dag.svg
-include docs/source/tuto_dag/img/dag1.svg
-include docs/source/tuto_dag/img/dag2.svg
-include docs/source/tuto_dag/simple_dax.xml
-include docs/source/tuto_dag/simple_dot.dot
-include docs/source/tuto_dag/simple_json.json
-include docs/source/tuto_dag/small_platform.xml
 include docs/source/tuto_disk/CMakeLists.txt
 include docs/source/tuto_disk/Dockerfile
 include docs/source/tuto_disk/analysis.irst
@@ -1776,6 +1787,7 @@ include examples/README.rst
 include examples/c/CMakeLists.txt
 include examples/cpp/CMakeLists.txt
 include examples/platforms/CMakeLists.txt
+include examples/platforms/battery_platform.xml
 include examples/platforms/bypassRoute.xml
 include examples/platforms/bypassZoneRoute.xml
 include examples/platforms/cloud.xml
@@ -1904,6 +1916,7 @@ include include/simgrid/mailbox.h
 include include/simgrid/modelchecker.h
 include include/simgrid/mutex.h
 include include/simgrid/plugins/ProducerConsumer.hpp
+include include/simgrid/plugins/battery.hpp
 include include/simgrid/plugins/dvfs.h
 include include/simgrid/plugins/energy.h
 include include/simgrid/plugins/file_system.h
@@ -2254,6 +2267,7 @@ include src/mc/transition/TransitionRandom.hpp
 include src/mc/transition/TransitionSynchro.cpp
 include src/mc/transition/TransitionSynchro.hpp
 include src/plugins/ProducerConsumer.cpp
+include src/plugins/battery.cpp
 include src/plugins/chaos_monkey.cpp
 include src/plugins/file_system/s4u_FileSystem.cpp
 include src/plugins/host_dvfs.cpp
index 0594693..4511223 100644 (file)
@@ -159,5 +159,13 @@ File System
 
 .. doxygengroup:: plugin_filesystem
 
+.. _plugin_battery:
+
+Battery
+===========
+
+.. doxygengroup:: plugin_battery
+
+
 
 ..  LocalWords:  SimGrid
index e807cc4..621eaf2 100644 (file)
@@ -26,7 +26,7 @@ Set of edges representing precedence constraints between :ref:`Activities <API_s
 
    \mathcal{E} = {e_i,j | (i,j) \in {1, ..., V} x {1, ..., V}}
 
-.. image:: /tuto_dag/img/dag.svg
+.. image:: /img/dag.svg
    :align: center
 
 Representing Vertices/Activities
@@ -58,7 +58,7 @@ Representing Edges/Dependencies
 
 An activity will not start until all of its dependencies have been completed.
 Activities may have any number of successors.
-Dependencies between Activities are created using :cpp:func:`Activity::add_successor(ActivityPtr)`.
+Dependencies between Activities are created using :cpp:func:`simgrid::s4u::Activity::add_successor`.
 
 .. code-block:: cpp
 
@@ -71,7 +71,7 @@ Lab 1: Basics
 
 The goal of this lab is to describe the following DAG: 
 
-.. image:: /tuto_dag/img/dag1.svg
+.. image:: /img/dag1.svg
    :align: center
 
 In this DAG we want ``c1`` to compute 1e9 flops, ``c2`` to compute 5e9 flops and ``c3`` to compute 2e9 flops. 
@@ -79,110 +79,83 @@ There is also a data transfer of 5e8 bytes between ``c1`` and ``c3``.
 
 First of all, include the Simgrid library and define the log category.
 
-.. code-block:: cpp
-
-   #include "simgrid/s4u.hpp"
-
-   XBT_LOG_NEW_DEFAULT_CATEGORY(main, "Messages specific for this s4u tutorial");
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 6-8
 
 Inside the ``main`` function create an instance of :ref:`Engine <API_s4u_Engine>` and load the platform.
 
-.. code-block:: cpp
-
-    simgrid::s4u::Engine e(&argc, argv);
-    e.load_platform(argv[1]);
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 12-13
 
 Retrieve pointers to some hosts.
 
-.. code-block:: cpp
-
-    simgrid::s4u::Host* tremblay = e.host_by_name("Tremblay");
-    simgrid::s4u::Host* jupiter  = e.host_by_name("Jupiter");
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 15-16
 
 Initiate the activities.
 
-.. code-block:: cpp
-
-    simgrid::s4u::ExecPtr c1 = simgrid::s4u::Exec::init();
-    simgrid::s4u::ExecPtr c2 = simgrid::s4u::Exec::init();
-    simgrid::s4u::ExecPtr c3 = simgrid::s4u::Exec::init();
-    simgrid::s4u::CommPtr t1 = simgrid::s4u::Comm::sendto_init();
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 18-21
 
 Give names to thoses activities.
 
-.. code-block:: cpp
-
-    c1->set_name("c1");
-    c2->set_name("c2");
-    c3->set_name("c3");
-    t1->set_name("t1");
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 23-26
 
 Set the amount of work for each activity.
 
-.. code-block:: cpp
-
-    c1->set_flops_amount(1e9);
-    c2->set_flops_amount(5e9);
-    c3->set_flops_amount(2e9);
-    t1->set_payload_size(5e8);
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 28-31
 
 Define the dependencies between the activities.
 
-.. code-block:: cpp
-
-    c1->add_successor(t1);
-    t1->add_successor(c3);
-    c2->add_successor(c3);
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 33-35
 
 Set the location of each Exec activity and source and destination for the Comm activity.
 
-.. code-block:: cpp
-
-    c1->set_host(tremblay);
-    c2->set_host(jupiter);
-    c3->set_host(jupiter);
-    t1->set_source(tremblay);
-    t1->set_destination(jupiter);
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 37-41
 
 Start the executions of Activities without dependencies.
 
-.. code-block:: cpp
-
-    c1->start();
-    c2->start();
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 43-44
 
 Add a callback to monitor the activities.
 
-.. code-block:: cpp
-
-   Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-      XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(), activity.get_start_time(),
-               activity.get_finish_time());
-      });
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 46-49
 
 Finally, run the simulation.
 
-.. code-block:: cpp
-
-   e.run();
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.cpp
+   :language: cpp
+   :lines: 51
 
 The execution of this code should give you the following output:
 
-.. code-block:: bash
-
-   [10.194200] [main/INFO] Activity 'c1' is complete (start time: 0.000000, finish time: 10.194200)
-   [65.534235] [main/INFO] Activity 'c2' is complete (start time: 0.000000, finish time: 65.534235)
-   [85.283378] [main/INFO] Activity 't1' is complete (start time: 10.194200, finish time: 85.283378)
-   [111.497072] [main/INFO] Activity 'c3' is complete (start time: 85.283378, finish time: 111.497072)
-
+.. literalinclude:: ../../examples/cpp/dag-tuto/s4u-dag-tuto.tesh
+   :language: none
+   :lines: 4-
 Lab 2: Import a DAG from a file
----------------
+-------------------------------
 
 In this lab we present how to import a DAG into you Simgrid simulation, either using a DOT file, a JSON file, or a DAX file. 
 
 The files presented in this lab describe the following DAG:
 
-.. image:: /tuto_dag/img/dag2.svg
+.. image:: /img/dag2.svg
    :align: center
 
 From a DOT file
@@ -192,74 +165,19 @@ A DOT file describes a workflow in accordance with the graphviz format.
 
 The following DOT file describes the workflow presented at the beginning of this lab:
 
-.. code-block:: xml
-
-   digraph G {
-      c1 [size="1e9"];
-      c2 [size="5e9"];
-      c3 [size="2e9"];
+.. literalinclude:: ../../examples/cpp/dag-from-dot-simple/dag.dot
+   :language: dot
 
-      root->c1 [size="2e8"];
-      root->c2 [size="1e8"];
-      c1->c3   [size="5e8"];
-      c2->c3   [size="-1"];
-      c3->end  [size="2e8"];
-   }
+It can be imported as a vector of Activities into Simgrid using :cpp:func:`simgrid::s4u::create_DAG_from_DOT`. Then, you have to assign hosts to your Activities.
 
-It can be imported as a vector of Activities into Simgrid using :cpp:func:`create_DAG_from_DOT(const std::string& filename)`. Then, you have to assign hosts to your Activities.
-
-.. code-block:: cpp
-
-   #include "simgrid/s4u.hpp"
-
-   XBT_LOG_NEW_DEFAULT_CATEGORY(main, "Messages specific for this s4u example");
-
-   int main(int argc, char* argv[]) {
-      simgrid::s4u::Engine e(&argc, argv);
-      e.load_platform(argv[1]);
-
-      std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_dot(argv[2]);
-
-      simgrid::s4u::Host* tremblay = e.host_by_name("Tremblay");
-      simgrid::s4u::Host* jupiter  = e.host_by_name("Jupiter");
-      simgrid::s4u::Host* fafard  = e.host_by_name("Fafard");
-
-      dynamic_cast<simgrid::s4u::Exec*>(dag[0].get())->set_host(fafard);
-      dynamic_cast<simgrid::s4u::Exec*>(dag[1].get())->set_host(tremblay);
-      dynamic_cast<simgrid::s4u::Exec*>(dag[2].get())->set_host(jupiter);
-      dynamic_cast<simgrid::s4u::Exec*>(dag[3].get())->set_host(jupiter);
-      dynamic_cast<simgrid::s4u::Exec*>(dag[8].get())->set_host(jupiter);
-    
-      for (const auto& a : dag) {
-         if (auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get())) {
-               auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
-               auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
-               comm->set_source(pred->get_host())->set_destination(succ->get_host());
-         }
-      }
-
-      simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-      XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(), activity.get_start_time(),
-             activity.get_finish_time());
-      });
-
-      e.run();
-      return 0;
-   }
+.. literalinclude:: ../../examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.cpp
+   :language: cpp
 
 The execution of this code should give you the following output:
 
-.. code-block:: bash
-
-   [0.000000] [main/INFO] Activity 'root' is complete (start time: 0.000000, finish time: 0.000000)
-   [33.394394] [main/INFO] Activity 'root->c2' is complete (start time: 0.000000, finish time: 33.394394)
-   [39.832311] [main/INFO] Activity 'root->c1' is complete (start time: 0.000000, finish time: 39.832311)
-   [50.026511] [main/INFO] Activity 'c1' is complete (start time: 39.832311, finish time: 50.026511)
-   [98.928629] [main/INFO] Activity 'c2' is complete (start time: 33.394394, finish time: 98.928629)
-   [125.115689] [main/INFO] Activity 'c1->c3' is complete (start time: 50.026511, finish time: 125.115689)
-   [151.329383] [main/INFO] Activity 'c3' is complete (start time: 125.115689, finish time: 151.329383)
-   [151.743605] [main/INFO] Activity 'c3->end' is complete (start time: 151.329383, finish time: 151.743605)
-   [151.743605] [main/INFO] Activity 'end' is complete (start time: 151.743605, finish time: 151.743605)
+.. literalinclude:: ../../examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.tesh
+   :language: none
+   :lines: 4-
 
 From a JSON file
 ................
@@ -268,82 +186,19 @@ A JSON file describes a workflow in accordance with the `wfformat <https://githu
 
 The following JSON file describes the workflow presented at the beginning of this lab:
 
-.. code-block:: JSON
-
-   {
-      "name": "simple_json",
-      "schemaVersion": "1.0",
-      "workflow": {
-         "makespan": 0,
-         "executedAt": "2023-03-09T00:00:00-00:00",
-         "tasks": [
-         {
-            "name": "c1",
-            "type": "compute",
-            "parents": [],
-            "runtime": 1e9,
-            "machine": "Tremblay"
-         },
-         {
-            "name": "t1",
-            "type": "transfer",
-            "parents": ["c1"],
-            "bytesWritten": 5e8,
-            "machine": "Jupiter"
-         },
-         {
-            "name": "c2",
-            "type": "compute",
-            "parents": [],
-            "runtime": 5e9,
-            "machine": "Jupiter"
-         },
-         {
-            "name": "c3",
-            "type": "compute",
-            "parents": ["t1","c2"],
-         "runtime": 2e9,
-         "machine": "Jupiter"
-         }
-         ],
-         "machines": [
-            {"nodeName": "Tremblay"},
-            {"nodeName": "Jupiter"}
-         ]
-      }
-   }
-
-It can be imported as a vector of Activities into Simgrid using :cpp:func:`create_DAG_from_json(const std::string& filename)`. 
-
-.. code-block:: cpp
-
-   #include "simgrid/s4u.hpp"
+.. literalinclude:: ../../examples/cpp/dag-from-json-simple/dag.json
+   :language: json
 
-   XBT_LOG_NEW_DEFAULT_CATEGORY(main, "Messages specific for this s4u example");
+It can be imported as a vector of Activities into Simgrid using :cpp:func:`simgrid::s4u::create_DAG_from_json`. 
 
-   int main(int argc, char* argv[]) {
-      simgrid::s4u::Engine e(&argc, argv);
-      e.load_platform(argv[1]);
-
-      std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_json(argv[2]);
-
-      simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-      XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(), activity.get_start_time(),
-             activity.get_finish_time());
-      });
-
-      e.run();
-      return 0;
-   }
+.. literalinclude:: ../../examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.cpp
+   :language: cpp
 
 The execution of this code should give you the following output:
 
-.. code-block:: bash
-
-   [10.194200] [main/INFO] Activity 'c1' is complete (start time: 0.000000, finish time: 10.194200)
-   [65.534235] [main/INFO] Activity 'c2' is complete (start time: 0.000000, finish time: 65.534235)
-   [85.283378] [main/INFO] Activity 't1' is complete (start time: 10.194200, finish time: 85.283378)
-   [111.497072] [main/INFO] Activity 'c3' is complete (start time: 85.283378, finish time: 111.497072)
+.. literalinclude:: ../../examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.tesh
+   :language: none
+   :lines: 4-
 
 From a DAX file [deprecated]
 ............................
@@ -352,67 +207,10 @@ A DAX file describes a workflow in accordance with the `Pegasus <http://pegasus.
 
 The following DAX file describes the workflow presented at the beginning of this lab:
 
-.. code-block:: xml
-
-   <?xml version="1.0" encoding="UTF-8"?>
-   <adag xmlns="http://pegasus.isi.edu/schema/DAX" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-      xsi:schemaLocation="http://pegasus.isi.edu/schema/DAX http://pegasus.isi.edu/schema/dax-2.1.xsd"
-      version="2.1">
-      <job id="1" name="c1" runtime="10">
-         <uses file="i1" link="input" register="true" transfer="true" optional="false" type="data" size="2e8"/>
-         <uses file="o1" link="output" register="true" transfer="true" optional="false" type="data" size="5e8"/>
-      </job>
-      <job id="2" name="c2" runtime="50">
-         <uses file="i2" link="input" register="true" transfer="true" optional="false" type="data" size="1e8"/>
-      </job>
-      <job id="3" name="c3" runtime="20">
-         <uses file="o1" link="input" register="true" transfer="true" optional="false" type="data" size="5e8"/>
-         <uses file="o3" link="output" register="true" transfer="true" optional="false" type="data" size="2e8"/>
-      </job>
-      <child ref="3">
-         <parent ref="1"/>
-         <parent ref="2"/>
-      </child>
-   </adag>
-
-It can be imported as a vector of Activities into Simgrid using :cpp:func:`create_DAG_from_DAX(std::string)`.
-
-.. code-block:: cpp
-
-   #include "simgrid/s4u.hpp"
-
-   XBT_LOG_NEW_DEFAULT_CATEGORY(main, "Messages specific for this s4u example");
-
-   int main(int argc, char* argv[]) {
-      simgrid::s4u::Engine e(&argc, argv);
-      e.load_platform(argv[1]);
-
-      std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_DAX(argv[2]);
-
-      simgrid::s4u::Host* tremblay = e.host_by_name("Tremblay");
-      simgrid::s4u::Host* jupiter  = e.host_by_name("Jupiter");
-      simgrid::s4u::Host* fafard  = e.host_by_name("Fafard");
-
-      dynamic_cast<simgrid::s4u::Exec*>(dag[0].get())->set_host(fafard);
-      dynamic_cast<simgrid::s4u::Exec*>(dag[1].get())->set_host(tremblay);
-      dynamic_cast<simgrid::s4u::Exec*>(dag[2].get())->set_host(jupiter);
-      dynamic_cast<simgrid::s4u::Exec*>(dag[3].get())->set_host(jupiter);
-      dynamic_cast<simgrid::s4u::Exec*>(dag[8].get())->set_host(jupiter);
-    
-      for (const auto& a : dag) {
-         if (auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get())) {
-            auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
-            auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
-            comm->set_source(pred->get_host())->set_destination(succ->get_host());
-         }
-      }
-
-      simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-      XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(), activity.get_start_time(),
-         activity.get_finish_time());
-      });
+.. literalinclude:: ../../examples/cpp/dag-from-dax-simple/dag.xml
+   :language: xml
 
-      e.run();
-      return 0;
-   }
+It can be imported as a vector of Activities into Simgrid using :cpp:func:`simgrid::s4u::create_DAG_from_DAX`.
 
+.. literalinclude:: ../../examples/cpp/dag-from-dax-simple/s4u-dag-from-dax-simple.cpp
+   :language: cpp
diff --git a/docs/source/img/battery_degradation.svg b/docs/source/img/battery_degradation.svg
new file mode 100644 (file)
index 0000000..630744b
--- /dev/null
@@ -0,0 +1,1314 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1152pt" height="576pt" viewBox="0 0 1152 576" xmlns="http://www.w3.org/2000/svg" version="1.1">
+ <metadata>
+  <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+   <cc:Work>
+    <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+    <dc:date>2023-03-30T14:42:09.493393</dc:date>
+    <dc:format>image/svg+xml</dc:format>
+    <dc:creator>
+     <cc:Agent>
+      <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title>
+     </cc:Agent>
+    </dc:creator>
+   </cc:Work>
+  </rdf:RDF>
+ </metadata>
+ <defs>
+  <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>
+ </defs>
+ <g id="figure_1">
+  <g id="patch_1">
+   <path d="M 0 576 
+L 1152 576 
+L 1152 0 
+L 0 0 
+z
+" style="fill: #ffffff"/>
+  </g>
+  <g id="axes_1">
+   <g id="patch_2">
+    <path d="M 144 512.64 
+L 1036.8 512.64 
+L 1036.8 69.12 
+L 144 69.12 
+z
+" style="fill: #eaeaf2"/>
+   </g>
+   <g id="matplotlib.axis_1">
+    <g id="xtick_1">
+     <g id="line2d_1">
+      <path d="M 184.581818 512.64 
+L 184.581818 69.12 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_1">
+      <!-- 0 -->
+      <g style="fill: #262626" transform="translate(181.082443 530.498281) scale(0.11 -0.11)">
+       <defs>
+        <path id="DejaVuSans-30" d="M 2034 4250 
+Q 1547 4250 1301 3770 
+Q 1056 3291 1056 2328 
+Q 1056 1369 1301 889 
+Q 1547 409 2034 409 
+Q 2525 409 2770 889 
+Q 3016 1369 3016 2328 
+Q 3016 3291 2770 3770 
+Q 2525 4250 2034 4250 
+z
+M 2034 4750 
+Q 2819 4750 3233 4129 
+Q 3647 3509 3647 2328 
+Q 3647 1150 3233 529 
+Q 2819 -91 2034 -91 
+Q 1250 -91 836 529 
+Q 422 1150 422 2328 
+Q 422 3509 836 4129 
+Q 1250 4750 2034 4750 
+z
+" transform="scale(0.015625)"/>
+       </defs>
+       <use xlink:href="#DejaVuSans-30"/>
+      </g>
+     </g>
+    </g>
+    <g id="xtick_2">
+     <g id="line2d_2">
+      <path d="M 341.1509 512.64 
+L 341.1509 69.12 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_2">
+      <!-- 10000 -->
+      <g style="fill: #262626" transform="translate(323.654025 530.498281) scale(0.11 -0.11)">
+       <defs>
+        <path id="DejaVuSans-31" d="M 794 531 
+L 1825 531 
+L 1825 4091 
+L 703 3866 
+L 703 4441 
+L 1819 4666 
+L 2450 4666 
+L 2450 531 
+L 3481 531 
+L 3481 0 
+L 794 0 
+L 794 531 
+z
+" transform="scale(0.015625)"/>
+       </defs>
+       <use xlink:href="#DejaVuSans-31"/>
+       <use xlink:href="#DejaVuSans-30" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-30" x="127.246094"/>
+       <use xlink:href="#DejaVuSans-30" x="190.869141"/>
+       <use xlink:href="#DejaVuSans-30" x="254.492188"/>
+      </g>
+     </g>
+    </g>
+    <g id="xtick_3">
+     <g id="line2d_3">
+      <path d="M 497.719982 512.64 
+L 497.719982 69.12 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_3">
+      <!-- 20000 -->
+      <g style="fill: #262626" transform="translate(480.223107 530.498281) scale(0.11 -0.11)">
+       <defs>
+        <path id="DejaVuSans-32" d="M 1228 531 
+L 3431 531 
+L 3431 0 
+L 469 0 
+L 469 531 
+Q 828 903 1448 1529 
+Q 2069 2156 2228 2338 
+Q 2531 2678 2651 2914 
+Q 2772 3150 2772 3378 
+Q 2772 3750 2511 3984 
+Q 2250 4219 1831 4219 
+Q 1534 4219 1204 4116 
+Q 875 4013 500 3803 
+L 500 4441 
+Q 881 4594 1212 4672 
+Q 1544 4750 1819 4750 
+Q 2544 4750 2975 4387 
+Q 3406 4025 3406 3419 
+Q 3406 3131 3298 2873 
+Q 3191 2616 2906 2266 
+Q 2828 2175 2409 1742 
+Q 1991 1309 1228 531 
+z
+" transform="scale(0.015625)"/>
+       </defs>
+       <use xlink:href="#DejaVuSans-32"/>
+       <use xlink:href="#DejaVuSans-30" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-30" x="127.246094"/>
+       <use xlink:href="#DejaVuSans-30" x="190.869141"/>
+       <use xlink:href="#DejaVuSans-30" x="254.492188"/>
+      </g>
+     </g>
+    </g>
+    <g id="xtick_4">
+     <g id="line2d_4">
+      <path d="M 654.289063 512.64 
+L 654.289063 69.12 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_4">
+      <!-- 30000 -->
+      <g style="fill: #262626" transform="translate(636.792188 530.498281) scale(0.11 -0.11)">
+       <defs>
+        <path id="DejaVuSans-33" d="M 2597 2516 
+Q 3050 2419 3304 2112 
+Q 3559 1806 3559 1356 
+Q 3559 666 3084 287 
+Q 2609 -91 1734 -91 
+Q 1441 -91 1130 -33 
+Q 819 25 488 141 
+L 488 750 
+Q 750 597 1062 519 
+Q 1375 441 1716 441 
+Q 2309 441 2620 675 
+Q 2931 909 2931 1356 
+Q 2931 1769 2642 2001 
+Q 2353 2234 1838 2234 
+L 1294 2234 
+L 1294 2753 
+L 1863 2753 
+Q 2328 2753 2575 2939 
+Q 2822 3125 2822 3475 
+Q 2822 3834 2567 4026 
+Q 2313 4219 1838 4219 
+Q 1578 4219 1281 4162 
+Q 984 4106 628 3988 
+L 628 4550 
+Q 988 4650 1302 4700 
+Q 1616 4750 1894 4750 
+Q 2613 4750 3031 4423 
+Q 3450 4097 3450 3541 
+Q 3450 3153 3228 2886 
+Q 3006 2619 2597 2516 
+z
+" transform="scale(0.015625)"/>
+       </defs>
+       <use xlink:href="#DejaVuSans-33"/>
+       <use xlink:href="#DejaVuSans-30" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-30" x="127.246094"/>
+       <use xlink:href="#DejaVuSans-30" x="190.869141"/>
+       <use xlink:href="#DejaVuSans-30" x="254.492188"/>
+      </g>
+     </g>
+    </g>
+    <g id="xtick_5">
+     <g id="line2d_5">
+      <path d="M 810.858145 512.64 
+L 810.858145 69.12 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_5">
+      <!-- 40000 -->
+      <g style="fill: #262626" transform="translate(793.36127 530.498281) scale(0.11 -0.11)">
+       <defs>
+        <path id="DejaVuSans-34" d="M 2419 4116 
+L 825 1625 
+L 2419 1625 
+L 2419 4116 
+z
+M 2253 4666 
+L 3047 4666 
+L 3047 1625 
+L 3713 1625 
+L 3713 1100 
+L 3047 1100 
+L 3047 0 
+L 2419 0 
+L 2419 1100 
+L 313 1100 
+L 313 1709 
+L 2253 4666 
+z
+" transform="scale(0.015625)"/>
+       </defs>
+       <use xlink:href="#DejaVuSans-34"/>
+       <use xlink:href="#DejaVuSans-30" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-30" x="127.246094"/>
+       <use xlink:href="#DejaVuSans-30" x="190.869141"/>
+       <use xlink:href="#DejaVuSans-30" x="254.492188"/>
+      </g>
+     </g>
+    </g>
+    <g id="xtick_6">
+     <g id="line2d_6">
+      <path d="M 967.427227 512.64 
+L 967.427227 69.12 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_6">
+      <!-- 50000 -->
+      <g style="fill: #262626" transform="translate(949.930352 530.498281) scale(0.11 -0.11)">
+       <defs>
+        <path id="DejaVuSans-35" d="M 691 4666 
+L 3169 4666 
+L 3169 4134 
+L 1269 4134 
+L 1269 2991 
+Q 1406 3038 1543 3061 
+Q 1681 3084 1819 3084 
+Q 2600 3084 3056 2656 
+Q 3513 2228 3513 1497 
+Q 3513 744 3044 326 
+Q 2575 -91 1722 -91 
+Q 1428 -91 1123 -41 
+Q 819 9 494 109 
+L 494 744 
+Q 775 591 1075 516 
+Q 1375 441 1709 441 
+Q 2250 441 2565 725 
+Q 2881 1009 2881 1497 
+Q 2881 1984 2565 2268 
+Q 2250 2553 1709 2553 
+Q 1456 2553 1204 2497 
+Q 953 2441 691 2322 
+L 691 4666 
+z
+" transform="scale(0.015625)"/>
+       </defs>
+       <use xlink:href="#DejaVuSans-35"/>
+       <use xlink:href="#DejaVuSans-30" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-30" x="127.246094"/>
+       <use xlink:href="#DejaVuSans-30" x="190.869141"/>
+       <use xlink:href="#DejaVuSans-30" x="254.492188"/>
+      </g>
+     </g>
+    </g>
+    <g id="text_7">
+     <!-- Time -->
+     <g style="fill: #262626" transform="translate(575.719687 545.904063) scale(0.12 -0.12)">
+      <defs>
+       <path id="DejaVuSans-54" d="M -19 4666 
+L 3928 4666 
+L 3928 4134 
+L 2272 4134 
+L 2272 0 
+L 1638 0 
+L 1638 4134 
+L -19 4134 
+L -19 4666 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-69" d="M 603 3500 
+L 1178 3500 
+L 1178 0 
+L 603 0 
+L 603 3500 
+z
+M 603 4863 
+L 1178 4863 
+L 1178 4134 
+L 603 4134 
+L 603 4863 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-6d" d="M 3328 2828 
+Q 3544 3216 3844 3400 
+Q 4144 3584 4550 3584 
+Q 5097 3584 5394 3201 
+Q 5691 2819 5691 2113 
+L 5691 0 
+L 5113 0 
+L 5113 2094 
+Q 5113 2597 4934 2840 
+Q 4756 3084 4391 3084 
+Q 3944 3084 3684 2787 
+Q 3425 2491 3425 1978 
+L 3425 0 
+L 2847 0 
+L 2847 2094 
+Q 2847 2600 2669 2842 
+Q 2491 3084 2119 3084 
+Q 1678 3084 1418 2786 
+Q 1159 2488 1159 1978 
+L 1159 0 
+L 581 0 
+L 581 3500 
+L 1159 3500 
+L 1159 2956 
+Q 1356 3278 1631 3431 
+Q 1906 3584 2284 3584 
+Q 2666 3584 2933 3390 
+Q 3200 3197 3328 2828 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-65" d="M 3597 1894 
+L 3597 1613 
+L 953 1613 
+Q 991 1019 1311 708 
+Q 1631 397 2203 397 
+Q 2534 397 2845 478 
+Q 3156 559 3463 722 
+L 3463 178 
+Q 3153 47 2828 -22 
+Q 2503 -91 2169 -91 
+Q 1331 -91 842 396 
+Q 353 884 353 1716 
+Q 353 2575 817 3079 
+Q 1281 3584 2069 3584 
+Q 2775 3584 3186 3129 
+Q 3597 2675 3597 1894 
+z
+M 3022 2063 
+Q 3016 2534 2758 2815 
+Q 2500 3097 2075 3097 
+Q 1594 3097 1305 2825 
+Q 1016 2553 972 2059 
+L 3022 2063 
+z
+" transform="scale(0.015625)"/>
+      </defs>
+      <use xlink:href="#DejaVuSans-54"/>
+      <use xlink:href="#DejaVuSans-69" x="57.958984"/>
+      <use xlink:href="#DejaVuSans-6d" x="85.742188"/>
+      <use xlink:href="#DejaVuSans-65" x="183.154297"/>
+     </g>
+    </g>
+   </g>
+   <g id="matplotlib.axis_2">
+    <g id="ytick_1">
+     <g id="line2d_7">
+      <path d="M 144 492.488871 
+L 1036.8 492.488871 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_8">
+      <!-- 0.0 -->
+      <g style="fill: #262626" transform="translate(117.006563 496.668011) scale(0.11 -0.11)">
+       <defs>
+        <path id="DejaVuSans-2e" d="M 684 794 
+L 1344 794 
+L 1344 0 
+L 684 0 
+L 684 794 
+z
+" transform="scale(0.015625)"/>
+       </defs>
+       <use xlink:href="#DejaVuSans-30"/>
+       <use xlink:href="#DejaVuSans-2e" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-30" x="95.410156"/>
+      </g>
+     </g>
+    </g>
+    <g id="ytick_2">
+     <g id="line2d_8">
+      <path d="M 144 411.847096 
+L 1036.8 411.847096 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_9">
+      <!-- 0.2 -->
+      <g style="fill: #262626" transform="translate(117.006563 416.026237) scale(0.11 -0.11)">
+       <use xlink:href="#DejaVuSans-30"/>
+       <use xlink:href="#DejaVuSans-2e" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-32" x="95.410156"/>
+      </g>
+     </g>
+    </g>
+    <g id="ytick_3">
+     <g id="line2d_9">
+      <path d="M 144 331.205322 
+L 1036.8 331.205322 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_10">
+      <!-- 0.4 -->
+      <g style="fill: #262626" transform="translate(117.006563 335.384463) scale(0.11 -0.11)">
+       <use xlink:href="#DejaVuSans-30"/>
+       <use xlink:href="#DejaVuSans-2e" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-34" x="95.410156"/>
+      </g>
+     </g>
+    </g>
+    <g id="ytick_4">
+     <g id="line2d_10">
+      <path d="M 144 250.563548 
+L 1036.8 250.563548 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_11">
+      <!-- 0.6 -->
+      <g style="fill: #262626" transform="translate(117.006563 254.742689) scale(0.11 -0.11)">
+       <defs>
+        <path id="DejaVuSans-36" d="M 2113 2584 
+Q 1688 2584 1439 2293 
+Q 1191 2003 1191 1497 
+Q 1191 994 1439 701 
+Q 1688 409 2113 409 
+Q 2538 409 2786 701 
+Q 3034 994 3034 1497 
+Q 3034 2003 2786 2293 
+Q 2538 2584 2113 2584 
+z
+M 3366 4563 
+L 3366 3988 
+Q 3128 4100 2886 4159 
+Q 2644 4219 2406 4219 
+Q 1781 4219 1451 3797 
+Q 1122 3375 1075 2522 
+Q 1259 2794 1537 2939 
+Q 1816 3084 2150 3084 
+Q 2853 3084 3261 2657 
+Q 3669 2231 3669 1497 
+Q 3669 778 3244 343 
+Q 2819 -91 2113 -91 
+Q 1303 -91 875 529 
+Q 447 1150 447 2328 
+Q 447 3434 972 4092 
+Q 1497 4750 2381 4750 
+Q 2619 4750 2861 4703 
+Q 3103 4656 3366 4563 
+z
+" transform="scale(0.015625)"/>
+       </defs>
+       <use xlink:href="#DejaVuSans-30"/>
+       <use xlink:href="#DejaVuSans-2e" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-36" x="95.410156"/>
+      </g>
+     </g>
+    </g>
+    <g id="ytick_5">
+     <g id="line2d_11">
+      <path d="M 144 169.921774 
+L 1036.8 169.921774 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_12">
+      <!-- 0.8 -->
+      <g style="fill: #262626" transform="translate(117.006563 174.100915) scale(0.11 -0.11)">
+       <defs>
+        <path id="DejaVuSans-38" d="M 2034 2216 
+Q 1584 2216 1326 1975 
+Q 1069 1734 1069 1313 
+Q 1069 891 1326 650 
+Q 1584 409 2034 409 
+Q 2484 409 2743 651 
+Q 3003 894 3003 1313 
+Q 3003 1734 2745 1975 
+Q 2488 2216 2034 2216 
+z
+M 1403 2484 
+Q 997 2584 770 2862 
+Q 544 3141 544 3541 
+Q 544 4100 942 4425 
+Q 1341 4750 2034 4750 
+Q 2731 4750 3128 4425 
+Q 3525 4100 3525 3541 
+Q 3525 3141 3298 2862 
+Q 3072 2584 2669 2484 
+Q 3125 2378 3379 2068 
+Q 3634 1759 3634 1313 
+Q 3634 634 3220 271 
+Q 2806 -91 2034 -91 
+Q 1263 -91 848 271 
+Q 434 634 434 1313 
+Q 434 1759 690 2068 
+Q 947 2378 1403 2484 
+z
+M 1172 3481 
+Q 1172 3119 1398 2916 
+Q 1625 2713 2034 2713 
+Q 2441 2713 2670 2916 
+Q 2900 3119 2900 3481 
+Q 2900 3844 2670 4047 
+Q 2441 4250 2034 4250 
+Q 1625 4250 1398 4047 
+Q 1172 3844 1172 3481 
+z
+" transform="scale(0.015625)"/>
+       </defs>
+       <use xlink:href="#DejaVuSans-30"/>
+       <use xlink:href="#DejaVuSans-2e" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-38" x="95.410156"/>
+      </g>
+     </g>
+    </g>
+    <g id="ytick_6">
+     <g id="line2d_12">
+      <path d="M 144 89.28 
+L 1036.8 89.28 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #ffffff; stroke-linecap: round"/>
+     </g>
+     <g id="text_13">
+      <!-- 1.0 -->
+      <g style="fill: #262626" transform="translate(117.006563 93.459141) scale(0.11 -0.11)">
+       <use xlink:href="#DejaVuSans-31"/>
+       <use xlink:href="#DejaVuSans-2e" x="63.623047"/>
+       <use xlink:href="#DejaVuSans-30" x="95.410156"/>
+      </g>
+     </g>
+    </g>
+    <g id="text_14">
+     <!-- Value -->
+     <g style="fill: #262626" transform="translate(110.510937 307.3575) rotate(-90) scale(0.12 -0.12)">
+      <defs>
+       <path id="DejaVuSans-56" d="M 1831 0 
+L 50 4666 
+L 709 4666 
+L 2188 738 
+L 3669 4666 
+L 4325 4666 
+L 2547 0 
+L 1831 0 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-61" d="M 2194 1759 
+Q 1497 1759 1228 1600 
+Q 959 1441 959 1056 
+Q 959 750 1161 570 
+Q 1363 391 1709 391 
+Q 2188 391 2477 730 
+Q 2766 1069 2766 1631 
+L 2766 1759 
+L 2194 1759 
+z
+M 3341 1997 
+L 3341 0 
+L 2766 0 
+L 2766 531 
+Q 2569 213 2275 61 
+Q 1981 -91 1556 -91 
+Q 1019 -91 701 211 
+Q 384 513 384 1019 
+Q 384 1609 779 1909 
+Q 1175 2209 1959 2209 
+L 2766 2209 
+L 2766 2266 
+Q 2766 2663 2505 2880 
+Q 2244 3097 1772 3097 
+Q 1472 3097 1187 3025 
+Q 903 2953 641 2809 
+L 641 3341 
+Q 956 3463 1253 3523 
+Q 1550 3584 1831 3584 
+Q 2591 3584 2966 3190 
+Q 3341 2797 3341 1997 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-6c" d="M 603 4863 
+L 1178 4863 
+L 1178 0 
+L 603 0 
+L 603 4863 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-75" d="M 544 1381 
+L 544 3500 
+L 1119 3500 
+L 1119 1403 
+Q 1119 906 1312 657 
+Q 1506 409 1894 409 
+Q 2359 409 2629 706 
+Q 2900 1003 2900 1516 
+L 2900 3500 
+L 3475 3500 
+L 3475 0 
+L 2900 0 
+L 2900 538 
+Q 2691 219 2414 64 
+Q 2138 -91 1772 -91 
+Q 1169 -91 856 284 
+Q 544 659 544 1381 
+z
+M 1991 3584 
+L 1991 3584 
+z
+" transform="scale(0.015625)"/>
+      </defs>
+      <use xlink:href="#DejaVuSans-56"/>
+      <use xlink:href="#DejaVuSans-61" x="60.658203"/>
+      <use xlink:href="#DejaVuSans-6c" x="121.9375"/>
+      <use xlink:href="#DejaVuSans-75" x="149.720703"/>
+      <use xlink:href="#DejaVuSans-65" x="213.099609"/>
+     </g>
+    </g>
+   </g>
+   <g id="PolyCollection_1"/>
+   <g id="PolyCollection_2"/>
+   <g id="line2d_13">
+    <path d="M 184.581818 169.921774 
+L 187.96371 411.847096 
+L 191.33433 169.921774 
+L 194.693713 411.847096 
+L 198.041899 169.921774 
+L 201.378924 411.847096 
+L 204.704826 169.921774 
+L 208.019642 411.847096 
+L 211.323408 169.921774 
+L 214.616161 411.847096 
+L 217.897939 169.921774 
+L 221.168777 411.847096 
+L 224.428713 169.921774 
+L 227.677782 411.847096 
+L 230.916021 169.921774 
+L 234.143466 411.847096 
+L 237.360153 169.921774 
+L 240.566117 411.847096 
+L 243.761395 169.921774 
+L 246.946022 411.847096 
+L 250.120033 169.921774 
+L 253.283465 411.847096 
+L 256.436351 169.921774 
+L 259.578728 411.847096 
+L 262.710631 169.921774 
+L 265.832094 411.847096 
+L 268.943152 169.921774 
+L 272.043839 411.847096 
+L 275.134191 169.921774 
+L 278.214242 411.847096 
+L 281.284026 169.921774 
+L 284.343578 411.847096 
+L 287.392931 169.921774 
+L 290.432119 411.847096 
+L 293.461177 169.921774 
+L 296.480138 411.847096 
+L 299.489036 169.921774 
+L 302.487904 411.847096 
+L 305.476776 169.921774 
+L 308.455685 411.847096 
+L 311.424664 169.921774 
+L 314.383747 411.847096 
+L 317.332966 169.921774 
+L 320.272354 411.847096 
+L 323.201945 169.921774 
+L 326.12177 411.847096 
+L 329.031862 169.921774 
+L 331.932254 411.847096 
+L 334.822978 169.921774 
+L 337.704066 411.847096 
+L 340.575551 169.921774 
+L 343.437464 411.847096 
+L 346.289838 169.921774 
+L 349.132703 411.847096 
+L 351.966092 169.921774 
+L 354.790037 411.847096 
+L 357.604568 169.921774 
+L 360.409718 411.847096 
+L 363.205517 169.921774 
+L 365.991997 411.847096 
+L 368.769188 169.921774 
+L 371.537123 411.847096 
+L 374.295831 169.921774 
+L 377.045343 411.847096 
+L 379.78569 169.921774 
+L 382.516902 411.847096 
+L 385.239011 169.921774 
+L 387.952046 411.847096 
+L 390.656037 169.921774 
+L 393.351015 411.847096 
+L 396.03701 169.921774 
+L 398.714052 411.847096 
+L 401.38217 169.921774 
+L 404.041394 411.847096 
+L 406.691754 169.921774 
+L 409.33328 411.847096 
+L 411.966001 169.921774 
+L 414.589945 411.847096 
+L 417.205144 169.921774 
+L 419.811625 411.847096 
+L 422.409418 169.921774 
+L 424.998551 411.847096 
+L 427.579054 169.921774 
+L 430.150956 411.847096 
+L 432.714284 169.921774 
+L 435.269068 411.847096 
+L 437.815336 169.921774 
+L 440.353116 411.847096 
+L 442.882438 169.921774 
+L 445.403328 411.847096 
+L 447.915815 169.921774 
+L 450.419927 411.847096 
+L 452.915692 169.921774 
+L 455.403138 411.847096 
+L 457.882293 169.921774 
+L 460.353183 411.847096 
+L 462.815837 169.921774 
+L 465.270283 411.847096 
+L 467.716547 169.921774 
+L 470.154657 411.847096 
+L 472.584639 169.921774 
+L 475.006522 411.847096 
+L 477.420332 169.921774 
+L 479.826096 411.847096 
+L 482.22384 169.921774 
+L 484.613592 411.847096 
+L 486.995379 169.921774 
+L 489.369225 411.847096 
+L 491.73516 169.921774 
+L 494.093207 411.847096 
+L 496.443395 169.921774 
+L 498.785748 411.847096 
+L 501.120294 169.921774 
+L 503.447058 411.847096 
+L 505.766066 169.921774 
+L 508.077344 411.847096 
+L 510.380918 169.921774 
+L 512.676813 411.847096 
+L 514.965055 169.921774 
+L 517.24567 411.847096 
+L 519.518683 169.921774 
+L 521.784119 411.847096 
+L 524.042003 169.921774 
+L 526.292361 411.847096 
+L 528.535218 169.921774 
+L 530.770599 411.847096 
+L 532.998529 169.921774 
+L 535.219032 411.847096 
+L 537.432133 169.921774 
+L 539.637858 411.847096 
+L 541.83623 169.921774 
+L 544.027274 411.847096 
+L 546.211014 169.921774 
+L 548.387476 411.847096 
+L 550.556683 169.921774 
+L 552.718659 411.847096 
+L 554.873428 169.921774 
+L 557.021015 411.847096 
+L 559.161443 169.921774 
+L 561.294736 411.847096 
+L 563.420919 169.921774 
+L 565.540014 411.847096 
+L 567.652045 169.921774 
+L 569.757037 411.847096 
+L 571.855012 169.921774 
+L 573.945993 411.847096 
+L 576.030005 169.921774 
+L 578.10707 411.847096 
+L 580.177211 169.921774 
+L 582.240452 411.847096 
+L 584.296815 169.921774 
+L 586.346324 411.847096 
+L 588.389001 169.921774 
+L 590.424869 411.847096 
+L 592.453951 169.921774 
+L 594.47627 411.847096 
+L 596.491847 169.921774 
+L 598.500706 411.847096 
+L 600.502868 169.921774 
+L 602.498357 411.847096 
+L 604.487194 169.921774 
+L 606.469402 411.847096 
+L 608.445002 169.921774 
+L 610.414017 411.847096 
+L 612.376468 169.921774 
+L 614.332378 411.847096 
+L 616.281769 169.921774 
+L 618.224661 411.847096 
+L 620.161077 169.921774 
+L 622.091038 411.847096 
+L 624.014566 169.921774 
+L 625.931683 411.847096 
+L 627.842409 169.921774 
+L 629.746766 411.847096 
+L 631.644775 169.921774 
+L 633.536457 411.847096 
+L 635.421834 169.921774 
+L 637.300926 411.847096 
+L 639.173754 169.921774 
+L 641.04034 411.847096 
+L 642.900704 169.921774 
+L 644.754866 411.847096 
+L 646.602848 169.921774 
+L 648.44467 411.847096 
+L 650.280353 169.921774 
+L 652.109917 411.847096 
+L 653.933382 169.921774 
+L 655.750769 411.847096 
+L 657.562098 169.921774 
+L 659.367389 411.847096 
+L 661.166663 169.921774 
+L 662.959939 411.847096 
+L 664.747237 169.921774 
+L 666.528578 411.847096 
+L 668.303981 169.921774 
+L 670.073466 411.847096 
+L 671.837052 169.921774 
+L 673.59476 411.847096 
+L 675.346609 169.921774 
+L 677.092619 411.847096 
+L 678.832808 169.921774 
+L 680.567197 411.847096 
+L 682.295805 169.921774 
+L 684.01865 411.847096 
+L 685.735753 169.921774 
+L 687.447132 411.847096 
+L 689.152807 169.921774 
+L 690.852796 411.847096 
+L 692.547118 169.921774 
+L 694.235792 411.847096 
+L 695.918838 169.921774 
+L 697.596273 411.847096 
+L 699.268117 169.921774 
+L 700.934388 411.847096 
+L 702.595105 169.921774 
+L 704.250287 411.847096 
+L 705.899951 169.921774 
+L 707.544116 411.847096 
+L 709.1828 169.921774 
+L 710.816022 411.847096 
+L 712.4438 169.921774 
+L 714.066153 411.847096 
+L 715.683097 169.921774 
+L 717.294652 411.847096 
+L 718.900834 169.921774 
+L 720.501663 411.847096 
+L 722.097156 169.921774 
+L 723.68733 411.847096 
+L 725.272204 169.921774 
+L 726.851795 411.847096 
+L 728.42612 169.921774 
+L 729.995198 411.847096 
+L 731.559046 169.921774 
+L 733.117681 411.847096 
+L 734.67112 169.921774 
+L 736.219381 411.847096 
+L 737.762481 169.921774 
+L 739.300438 411.847096 
+L 740.833268 169.921774 
+L 742.360989 411.847096 
+L 743.883617 169.921774 
+L 745.40117 411.847096 
+L 746.913664 169.921774 
+L 748.421117 411.847096 
+L 749.923545 169.921774 
+L 751.420964 411.847096 
+L 752.913393 169.921774 
+L 754.400846 411.847096 
+L 755.883342 169.921774 
+L 757.360896 411.847096 
+L 758.833524 169.921774 
+L 760.301244 411.847096 
+L 761.764071 169.921774 
+L 763.222023 411.847096 
+L 764.675114 169.921774 
+L 766.123362 411.847096 
+L 767.566782 169.921774 
+L 769.005391 411.847096 
+L 770.439205 169.921774 
+L 771.868239 411.847096 
+L 773.29251 169.921774 
+L 774.712033 411.847096 
+L 776.126824 169.921774 
+L 777.5369 411.847096 
+L 778.942275 169.921774 
+L 780.342966 411.847096 
+L 781.738987 169.921774 
+L 783.130356 411.847096 
+L 784.517086 169.921774 
+L 785.899194 411.847096 
+L 787.276695 169.921774 
+L 788.649604 411.847096 
+L 790.017937 169.921774 
+L 791.381709 411.847096 
+L 792.740935 169.921774 
+L 794.09563 411.847096 
+L 795.445809 169.921774 
+L 796.791488 411.847096 
+L 798.132681 169.921774 
+L 799.469404 411.847096 
+L 800.801671 169.921774 
+L 802.129497 411.847096 
+L 803.452897 169.921774 
+L 804.771885 411.847096 
+L 806.086477 169.921774 
+L 807.396687 411.847096 
+L 808.70253 169.921774 
+L 810.00402 411.847096 
+L 811.301171 169.921774 
+L 812.593999 411.847096 
+L 813.882517 169.921774 
+L 815.16674 411.847096 
+L 816.446683 169.921774 
+L 817.722359 411.847096 
+L 818.993782 169.921774 
+L 820.260968 411.847096 
+L 821.52393 169.921774 
+L 822.782681 411.847096 
+L 824.037237 169.921774 
+L 825.287611 411.847096 
+L 826.533818 169.921774 
+L 827.77587 411.847096 
+L 829.013782 169.921774 
+L 830.247567 411.847096 
+L 831.47724 169.921774 
+L 832.702815 411.847096 
+L 833.924303 169.921774 
+L 835.141721 411.847096 
+L 836.35508 169.921774 
+L 837.564394 411.847096 
+L 838.769678 169.921774 
+L 839.970944 411.847096 
+L 841.168206 169.921774 
+L 842.361477 411.847096 
+L 843.55077 169.921774 
+L 844.736099 411.847096 
+L 845.917477 169.921774 
+L 847.094917 411.847096 
+L 848.268432 169.921774 
+L 849.438035 411.847096 
+L 850.60374 169.921774 
+L 851.765559 411.847096 
+L 852.923506 169.921774 
+L 854.077592 411.847096 
+L 855.227832 169.921774 
+L 856.374237 411.847096 
+L 857.516821 169.921774 
+L 858.655597 411.847096 
+L 859.790576 169.921774 
+L 860.921773 411.847096 
+L 862.049198 169.921774 
+L 863.172866 411.847096 
+L 864.292788 169.921774 
+L 865.408977 411.847096 
+L 866.521445 169.921774 
+L 867.630205 411.847096 
+L 868.735269 169.921774 
+L 869.83665 411.847096 
+L 870.934359 169.921774 
+L 872.02841 411.847096 
+L 873.118813 169.921774 
+L 874.205582 411.847096 
+L 875.288728 169.921774 
+L 876.368264 411.847096 
+L 877.444202 169.921774 
+L 878.516552 411.847096 
+L 879.585329 169.921774 
+L 880.650543 411.847096 
+L 881.712206 169.921774 
+L 882.77033 411.847096 
+L 883.824927 169.921774 
+L 884.876009 411.847096 
+L 885.923587 169.921774 
+L 886.967673 411.847096 
+L 888.008279 169.921774 
+L 889.045417 411.847096 
+L 890.079097 169.921774 
+L 891.109331 411.847096 
+L 892.136132 169.921774 
+L 893.15951 411.847096 
+L 894.179476 169.921774 
+L 895.196043 411.847096 
+L 896.209221 169.921774 
+L 897.219022 411.847096 
+L 898.225457 169.921774 
+L 899.228537 411.847096 
+L 900.228273 169.921774 
+L 901.224677 411.847096 
+L 902.21776 169.921774 
+L 903.207532 411.847096 
+L 904.194005 169.921774 
+L 905.17719 411.847096 
+L 906.157098 169.921774 
+L 907.133739 411.847096 
+L 908.107125 169.921774 
+L 909.077266 411.847096 
+L 910.044173 169.921774 
+L 911.007857 411.847096 
+L 911.968329 169.921774 
+L 912.9256 411.847096 
+L 913.879679 169.921774 
+L 914.830579 411.847096 
+L 915.778308 169.921774 
+L 916.722879 411.847096 
+L 917.664301 169.921774 
+L 918.602585 411.847096 
+L 919.537741 169.921774 
+L 920.46978 411.847096 
+L 921.398712 169.921774 
+L 922.324548 411.847096 
+L 923.247298 169.921774 
+L 924.166972 411.847096 
+L 925.08358 169.921774 
+L 925.997133 411.847096 
+L 926.907641 169.921774 
+L 927.815114 411.847096 
+L 928.719562 169.921774 
+L 929.620995 411.847096 
+L 930.519423 169.921774 
+L 931.414856 411.847096 
+L 932.307305 169.921774 
+L 933.196779 411.847096 
+L 934.083288 169.921774 
+L 934.966842 411.847096 
+L 935.847451 169.921774 
+L 936.725124 411.847096 
+L 937.599872 169.921774 
+L 938.471704 411.847096 
+L 939.34063 169.921774 
+L 940.206659 411.847096 
+L 941.069802 169.921774 
+L 941.930067 411.847096 
+L 942.787465 169.921774 
+L 943.642005 411.847096 
+L 944.493697 169.921774 
+L 945.342549 411.847096 
+L 946.188572 169.921774 
+L 947.031775 411.847096 
+L 947.872168 169.921774 
+L 948.709759 411.847096 
+L 949.544558 169.921774 
+L 950.376574 411.847096 
+L 951.205817 169.921774 
+L 952.032296 411.847096 
+L 952.85602 169.921774 
+L 953.676998 411.847096 
+L 954.49524 169.921774 
+L 955.310754 411.847096 
+L 956.123549 169.921774 
+L 956.933636 411.847096 
+L 957.741022 169.921774 
+L 958.545717 411.847096 
+L 959.347729 169.921774 
+L 960.147068 411.847096 
+L 960.943743 169.921774 
+L 961.737762 411.847096 
+L 962.529134 169.921774 
+L 963.317869 411.847096 
+L 964.103974 169.921774 
+L 964.887459 411.847096 
+L 965.668333 169.921774 
+L 966.446603 411.847096 
+L 967.222279 169.921774 
+L 967.99537 411.847096 
+L 968.765884 169.921774 
+L 969.533829 411.847096 
+L 970.299214 169.921774 
+L 971.062048 411.847096 
+L 971.82234 169.921774 
+L 972.580097 411.847096 
+L 973.335328 169.921774 
+L 974.088042 411.847096 
+L 974.838247 169.921774 
+L 975.585951 411.847096 
+L 976.331163 169.921774 
+L 977.07389 411.847096 
+L 977.814142 169.921774 
+L 978.551927 411.847096 
+L 979.287252 169.921774 
+L 980.020126 411.847096 
+L 980.750557 169.921774 
+L 981.478553 411.847096 
+L 982.204123 169.921774 
+L 982.927274 411.847096 
+L 983.648015 169.921774 
+L 984.366353 411.847096 
+L 985.082297 169.921774 
+L 985.795854 411.847096 
+L 986.507033 169.921774 
+L 987.215841 411.847096 
+L 987.922286 169.921774 
+L 988.626377 411.847096 
+L 989.32812 169.921774 
+L 990.027525 411.847096 
+L 990.724598 169.921774 
+L 991.419348 411.847096 
+L 992.111781 169.921774 
+L 992.801907 411.847096 
+L 993.489732 169.921774 
+L 994.175265 411.847096 
+L 994.858512 169.921774 
+L 995.539482 411.847096 
+L 996.218182 169.921774 
+L 996.218182 169.921774 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #4c72b0; stroke-width: 1.5; stroke-linecap: round"/>
+   </g>
+   <g id="line2d_14">
+    <path d="M 184.581818 89.28 
+L 996.218182 492.48 
+L 996.218182 492.48 
+" clip-path="url(#pb647630257)" style="fill: none; stroke: #dd8452; stroke-width: 1.5; stroke-linecap: round"/>
+   </g>
+   <g id="line2d_15"/>
+   <g id="line2d_16"/>
+   <g id="patch_3">
+    <path d="M 144 512.64 
+L 144 69.12 
+" style="fill: none; stroke: #ffffff; stroke-width: 1.25; stroke-linejoin: miter; stroke-linecap: square"/>
+   </g>
+   <g id="patch_4">
+    <path d="M 1036.8 512.64 
+L 1036.8 69.12 
+" style="fill: none; stroke: #ffffff; stroke-width: 1.25; stroke-linejoin: miter; stroke-linecap: square"/>
+   </g>
+   <g id="patch_5">
+    <path d="M 144 512.64 
+L 1036.8 512.64 
+" style="fill: none; stroke: #ffffff; stroke-width: 1.25; stroke-linejoin: miter; stroke-linecap: square"/>
+   </g>
+   <g id="patch_6">
+    <path d="M 144 69.12 
+L 1036.8 69.12 
+" style="fill: none; stroke: #ffffff; stroke-width: 1.25; stroke-linejoin: miter; stroke-linecap: square"/>
+   </g>
+   <g id="legend_1">
+    <g id="patch_7">
+     <path d="M 965.418125 127.325625 
+L 1029.1 127.325625 
+Q 1031.3 127.325625 1031.3 125.125625 
+L 1031.3 76.82 
+Q 1031.3 74.62 1029.1 74.62 
+L 965.418125 74.62 
+Q 963.218125 74.62 963.218125 76.82 
+L 963.218125 125.125625 
+Q 963.218125 127.325625 965.418125 127.325625 
+z
+" style="fill: #eaeaf2; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter"/>
+    </g>
+    <g id="text_15">
+     <!-- SoC - SoH -->
+     <g style="fill: #262626" transform="translate(967.618125 88.138125) scale(0.12 -0.12)">
+      <defs>
+       <path id="DejaVuSans-53" d="M 3425 4513 
+L 3425 3897 
+Q 3066 4069 2747 4153 
+Q 2428 4238 2131 4238 
+Q 1616 4238 1336 4038 
+Q 1056 3838 1056 3469 
+Q 1056 3159 1242 3001 
+Q 1428 2844 1947 2747 
+L 2328 2669 
+Q 3034 2534 3370 2195 
+Q 3706 1856 3706 1288 
+Q 3706 609 3251 259 
+Q 2797 -91 1919 -91 
+Q 1588 -91 1214 -16 
+Q 841 59 441 206 
+L 441 856 
+Q 825 641 1194 531 
+Q 1563 422 1919 422 
+Q 2459 422 2753 634 
+Q 3047 847 3047 1241 
+Q 3047 1584 2836 1778 
+Q 2625 1972 2144 2069 
+L 1759 2144 
+Q 1053 2284 737 2584 
+Q 422 2884 422 3419 
+Q 422 4038 858 4394 
+Q 1294 4750 2059 4750 
+Q 2388 4750 2728 4690 
+Q 3069 4631 3425 4513 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-6f" d="M 1959 3097 
+Q 1497 3097 1228 2736 
+Q 959 2375 959 1747 
+Q 959 1119 1226 758 
+Q 1494 397 1959 397 
+Q 2419 397 2687 759 
+Q 2956 1122 2956 1747 
+Q 2956 2369 2687 2733 
+Q 2419 3097 1959 3097 
+z
+M 1959 3584 
+Q 2709 3584 3137 3096 
+Q 3566 2609 3566 1747 
+Q 3566 888 3137 398 
+Q 2709 -91 1959 -91 
+Q 1206 -91 779 398 
+Q 353 888 353 1747 
+Q 353 2609 779 3096 
+Q 1206 3584 1959 3584 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-43" d="M 4122 4306 
+L 4122 3641 
+Q 3803 3938 3442 4084 
+Q 3081 4231 2675 4231 
+Q 1875 4231 1450 3742 
+Q 1025 3253 1025 2328 
+Q 1025 1406 1450 917 
+Q 1875 428 2675 428 
+Q 3081 428 3442 575 
+Q 3803 722 4122 1019 
+L 4122 359 
+Q 3791 134 3420 21 
+Q 3050 -91 2638 -91 
+Q 1578 -91 968 557 
+Q 359 1206 359 2328 
+Q 359 3453 968 4101 
+Q 1578 4750 2638 4750 
+Q 3056 4750 3426 4639 
+Q 3797 4528 4122 4306 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-20" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-2d" d="M 313 2009 
+L 1997 2009 
+L 1997 1497 
+L 313 1497 
+L 313 2009 
+z
+" transform="scale(0.015625)"/>
+       <path id="DejaVuSans-48" d="M 628 4666 
+L 1259 4666 
+L 1259 2753 
+L 3553 2753 
+L 3553 4666 
+L 4184 4666 
+L 4184 0 
+L 3553 0 
+L 3553 2222 
+L 1259 2222 
+L 1259 0 
+L 628 0 
+L 628 4666 
+z
+" transform="scale(0.015625)"/>
+      </defs>
+      <use xlink:href="#DejaVuSans-53"/>
+      <use xlink:href="#DejaVuSans-6f" x="63.476562"/>
+      <use xlink:href="#DejaVuSans-43" x="124.658203"/>
+      <use xlink:href="#DejaVuSans-20" x="194.482422"/>
+      <use xlink:href="#DejaVuSans-2d" x="226.269531"/>
+      <use xlink:href="#DejaVuSans-20" x="262.353516"/>
+      <use xlink:href="#DejaVuSans-53" x="294.140625"/>
+      <use xlink:href="#DejaVuSans-6f" x="357.617188"/>
+      <use xlink:href="#DejaVuSans-48" x="418.798828"/>
+     </g>
+    </g>
+    <g id="line2d_17">
+     <path d="M 970.865937 100.642031 
+L 981.865937 100.642031 
+L 992.865937 100.642031 
+" style="fill: none; stroke: #4c72b0; stroke-width: 1.5; stroke-linecap: round"/>
+    </g>
+    <g id="text_16">
+     <!-- SoC -->
+     <g style="fill: #262626" transform="translate(1001.665937 104.492031) scale(0.11 -0.11)">
+      <use xlink:href="#DejaVuSans-53"/>
+      <use xlink:href="#DejaVuSans-6f" x="63.476562"/>
+      <use xlink:href="#DejaVuSans-43" x="124.658203"/>
+     </g>
+    </g>
+    <g id="line2d_18">
+     <path d="M 970.865937 116.787969 
+L 981.865937 116.787969 
+L 992.865937 116.787969 
+" style="fill: none; stroke: #dd8452; stroke-width: 1.5; stroke-linecap: round"/>
+    </g>
+    <g id="text_17">
+     <!-- SoH -->
+     <g style="fill: #262626" transform="translate(1001.665937 120.637969) scale(0.11 -0.11)">
+      <use xlink:href="#DejaVuSans-53"/>
+      <use xlink:href="#DejaVuSans-6f" x="63.476562"/>
+      <use xlink:href="#DejaVuSans-48" x="124.658203"/>
+     </g>
+    </g>
+   </g>
+  </g>
+ </g>
+ <defs>
+  <clipPath id="pb647630257">
+   <rect x="144" y="69.12" width="892.8" height="443.52"/>
+  </clipPath>
+ </defs>
+</svg>
diff --git a/docs/source/tuto_dag/dag_lab1.cpp b/docs/source/tuto_dag/dag_lab1.cpp
deleted file mode 100644 (file)
index 1242ffa..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "simgrid/s4u.hpp"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(main, "Messages specific for this s4u tutorial");
-
-int main(int argc, char* argv[]) {
-    simgrid::s4u::Engine e(&argc, argv);
-    e.load_platform(argv[1]);
-
-    simgrid::s4u::Host* tremblay = e.host_by_name("Tremblay");
-    simgrid::s4u::Host* jupiter  = e.host_by_name("Jupiter");
-
-    simgrid::s4u::ExecPtr c1 = simgrid::s4u::Exec::init();
-    simgrid::s4u::ExecPtr c2 = simgrid::s4u::Exec::init();
-    simgrid::s4u::ExecPtr c3 = simgrid::s4u::Exec::init();
-    simgrid::s4u::CommPtr t1 = simgrid::s4u::Comm::sendto_init();
-
-    c1->set_name("c1");
-    c2->set_name("c2");
-    c3->set_name("c3");
-    t1->set_name("t1");
-
-    c1->set_flops_amount(1e9);
-    c2->set_flops_amount(5e9);
-    c3->set_flops_amount(2e9);
-    t1->set_payload_size(5e8);
-
-    c1->add_successor(t1);
-    t1->add_successor(c3);
-    c2->add_successor(c3);
-
-    c1->set_host(tremblay);
-    c2->set_host(jupiter);
-    c3->set_host(jupiter);
-    t1->set_source(tremblay);
-    t1->set_destination(jupiter);
-
-    c1->start();
-    c2->start();
-
-    simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-    XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(), activity.get_start_time(),
-             activity.get_finish_time());
-    });
-
-    e.run();
-       return 0;
-}
-
diff --git a/docs/source/tuto_dag/dag_lab2-1.cpp b/docs/source/tuto_dag/dag_lab2-1.cpp
deleted file mode 100644 (file)
index 9ee5baa..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "simgrid/s4u.hpp"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(main, "Messages specific for this s4u example");
-
-int main(int argc, char* argv[]) {
-    simgrid::s4u::Engine e(&argc, argv);
-    e.load_platform(argv[1]);
-
-    std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_dot(argv[2]);
-
-    simgrid::s4u::Host* tremblay = e.host_by_name("Tremblay");
-    simgrid::s4u::Host* jupiter  = e.host_by_name("Jupiter");
-    simgrid::s4u::Host* fafard  = e.host_by_name("Fafard");
-
-    dynamic_cast<simgrid::s4u::Exec*>(dag[0].get())->set_host(fafard);
-    dynamic_cast<simgrid::s4u::Exec*>(dag[1].get())->set_host(tremblay);
-    dynamic_cast<simgrid::s4u::Exec*>(dag[2].get())->set_host(jupiter);
-    dynamic_cast<simgrid::s4u::Exec*>(dag[3].get())->set_host(jupiter);
-    dynamic_cast<simgrid::s4u::Exec*>(dag[8].get())->set_host(jupiter);
-    
-    for (const auto& a : dag) {
-        if (auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get())) {
-            auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
-            auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
-            comm->set_source(pred->get_host())->set_destination(succ->get_host());
-        }
-    }
-
-    simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-    XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(), activity.get_start_time(),
-             activity.get_finish_time());
-    });
-
-    e.run();
-       return 0;
-}
-
diff --git a/docs/source/tuto_dag/dag_lab2-2.cpp b/docs/source/tuto_dag/dag_lab2-2.cpp
deleted file mode 100644 (file)
index f392ecb..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "simgrid/s4u.hpp"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(main, "Messages specific for this s4u example");
-
-int main(int argc, char* argv[]) {
-    simgrid::s4u::Engine e(&argc, argv);
-    e.load_platform(argv[1]);
-
-    std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_json(argv[2]);
-
-    simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-    XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(), activity.get_start_time(),
-             activity.get_finish_time());
-    });
-
-    e.run();
-       return 0;
-}
-
diff --git a/docs/source/tuto_dag/dag_lab2-3.cpp b/docs/source/tuto_dag/dag_lab2-3.cpp
deleted file mode 100644 (file)
index e3db543..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "simgrid/s4u.hpp"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(main, "Messages specific for this s4u example");
-
-int main(int argc, char* argv[]) {
-    simgrid::s4u::Engine e(&argc, argv);
-    e.load_platform(argv[1]);
-
-    std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_DAX(argv[2]);
-
-    simgrid::s4u::Host* tremblay = e.host_by_name("Tremblay");
-    simgrid::s4u::Host* jupiter  = e.host_by_name("Jupiter");
-    simgrid::s4u::Host* fafard  = e.host_by_name("Fafard");
-
-    dynamic_cast<simgrid::s4u::Exec*>(dag[0].get())->set_host(fafard);
-    dynamic_cast<simgrid::s4u::Exec*>(dag[1].get())->set_host(tremblay);
-    dynamic_cast<simgrid::s4u::Exec*>(dag[2].get())->set_host(jupiter);
-    dynamic_cast<simgrid::s4u::Exec*>(dag[3].get())->set_host(jupiter);
-    dynamic_cast<simgrid::s4u::Exec*>(dag[8].get())->set_host(jupiter);
-    
-    for (const auto& a : dag) {
-        if (auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get())) {
-            auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
-            auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
-            comm->set_source(pred->get_host())->set_destination(succ->get_host());
-        }
-    }
-
-    simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-    XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(), activity.get_start_time(),
-             activity.get_finish_time());
-    });
-
-    e.run();
-       return 0;
-}
-
diff --git a/docs/source/tuto_dag/small_platform.xml b/docs/source/tuto_dag/small_platform.xml
deleted file mode 100644 (file)
index 69bdcae..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
-  <zone id="zone0" routing="Full">
-    <host id="Tremblay" speed="98.095Mf"/>
-    <host id="Jupiter" speed="76.296Mf"/>
-    <host id="Fafard" speed="76.296Mf"/>
-    <host id="Ginette" speed="48.492Mf"/>
-    <host id="Bourassa" speed="48.492Mf"/>
-    <host id="Jacquelin" speed="137.333Mf"/>
-    <host id="Boivin" speed="98.095Mf"/>
-
-    <link id="6" bandwidth="41.279125MBps" latency="59.904us"/>
-    <link id="3" bandwidth="34.285625MBps" latency="514.433us"/>
-    <link id="7" bandwidth="11.618875MBps" latency="189.98us"/>
-    <link id="9" bandwidth="7.20975MBps" latency="1.461517ms"/>
-    <link id="2" bandwidth="118.6825MBps" latency="136.931us"/>
-    <link id="8" bandwidth="8.158MBps" latency="270.544us"/>
-    <link id="1" bandwidth="34.285625MBps" latency="514.433us"/>
-    <link id="4" bandwidth="10.099625MBps" latency="479.78us"/>
-    <link id="0" bandwidth="41.279125MBps" latency="59.904us"/>
-    <link id="5" bandwidth="27.94625MBps" latency="278.066us"/>
-    <link id="145" bandwidth="2.583375MBps" latency="410.463us"/>
-    <link id="10" bandwidth="34.285625MBps" latency="514.433us"/>
-    <link id="11" bandwidth="118.6825MBps" latency="136.931us"/>
-    <link id="16" bandwidth="34.285625MBps" latency="514.433us"/>
-    <link id="17" bandwidth="118.6825MBps" latency="136.931us"/>
-    <link id="44" bandwidth="10.314625MBps" latency="6.932556ms"/>
-    <link id="47" bandwidth="10.314625MBps" latency="6.932556ms"/>
-    <link id="54" bandwidth="15.376875MBps" latency="35.083019ms"/>
-    <link id="56" bandwidth="21.41475MBps" latency="29.5890617ms"/>
-    <link id="59" bandwidth="11.845375MBps" latency="370.788us"/>
-    <link id="78" bandwidth="27.94625MBps" latency="278.066us"/>
-    <link id="79" bandwidth="8.42725MBps" latency="156.056us"/>
-    <link id="80" bandwidth="15.376875MBps" latency="35.083019ms"/>
-    <link id="loopback" bandwidth="498MBps" latency="15us" sharing_policy="FATPIPE"/>
-
-    <route src="Tremblay" dst="Tremblay">
-      <link_ctn id="loopback"/>
-    </route>
-    <route src="Jupiter" dst="Jupiter">
-      <link_ctn id="loopback"/>
-    </route>
-    <route src="Fafard" dst="Fafard">
-      <link_ctn id="loopback"/>
-    </route>
-    <route src="Ginette" dst="Ginette">
-      <link_ctn id="loopback"/>
-    </route>
-    <route src="Bourassa" dst="Bourassa">
-      <link_ctn id="loopback"/>
-    </route>
-    <route src="Tremblay" dst="Jupiter">
-      <link_ctn id="9"/>
-    </route>
-    <route src="Tremblay" dst="Fafard">
-      <link_ctn id="4"/>
-      <link_ctn id="3"/>
-      <link_ctn id="2"/>
-      <link_ctn id="0"/>
-      <link_ctn id="1"/>
-      <link_ctn id="8"/>
-    </route>
-    <route src="Tremblay" dst="Ginette">
-      <link_ctn id="4"/>
-      <link_ctn id="3"/>
-      <link_ctn id="5"/>
-    </route>
-    <route src="Tremblay" dst="Bourassa">
-      <link_ctn id="4"/>
-      <link_ctn id="3"/>
-      <link_ctn id="2"/>
-      <link_ctn id="0"/>
-      <link_ctn id="1"/>
-      <link_ctn id="6"/>
-      <link_ctn id="7"/>
-    </route>
-    <route src="Jupiter" dst="Fafard">
-      <link_ctn id="9"/>
-      <link_ctn id="4"/>
-      <link_ctn id="3"/>
-      <link_ctn id="2"/>
-      <link_ctn id="0"/>
-      <link_ctn id="1"/>
-      <link_ctn id="8"/>
-    </route>
-    <route src="Jupiter" dst="Bourassa">
-      <link_ctn id="9"/>
-      <link_ctn id="4"/>
-      <link_ctn id="3"/>
-      <link_ctn id="2"/>
-      <link_ctn id="0"/>
-      <link_ctn id="1"/>
-      <link_ctn id="6"/>
-      <link_ctn id="7"/>
-    </route>
-    <route src="Fafard" dst="Ginette">
-      <link_ctn id="8"/>
-      <link_ctn id="1"/>
-      <link_ctn id="0"/>
-      <link_ctn id="2"/>
-      <link_ctn id="5"/>
-    </route>
-    <route src="Jupiter" dst="Jacquelin">
-      <link_ctn id="145"/>
-    </route>
-    <route src="Jupiter" dst="Boivin">
-      <link_ctn id="47"/>
-    </route>
-    <route src="Jupiter" dst="Ginette">
-      <link_ctn id="9"/>
-      <link_ctn id="4"/>
-      <link_ctn id="3"/>
-      <link_ctn id="5"/>
-    </route>
-    <route src="Fafard" dst="Bourassa">
-      <link_ctn id="8"/>
-      <link_ctn id="6"/>
-      <link_ctn id="7"/>
-    </route>
-    <route src="Ginette" dst="Bourassa">
-      <link_ctn id="5"/>
-      <link_ctn id="2"/>
-      <link_ctn id="0"/>
-      <link_ctn id="1"/>
-      <link_ctn id="6"/>
-      <link_ctn id="7"/>
-    </route>
-    <route src="Ginette" dst="Jacquelin">
-      <link_ctn id="145"/>
-    </route>
-    <route src="Ginette" dst="Boivin">
-      <link_ctn id="47"/>
-    </route>
-    <route src="Bourassa" dst="Jacquelin">
-      <link_ctn id="145"/>
-    </route>
-    <route src="Bourassa" dst="Boivin">
-      <link_ctn id="47"/>
-    </route>
-    <route src="Jacquelin" dst="Boivin">
-      <link_ctn id="145"/>
-      <link_ctn id="59"/>
-      <link_ctn id="56"/>
-      <link_ctn id="54"/>
-      <link_ctn id="17"/>
-      <link_ctn id="16"/>
-      <link_ctn id="10"/>
-      <link_ctn id="11"/>
-      <link_ctn id="44"/>
-      <link_ctn id="47"/>
-    </route>
-    <route src="Jacquelin" dst="Fafard">
-      <link_ctn id="145"/>
-      <link_ctn id="59"/>
-      <link_ctn id="56"/>
-      <link_ctn id="54"/>
-      <link_ctn id="17"/>
-      <link_ctn id="16"/>
-      <link_ctn id="10"/>
-      <link_ctn id="6"/>
-      <link_ctn id="9"/>
-      <link_ctn id="79"/>
-      <link_ctn id="78"/>
-    </route>
-    <route src="Jacquelin" dst="Tremblay">
-      <link_ctn id="145"/>
-      <link_ctn id="59"/>
-      <link_ctn id="56"/>
-      <link_ctn id="54"/>
-      <link_ctn id="2"/>
-      <link_ctn id="3"/>
-    </route>
-    <route src="Boivin" dst="Tremblay">
-      <link_ctn id="47"/>
-      <link_ctn id="44"/>
-      <link_ctn id="11"/>
-      <link_ctn id="10"/>
-      <link_ctn id="16"/>
-      <link_ctn id="0"/>
-      <link_ctn id="3"/>
-    </route>
-    <route src="Boivin" dst="Fafard">
-      <link_ctn id="47"/>
-      <link_ctn id="44"/>
-      <link_ctn id="11"/>
-      <link_ctn id="6"/>
-      <link_ctn id="9"/>
-      <link_ctn id="79"/>
-      <link_ctn id="78"/>
-      <link_ctn id="80"/>
-    </route>
-  </zone>
-</platform>
index cea4755..10fd24a 100644 (file)
@@ -99,9 +99,13 @@ if (SIMGRID_HAVE_MC)
   endforeach()
 endif()
 
-
 if(NOT HAVE_GRAPHVIZ)
   set(_dag-from-dot_disable 1)
+  set(_dag-from-dot-simple_disable 1)
+endif()
+
+if (NOT SIMGRID_HAVE_JSON)
+  set(_dag-from-json-simple_disable 1)
 endif()
 
 if(NOT SIMGRID_HAVE_NS3)
@@ -116,10 +120,11 @@ foreach (example activity-testany activity-waitany
                  actor-create actor-daemon actor-exiting actor-join actor-kill
                  actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
                  app-bittorrent app-chainsend app-token-ring
+                 battery-degradation battery-simple battery-energy
                  comm-pingpong comm-ready comm-suspend comm-testany comm-wait comm-waitany comm-waitall comm-waituntil
                  comm-dependent comm-host2host comm-failure comm-throttling
                  cloud-capping cloud-migration cloud-simple
-                 dag-comm dag-from-dax dag-from-dot dag-failure dag-io dag-scheduling dag-simple
+                 dag-comm dag-from-json-simple dag-from-dax-simple dag-from-dax dag-from-dot-simple dag-from-dot dag-failure dag-io dag-scheduling dag-simple dag-tuto
                  dht-chord dht-kademlia
                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
                  engine-filtering engine-run-partial
@@ -286,14 +291,18 @@ set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-a
                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/dogbone_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml                PARENT_SCOPE)
-set(bin_files     ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
+set(bin_files     ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/battery-degradation/plot_battery_degradation.py
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/promela_bugged1_liveness
                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged2-liveness/promela_bugged2_liveness PARENT_SCOPE)
 set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/simple_dax_with_cycle.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/smalldax.xml
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax-simple/dag.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag.dot
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot-simple/dag.dot
                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag_with_cycle.dot
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-json-simple/dag.json
                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
diff --git a/examples/cpp/battery-degradation/plot_battery_degradation.py b/examples/cpp/battery-degradation/plot_battery_degradation.py
new file mode 100644 (file)
index 0000000..6863832
--- /dev/null
@@ -0,0 +1,16 @@
+# Copyright (c) 2003-2023. 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.
+import sys
+import pandas as pd
+import seaborn as sns 
+
+df = pd.read_csv(sys.argv[1], names=['Time','Value', 'SoC - SoH'])
+df['Time'] = df['Time'].apply(lambda x: float(x.split(" ")[-1]))
+sns.set_theme()
+sns.set(rc={'figure.figsize':(16,8)})
+g = sns.lineplot(data=df, x='Time', y='Value', hue='SoC - SoH')
+g.get_figure().savefig('battery_degradation.svg')
\ No newline at end of file
diff --git a/examples/cpp/battery-degradation/s4u-battery-degradation.cpp b/examples/cpp/battery-degradation/s4u-battery-degradation.cpp
new file mode 100644 (file)
index 0000000..0aad5a1
--- /dev/null
@@ -0,0 +1,34 @@
+/* Copyright (c) 2003-2023. 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. */
+
+#include "simgrid/plugins/battery.hpp"
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(battery_degradation, "Messages specific for this s4u example");
+
+static void manager()
+{
+  auto battery = simgrid::s4u::this_actor::get_host();
+  double power = 100;
+  while (sg_battery_get_state_of_health(battery) > 0) {
+    XBT_INFO("%f,%f,SoC", simgrid::s4u::Engine::get_clock(), sg_battery_get_state_of_charge(battery));
+    XBT_INFO("%f,%f,SoH", simgrid::s4u::Engine::get_clock(), sg_battery_get_state_of_health(battery));
+    sg_battery_set_power(battery, power);
+    simgrid::s4u::this_actor::sleep_until(sg_battery_get_next_event_date(battery));
+    power *= -1;
+  }
+}
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  e.load_platform(argv[1]);
+
+  sg_battery_plugin_init();
+
+  simgrid::s4u::Actor::create("manager", e.get_all_hosts()[0], manager);
+  e.run();
+  return 0;
+}
diff --git a/examples/cpp/battery-degradation/s4u-battery-degradation.tesh b/examples/cpp/battery-degradation/s4u-battery-degradation.tesh
new file mode 100644 (file)
index 0000000..876bd7a
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/env tesh
+
+! output ignore 
+
+$ ${bindir:=.}/s4u-battery-degradation ${platfdir}/battery_platform.xml
diff --git a/examples/cpp/battery-energy/s4u-battery-energy.cpp b/examples/cpp/battery-energy/s4u-battery-energy.cpp
new file mode 100644 (file)
index 0000000..55bfc3c
--- /dev/null
@@ -0,0 +1,73 @@
+/* Copyright (c) 2003-2023. 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. */
+
+#include "simgrid/plugins/battery.hpp"
+#include "simgrid/plugins/energy.h"
+#include "simgrid/s4u.hpp"
+
+#include <iostream>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(battery_energy, "Messages specific for this s4u example");
+
+static void manager()
+{
+  auto battery = simgrid::s4u::Engine::get_instance()->host_by_name("battery");
+  auto host1   = simgrid::s4u::Engine::get_instance()->host_by_name("host1");
+  auto host2   = simgrid::s4u::Engine::get_instance()->host_by_name("host2");
+
+  XBT_INFO("Initial Battery: SoC: %f SoH: %f Capacity (Total): %fWh Capacity (Usable): %fWh P: %fW",
+           sg_battery_get_state_of_charge(battery), sg_battery_get_state_of_health(battery),
+           sg_battery_get_capacity(battery),
+           sg_battery_get_capacity(battery) *
+               (sg_battery_get_state_of_charge_max(battery) - sg_battery_get_state_of_charge_min(battery)),
+           sg_battery_get_power(battery));
+
+  // Start execs on each host
+  simgrid::s4u::ExecPtr exec1 = simgrid::s4u::Exec::init();
+  exec1->set_flops_amount(1e10);
+  exec1->set_host(host1);
+  exec1->start();
+  simgrid::s4u::ExecPtr exec2 = simgrid::s4u::Exec::init();
+  exec2->set_flops_amount(1e10);
+  exec2->set_host(host2);
+  exec2->start();
+  // Set power generation from the battery
+  double total_power_w =
+      sg_host_get_wattmax_at(host1, host1->get_pstate()) + sg_host_get_wattmax_at(host2, host2->get_pstate());
+  sg_battery_set_power(battery, total_power_w);
+  XBT_INFO("Battery power set to: %fW (host1) + %fW (host2)", sg_host_get_wattmax_at(host1, host1->get_pstate()),
+           sg_host_get_wattmax_at(host2, host2->get_pstate()));
+  double end = sg_battery_get_next_event_date(battery);
+  XBT_INFO("The battery will be depleted at: %f", end);
+  XBT_INFO("Exec1 will be finished in: %f", exec1->get_remaining() / host1->get_speed());
+  XBT_INFO("Exec2 will be finished in: %f", exec2->get_remaining() / host2->get_speed());
+  simgrid::s4u::this_actor::sleep_until(end);
+
+  // Battery depleted
+  XBT_INFO("Battery depleted: SoC: %f SoH: %f P: %fW", sg_battery_get_state_of_charge(battery),
+           sg_battery_get_state_of_health(battery), sg_battery_get_power(battery));
+  double energy_battery = sg_host_get_consumed_energy(host1) + sg_host_get_consumed_energy(host2);
+  XBT_INFO("Pursuing with power from the grid until both execs are finished");
+  simgrid::s4u::this_actor::sleep_for(
+      std::max(exec1->get_remaining() / host1->get_speed(), exec2->get_remaining() / host2->get_speed()));
+
+  // Execs finished
+  double energy_grid = sg_host_get_consumed_energy(host1) + sg_host_get_consumed_energy(host2) - energy_battery;
+  XBT_INFO("Energy consumed: Battery: %fJ (%fWh) Grid: %fJ (%fWh)", energy_battery, energy_battery / 3600, energy_grid,
+           energy_grid / 3600);
+}
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  e.load_platform(argv[1]);
+
+  sg_host_energy_plugin_init();
+  sg_battery_plugin_init();
+
+  simgrid::s4u::Actor::create("manager", e.host_by_name("host1"), manager);
+  e.run();
+  return 0;
+}
diff --git a/examples/cpp/battery-energy/s4u-battery-energy.tesh b/examples/cpp/battery-energy/s4u-battery-energy.tesh
new file mode 100644 (file)
index 0000000..e0ecf55
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-battery-energy ${platfdir}/battery_platform.xml
+> [host1:manager:(1) 0.000000] [battery_energy/INFO] Initial Battery: SoC: 0.800000 SoH: 1.000000 Capacity (Total): 10.000000Wh Capacity (Usable): 6.000000Wh P: 0.000000W
+> [host1:manager:(1) 0.000000] [battery_energy/INFO] Battery power set to: 200.000000W (host1) + 170.000000W (host2)
+> [host1:manager:(1) 0.000000] [battery_energy/INFO] The battery will be depleted at: 58.378378
+> [host1:manager:(1) 0.000000] [battery_energy/INFO] Exec1 will be finished in: 100.000000
+> [host1:manager:(1) 0.000000] [battery_energy/INFO] Exec2 will be finished in: 200.000000
+> [host1:manager:(1) 58.378378] [battery_energy/INFO] Battery depleted: SoC: 0.200000 SoH: 0.995833 P: 0.000000W
+> [host1:manager:(1) 58.378378] [battery_energy/INFO] Pursuing with power from the grid until both execs are finished
+> [host1:manager:(1) 200.000000] [battery_energy/INFO] Energy consumed: Battery: 21600.000000J (6.000000Wh) Grid: 42400.000000J (11.777778Wh)
+> [200.000000] [host_energy/INFO] Total energy consumption: 64000.000000 Joules (used hosts: 64000.000000 Joules; unused/idle hosts: 0.000000)
+> [200.000000] [host_energy/INFO] Energy consumption of host battery: 0.000000 Joules
+> [200.000000] [host_energy/INFO] Energy consumption of host host1: 30000.000000 Joules
+> [200.000000] [host_energy/INFO] Energy consumption of host host2: 34000.000000 Joules
diff --git a/examples/cpp/battery-simple/s4u-battery-simple.cpp b/examples/cpp/battery-simple/s4u-battery-simple.cpp
new file mode 100644 (file)
index 0000000..435c402
--- /dev/null
@@ -0,0 +1,41 @@
+/* Copyright (c) 2003-2023. 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. */
+
+#include "simgrid/plugins/battery.hpp"
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(battery_simple, "Messages specific for this s4u example");
+
+static void manager()
+{
+  auto battery         = simgrid::s4u::Engine::get_instance()->host_by_name("battery");
+  double consumption_w = 200;
+
+  XBT_INFO("Initial Battery: SoC: %f SoH: %f Capacity (Total): %fWh Capacity (Usable): %fWh P: %f",
+           sg_battery_get_state_of_charge(battery), sg_battery_get_state_of_health(battery),
+           sg_battery_get_capacity(battery),
+           sg_battery_get_capacity(battery) *
+               (sg_battery_get_state_of_charge_max(battery) - sg_battery_get_state_of_charge_min(battery)),
+           sg_battery_get_power(battery));
+  double start = simgrid::s4u::Engine::get_clock();
+  sg_battery_set_power(battery, consumption_w);
+  XBT_INFO("Battery power set to: %fW", consumption_w);
+  double end = sg_battery_get_next_event_date(battery);
+  XBT_INFO("The battery will be depleted at: %f", end);
+  simgrid::s4u::this_actor::sleep_until(end);
+  XBT_INFO("Energy consumed : %fJ (%fWh)", (end - start) * consumption_w, (end - start) * consumption_w / 3600);
+}
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  e.load_platform(argv[1]);
+
+  sg_battery_plugin_init();
+
+  simgrid::s4u::Actor::create("manager", e.host_by_name("host1"), manager);
+  e.run();
+  return 0;
+}
diff --git a/examples/cpp/battery-simple/s4u-battery-simple.tesh b/examples/cpp/battery-simple/s4u-battery-simple.tesh
new file mode 100644 (file)
index 0000000..b269145
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-battery-simple ${platfdir}/battery_platform.xml
+> [host1:manager:(1) 0.000000] [battery_simple/INFO] Initial Battery: SoC: 0.800000 SoH: 1.000000 Capacity (Total): 10.000000Wh Capacity (Usable): 6.000000Wh P: 0.000000
+> [host1:manager:(1) 0.000000] [battery_simple/INFO] Battery power set to: 200.000000W
+> [host1:manager:(1) 0.000000] [battery_simple/INFO] The battery will be depleted at: 108.000000
+> [host1:manager:(1) 108.000000] [battery_simple/INFO] Energy consumed : 21600.000000J (6.000000Wh)
diff --git a/examples/cpp/dag-from-dax-simple/s4u-dag-from-dax-simple.cpp b/examples/cpp/dag-from-dax-simple/s4u-dag-from-dax-simple.cpp
new file mode 100644 (file)
index 0000000..d55ec54
--- /dev/null
@@ -0,0 +1,42 @@
+/* Copyright (c) 2003-2023. 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. */
+
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(dag_from_dax_simple, "Messages specific for this s4u example");
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  e.load_platform(argv[1]);
+
+  std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_DAX(argv[2]);
+
+  simgrid::s4u::Host* tremblay = e.host_by_name("Tremblay");
+  simgrid::s4u::Host* jupiter  = e.host_by_name("Jupiter");
+  simgrid::s4u::Host* fafard   = e.host_by_name("Fafard");
+
+  dynamic_cast<simgrid::s4u::Exec*>(dag[0].get())->set_host(fafard);
+  dynamic_cast<simgrid::s4u::Exec*>(dag[1].get())->set_host(tremblay);
+  dynamic_cast<simgrid::s4u::Exec*>(dag[2].get())->set_host(jupiter);
+  dynamic_cast<simgrid::s4u::Exec*>(dag[3].get())->set_host(jupiter);
+  dynamic_cast<simgrid::s4u::Exec*>(dag[8].get())->set_host(jupiter);
+
+  for (const auto& a : dag) {
+    if (auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get())) {
+      auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
+      auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
+      comm->set_source(pred->get_host())->set_destination(succ->get_host());
+    }
+  }
+
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
+    XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(),
+             activity.get_start_time(), activity.get_finish_time());
+  });
+
+  e.run();
+  return 0;
+}
diff --git a/examples/cpp/dag-from-dax-simple/s4u-dag-from-dax-simple.tesh b/examples/cpp/dag-from-dax-simple/s4u-dag-from-dax-simple.tesh
new file mode 100644 (file)
index 0000000..7e78194
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-dag-from-dax-simple --log=no_loc ${platfdir}/small_platform.xml ${srcdir:=.}/dag.xml
+> [0.000000] [dag_from_dax_simple/INFO] Activity 'root' is complete (start time: 0.000000, finish time: 0.000000)
+> [33.394394] [dag_from_dax_simple/INFO] Activity 'root_i2_2@c2' is complete (start time: 0.000000, finish time: 33.394394)
+> [39.832311] [dag_from_dax_simple/INFO] Activity 'root_i1_1@c1' is complete (start time: 0.000000, finish time: 39.832311)
+> [467.988690] [dag_from_dax_simple/INFO] Activity '1@c1' is complete (start time: 39.832311, finish time: 467.988690)
+> [543.077868] [dag_from_dax_simple/INFO] Activity '1@c1_o1_3@c3' is complete (start time: 467.988690, finish time: 543.077868)
+> [2785.832267] [dag_from_dax_simple/INFO] Activity '2@c2' is complete (start time: 33.394394, finish time: 2785.832267)
+> [3886.807417] [dag_from_dax_simple/INFO] Activity '3@c3' is complete (start time: 2785.832267, finish time: 3886.807417)
+> [3887.221639] [dag_from_dax_simple/INFO] Activity '3@c3_o3_end' is complete (start time: 3886.807417, finish time: 3887.221639)
+> [3887.221639] [dag_from_dax_simple/INFO] Activity 'end' is complete (start time: 3887.221639, finish time: 3887.221639)
\ No newline at end of file
diff --git a/examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.cpp b/examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.cpp
new file mode 100644 (file)
index 0000000..5fbcf2c
--- /dev/null
@@ -0,0 +1,42 @@
+/* Copyright (c) 2003-2023. 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. */
+
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(dag_from_dot_simple, "Messages specific for this s4u example");
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  e.load_platform(argv[1]);
+
+  std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_dot(argv[2]);
+
+  simgrid::s4u::Host* tremblay = e.host_by_name("Tremblay");
+  simgrid::s4u::Host* jupiter  = e.host_by_name("Jupiter");
+  simgrid::s4u::Host* fafard   = e.host_by_name("Fafard");
+
+  dynamic_cast<simgrid::s4u::Exec*>(dag[0].get())->set_host(fafard);
+  dynamic_cast<simgrid::s4u::Exec*>(dag[1].get())->set_host(tremblay);
+  dynamic_cast<simgrid::s4u::Exec*>(dag[2].get())->set_host(jupiter);
+  dynamic_cast<simgrid::s4u::Exec*>(dag[3].get())->set_host(jupiter);
+  dynamic_cast<simgrid::s4u::Exec*>(dag[8].get())->set_host(jupiter);
+
+  for (const auto& a : dag) {
+    if (auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get())) {
+      auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
+      auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
+      comm->set_source(pred->get_host())->set_destination(succ->get_host());
+    }
+  }
+
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
+    XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(),
+             activity.get_start_time(), activity.get_finish_time());
+  });
+
+  e.run();
+  return 0;
+}
diff --git a/examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.tesh b/examples/cpp/dag-from-dot-simple/s4u-dag-from-dot-simple.tesh
new file mode 100644 (file)
index 0000000..d6a88d5
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-dag-from-dot-simple --log=no_loc ${platfdir}/small_platform.xml ${srcdir:=.}/dag.dot
+> [0.000000] [dag_from_dot_simple/INFO] Activity 'root' is complete (start time: 0.000000, finish time: 0.000000)
+> [33.394394] [dag_from_dot_simple/INFO] Activity 'root->c2' is complete (start time: 0.000000, finish time: 33.394394)
+> [39.832311] [dag_from_dot_simple/INFO] Activity 'root->c1' is complete (start time: 0.000000, finish time: 39.832311)
+> [50.026511] [dag_from_dot_simple/INFO] Activity 'c1' is complete (start time: 39.832311, finish time: 50.026511)
+> [98.928629] [dag_from_dot_simple/INFO] Activity 'c2' is complete (start time: 33.394394, finish time: 98.928629)
+> [125.115689] [dag_from_dot_simple/INFO] Activity 'c1->c3' is complete (start time: 50.026511, finish time: 125.115689)
+> [151.329383] [dag_from_dot_simple/INFO] Activity 'c3' is complete (start time: 125.115689, finish time: 151.329383)
+> [151.743605] [dag_from_dot_simple/INFO] Activity 'c3->end' is complete (start time: 151.329383, finish time: 151.743605)
+> [151.743605] [dag_from_dot_simple/INFO] Activity 'end' is complete (start time: 151.743605, finish time: 151.743605)
\ No newline at end of file
diff --git a/examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.cpp b/examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.cpp
new file mode 100644 (file)
index 0000000..e6246b1
--- /dev/null
@@ -0,0 +1,24 @@
+/* Copyright (c) 2003-2023. 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. */
+
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(dag_from_json_simple, "Messages specific for this s4u example");
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  e.load_platform(argv[1]);
+
+  std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_json(argv[2]);
+
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
+    XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(),
+             activity.get_start_time(), activity.get_finish_time());
+  });
+
+  e.run();
+  return 0;
+}
diff --git a/examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.tesh b/examples/cpp/dag-from-json-simple/s4u-dag-from-json-simple.tesh
new file mode 100644 (file)
index 0000000..1d37a65
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-dag-from-json-simple --log=no_loc ${platfdir}/small_platform.xml ${srcdir:=.}/dag.json
+> [10.194200] [dag_from_json_simple/INFO] Activity 'c1' is complete (start time: 0.000000, finish time: 10.194200)
+> [65.534235] [dag_from_json_simple/INFO] Activity 'c2' is complete (start time: 0.000000, finish time: 65.534235)
+> [85.283378] [dag_from_json_simple/INFO] Activity 't1' is complete (start time: 10.194200, finish time: 85.283378)
+> [111.497072] [dag_from_json_simple/INFO] Activity 'c3' is complete (start time: 85.283378, finish time: 111.497072)
\ No newline at end of file
diff --git a/examples/cpp/dag-tuto/s4u-dag-tuto.cpp b/examples/cpp/dag-tuto/s4u-dag-tuto.cpp
new file mode 100644 (file)
index 0000000..39b56d6
--- /dev/null
@@ -0,0 +1,53 @@
+/* Copyright (c) 2003-2023. 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. */
+
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(dag_tuto, "Messages specific for this s4u tutorial");
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  e.load_platform(argv[1]);
+
+  simgrid::s4u::Host* tremblay = e.host_by_name("Tremblay");
+  simgrid::s4u::Host* jupiter  = e.host_by_name("Jupiter");
+
+  simgrid::s4u::ExecPtr c1 = simgrid::s4u::Exec::init();
+  simgrid::s4u::ExecPtr c2 = simgrid::s4u::Exec::init();
+  simgrid::s4u::ExecPtr c3 = simgrid::s4u::Exec::init();
+  simgrid::s4u::CommPtr t1 = simgrid::s4u::Comm::sendto_init();
+
+  c1->set_name("c1");
+  c2->set_name("c2");
+  c3->set_name("c3");
+  t1->set_name("t1");
+
+  c1->set_flops_amount(1e9);
+  c2->set_flops_amount(5e9);
+  c3->set_flops_amount(2e9);
+  t1->set_payload_size(5e8);
+
+  c1->add_successor(t1);
+  t1->add_successor(c3);
+  c2->add_successor(c3);
+
+  c1->set_host(tremblay);
+  c2->set_host(jupiter);
+  c3->set_host(jupiter);
+  t1->set_source(tremblay);
+  t1->set_destination(jupiter);
+
+  c1->start();
+  c2->start();
+
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
+    XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(),
+             activity.get_start_time(), activity.get_finish_time());
+  });
+
+  e.run();
+  return 0;
+}
diff --git a/examples/cpp/dag-tuto/s4u-dag-tuto.tesh b/examples/cpp/dag-tuto/s4u-dag-tuto.tesh
new file mode 100644 (file)
index 0000000..56e448f
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-dag-tuto --log=no_loc ${platfdir}/small_platform.xml
+> [10.194200] [dag_tuto/INFO] Activity 'c1' is complete (start time: 0.000000, finish time: 10.194200)
+> [65.534235] [dag_tuto/INFO] Activity 'c2' is complete (start time: 0.000000, finish time: 65.534235)
+> [85.283378] [dag_tuto/INFO] Activity 't1' is complete (start time: 10.194200, finish time: 85.283378)
+> [111.497072] [dag_tuto/INFO] Activity 'c3' is complete (start time: 85.283378, finish time: 111.497072)
\ No newline at end of file
diff --git a/examples/platforms/battery_platform.xml b/examples/platforms/battery_platform.xml
new file mode 100644 (file)
index 0000000..210b4cb
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+  <zone id="world" routing="Floyd">
+    <host id="battery" speed="0f">
+      <!-- For Energy plugin -->
+      <prop id="wattage_per_state" value="0:0:0" />
+      <!---->
+      <!-- For Battery plugin -->
+      <prop id="battery_active" value="1" />
+      <prop id="battery_capacity" value="10" />
+      <prop id="battery_cycles" value="100" />
+      <prop id="battery_state_of_charge" value="0.8" />
+      <!---->
+    </host>
+
+    <host id="host1" core="1" pstate="0" speed="100.0Mf,50.0Mf,20.0Mf">
+      <!-- For Energy plugin -->
+      <prop id="wattage_per_state" value="100.0:200.0:200.0, 93.0:170.0:170.0, 90.0:150.0:150.0" />
+      <prop id="wattage_off" value="10" />
+      <!---->
+    </host>
+
+    <host id="host2" core="1" pstate="1" speed="100.0Mf,50.0Mf,20.0Mf">
+      <!-- For Energy plugin -->
+      <prop id="wattage_per_state" value="100.0:200.0:200.0, 93.0:170.0:170.0, 90.0:150.0:150.0" />
+      <prop id="wattage_off" value="10" />
+      <!---->
+    </host>
+
+
+  </zone>
+</platform>
diff --git a/include/simgrid/plugins/battery.hpp b/include/simgrid/plugins/battery.hpp
new file mode 100644 (file)
index 0000000..3899ff0
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef SIMGRID_PLUGINS_BATTERY_H_
+#define SIMGRID_PLUGINS_BATTERY_H_
+
+#include <simgrid/config.h>
+#include <simgrid/forward.h>
+#include <xbt/base.h>
+
+SG_BEGIN_DECL
+
+XBT_PUBLIC void sg_battery_plugin_init();
+
+XBT_PUBLIC void sg_battery_set_state(const_sg_host_t host, bool state);
+XBT_PUBLIC void sg_battery_set_power(const_sg_host_t host, double power);
+
+XBT_PUBLIC bool sg_battery_is_active(const_sg_host_t host);
+XBT_PUBLIC double sg_battery_get_power(const_sg_host_t host);
+XBT_PUBLIC double sg_battery_get_state_of_charge(const_sg_host_t host);
+XBT_PUBLIC double sg_battery_get_state_of_charge_min(const_sg_host_t host);
+XBT_PUBLIC double sg_battery_get_state_of_charge_max(const_sg_host_t host);
+XBT_PUBLIC double sg_battery_get_state_of_health(const_sg_host_t host);
+XBT_PUBLIC double sg_battery_get_capacity(const_sg_host_t host);
+XBT_PUBLIC double sg_battery_get_cumulative_cost(const_sg_host_t host);
+XBT_PUBLIC double sg_battery_get_next_event_date(const_sg_host_t host);
+
+SG_END_DECL
+
+#endif
\ No newline at end of file
diff --git a/src/plugins/battery.cpp b/src/plugins/battery.cpp
new file mode 100644 (file)
index 0000000..2628095
--- /dev/null
@@ -0,0 +1,598 @@
+#include <simgrid/Exception.hpp>
+#include <simgrid/plugins/battery.hpp>
+#include <simgrid/s4u/Actor.hpp>
+#include <simgrid/s4u/Engine.hpp>
+#include <simgrid/s4u/Host.hpp>
+#include <simgrid/s4u/VirtualMachine.hpp>
+#include <simgrid/simix.hpp>
+
+#include "src/kernel/resource/CpuImpl.hpp"
+#include "src/simgrid/module.hpp"
+
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
+
+SIMGRID_REGISTER_PLUGIN(battery, "Battery management", &sg_battery_plugin_init)
+
+/** @defgroup plugin_battery plugin_battery Plugin Battery
+
+  @beginrst
+
+This is the battery plugin, enabling management of batteries on hosts.
+To activate this plugin, first call :cpp:func:`sg_battery_plugin_init()`.
+
+We consider a constant energy exchange model.
+
+Properties of batteries such as State of Charge and State of Health are lazily updated, ie., when reading values and
+when the power is modified.
+
+State of Charge (SoC)
+.....................
+
+If the power of a battery is set to a negative value then the battery will act as a load and fill over time until it
+reaches its maximal SoC. Conversely, if the power of a battery is set to a positive value then the battery will act as a
+generator and deplete over time until it reaches its minimal SoC. When reaching either its maximal or minimal SoC it
+will set its power to 0.
+
+The natural depletion of batteries over time is not taken into account.
+
+State of Health (SoH)
+.....................
+
+A battery starts with an energy budget :math:`E` such as:
+
+.. math::
+
+  E = C \times U \times D \times N \times 2
+
+Where :math:`C` is the initial capacity, :math:`U` is the ratio of usable capacity, :math:`D` is the depth of discharge
+and :math:`N` is the number of cycles of the battery.
+
+The SoH represents the consumption of this energy budget during the lifetime of the battery.
+Use the battery reduces its SoH and its capacity in consequence.
+When the SoH reaches 0, the battery becomes unusable.
+
+.. warning::
+
+  Due to the decrease of the battery capacity with the SoH, a large usable capacity leads to very tiny battery capacity
+  when reaching low SoH. This may results in charge and discharge cycles too short to be evaluated by the simulator. To
+  avoid this situation you should not try to reach a SoH of 0 with a usable capacity set to 1.
+
+Plotting the output of the example "battery-degradation" highlights the linear decrease of the SoH due to a continuous
+use of the battery and the decreasing cycle duration as its capacity reduces:
+
+.. image:: /img/battery_degradation.svg
+   :align: center
+
+Batteries properties
+....................
+
+Properties of the batteries are defined as properties of hosts in the platform XML file.
+
+Here is an example of XML declaration:
+
+.. code-block:: xml
+
+   <host id="Host" speed="100.0Mf" core="1">
+       <prop id="battery_active" value="1" />
+       <prop id="battery_capacity" value="10" />
+       <prop id="battery_cycles" value="200" />
+       <prop id="battery_state_of_charge" value="0.8" />
+   </host>
+
+The different properties are:
+
+- ``battery_active``: Set the battery as active if set to 1 (default=0)
+- ``battery_power``: Set the initial power of the battery in W (default=0). A negative value indicates that the battery act as a load and charge. A positive value indicates that the battery act as a generator and discharge
+- ``battery_state_of_charge``: Set the initial state of charge of the battery (default=0)
+- ``battery_state_of_charge_min``: Set the minimal state of charge of the battery (default=0.2)
+- ``battery_state_of_charge_max``: Set the maximal state of charge of the battery (default=0.8)
+- ``battery_capacity``: Set the initial capacity of the battery in Wh (default=0)
+- ``battery_usable_capacity``: Set the ratio of usable capacity of the battery (default=0.8)
+- ``battery_depth_of_discharge``: Set the depth of discharge of the battery (default=0.9)
+- ``battery_charge_efficiency``: Set the charge efficiency of the battery (default=1)
+- ``battery_discharge_efficiency``: Set the charge efficiency of the battery (default=1)
+- ``battery_cycles``: Set the number of cycle of the battery (default=1)
+- ``battery_depth_of_discharge``: Set the number of cycle of the battery (default=1)
+- ``battery_eval_cost``: Evaluate the cost of the battery during the simulation if set to 1 (defaulf=0)
+- ``battery_investment_cost``: Set the investment cost of the battery (default=0)
+- ``battery_static_maintenance_cost``: Set the static maintenance cost of the battery (default=0)
+- ``battery_variable_maintenance_cost``: Set the variable maintenance cost of the battery (default=0)
+
+  @endrst
+ */
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(battery, kernel, "Logging specific to the battery plugin");
+
+namespace simgrid::plugin {
+class Battery {
+private:
+  simgrid::s4u::Host* host_ = nullptr;
+
+  double state_of_charge_min_  = 0.2;
+  double state_of_charge_max_  = 0.8;
+  double charge_efficiency_    = 1;
+  double discharge_efficiency_ = 1;
+  double initial_capacity_wh_  = 0;
+  double cycles_ = 1; // total complete cycles (charge + discharge) the battery can do before complete depletion.
+  double depth_of_discharge_ = 0.9;
+  double usable_capacity_    = 0.8;
+  double energy_budget_j_    = 0;
+
+  bool active_               = false;
+  double power_w_            = 0; // NEGATIVE when charging (consumes power) POSITIVE when discharging (generates power)
+  double state_of_charge_    = 0;
+  double capacity_wh_        = 0;
+  double next_event_         = -1;
+  double energy_exchanged_j_ = 0;
+  double last_updated_       = 0;
+
+  // Calculation of costs from Bei Li thesis (link :https://tel.archives-ouvertes.fr/tel-02077668/document) (chapter 4)
+  bool eval_cost_                                = false;
+  double cumulative_cost_                        = 0;
+  double investment_cost_per_wh_                 = 0;
+  double static_maintenance_cost_per_wh_times_h_ = 0;
+  double variable_maintenance_cost_per_wh_       = 0;
+
+  void init_battery_params();
+  void init_cost_params();
+  void update();
+
+  void set_state_of_charge(double soc);
+  void set_state_of_charge_min(double soc);
+  void set_state_of_charge_max(double soc);
+  void set_capacity(double c);
+  void set_initial_capacity(double c);
+  void set_cycles(int c);
+  void set_depth_of_discharge(double d);
+  void set_usable_capacity(double c);
+  void set_charge_efficiency(double e);
+  void set_discharge_efficiency(double e);
+  void set_eval_cost(bool eval);
+  void set_investment_cost(double c);
+  void set_static_maintenance_cost(double c);
+  void set_variable_maintenance_cost(double c);
+
+  bool is_charging();
+
+public:
+  static simgrid::xbt::Extension<simgrid::s4u::Host, Battery> EXTENSION_ID;
+
+  explicit Battery(simgrid::s4u::Host* host);
+  ~Battery();
+
+  void set_state(bool state);
+  void set_power(const double power);
+
+  bool is_active() const;
+  double get_power();
+  double get_state_of_charge();
+  double get_state_of_charge_min();
+  double get_state_of_charge_max();
+  double get_state_of_health();
+  double get_capacity();
+  double get_cumulative_cost();
+  double get_next_event_date();
+};
+
+simgrid::xbt::Extension<simgrid::s4u::Host, Battery> Battery::EXTENSION_ID;
+
+void Battery::set_power(const double p)
+{
+  update();
+  xbt_assert(p == 0 or (p > 0 and state_of_charge_ > state_of_charge_min_) or
+                 (p < 0 and state_of_charge_ < state_of_charge_max_),
+             "Incoherent power and state of charge. A battery cannot charge(discharge) past its maximal(minimal) state "
+             "of charge.");
+  xbt_assert(p == 0 or energy_exchanged_j_ < energy_budget_j_, "Cannot set power of a fully used battery.");
+  simgrid::kernel::actor::simcall_answered([this, p] {
+    power_w_ = p;
+    if (power_w_ == 0) {
+      next_event_ = -1;
+      return;
+    }
+    double soc_shutdown;
+    double soh_shutdown;
+    if (power_w_ > 0) {
+      soc_shutdown = capacity_wh_ * 3600 * (state_of_charge_ - state_of_charge_min_) / (power_w_ * charge_efficiency_);
+      soh_shutdown = (energy_budget_j_ - energy_exchanged_j_) / (power_w_ * charge_efficiency_);
+    } else if (power_w_ < 0) {
+      soc_shutdown =
+          capacity_wh_ * 3600 * (state_of_charge_max_ - state_of_charge_) / (abs(power_w_) / discharge_efficiency_);
+      soh_shutdown = (energy_budget_j_ - energy_exchanged_j_) / (abs(power_w_) / discharge_efficiency_);
+    }
+    if (soh_shutdown <= 0)
+      next_event_ = simgrid::s4u::Engine::get_clock() + soc_shutdown;
+    else
+      next_event_ = simgrid::s4u::Engine::get_clock() + std::min(soc_shutdown, soh_shutdown);
+  });
+}
+
+void Battery::set_state(bool state)
+{
+  update();
+  simgrid::kernel::actor::simcall_answered([this, state] { active_ = state; });
+}
+
+void Battery::set_state_of_charge(double soc)
+{
+  xbt_assert(soc > 0 and soc <= 1, " : state of charge should be in ]0,1] (provided: %f)", soc);
+  simgrid::kernel::actor::simcall_answered([this, soc] { state_of_charge_ = soc; });
+}
+
+void Battery::set_state_of_charge_min(double soc)
+{
+  xbt_assert(soc > 0 and soc <= 1 and soc < state_of_charge_max_,
+             " : state of charge min should be in ]0,1] and below state of charge max (provided: %f)", soc);
+  simgrid::kernel::actor::simcall_answered([this, soc] { state_of_charge_min_ = soc; });
+}
+
+void Battery::set_state_of_charge_max(double soc)
+{
+  xbt_assert(soc > 0 and soc <= 1 and soc > state_of_charge_min_,
+             " : state of charge max should be in ]0,1] and above state of charge min (provided: %f)", soc);
+  simgrid::kernel::actor::simcall_answered([this, soc] { state_of_charge_max_ = soc; });
+}
+
+void Battery::set_initial_capacity(double c)
+{
+  xbt_assert(c > 0, " : capacity should be > 0 (provided: %f)", c);
+  simgrid::kernel::actor::simcall_answered([this, c] { initial_capacity_wh_ = c; });
+}
+
+void Battery::set_capacity(double c)
+{
+  xbt_assert(c > 0, " : capacity should be > 0 (provided: %f)", c);
+  simgrid::kernel::actor::simcall_answered([this, c] { capacity_wh_ = c; });
+}
+
+void Battery::set_cycles(int c)
+{
+  xbt_assert(c > 0, " : cycles should be > 0 (provided: %d)", c);
+  simgrid::kernel::actor::simcall_answered([this, c] { cycles_ = c; });
+}
+
+void Battery::set_depth_of_discharge(double d)
+{
+  xbt_assert(d > 0 and d <= 1, " : depth of discharge should be in ]0, 1] (provided: %f)", d);
+  simgrid::kernel::actor::simcall_answered([this, d] { depth_of_discharge_ = d; });
+}
+
+void Battery::set_usable_capacity(double c)
+{
+  xbt_assert(c > 0 and c <= 1, " : usable capacity should be in ]0, 1] (provided: %f)", c);
+  simgrid::kernel::actor::simcall_answered([this, c] { usable_capacity_ = c; });
+}
+
+void Battery::set_charge_efficiency(double e)
+{
+  xbt_assert(e > 0 and e <= 1, " : charge efficiency should be in [0,1] (provided: %f)", e);
+  simgrid::kernel::actor::simcall_answered([this, e] { charge_efficiency_ = e; });
+}
+
+void Battery::set_discharge_efficiency(double e)
+{
+  xbt_assert(e > 0 and e <= 1, " : discharge efficiency should be in [0,1] (provided: %f)", e);
+  simgrid::kernel::actor::simcall_answered([this, e] { discharge_efficiency_ = e; });
+}
+
+void Battery::set_eval_cost(bool eval)
+{
+  simgrid::kernel::actor::simcall_answered([this, eval] { eval_cost_ = eval; });
+}
+
+void Battery::set_investment_cost(double c)
+{
+  xbt_assert(c >= 0, " : investment cost should be >= 0 (provided: %f)", c);
+  simgrid::kernel::actor::simcall_answered([this, c] { investment_cost_per_wh_ = c; });
+}
+
+void Battery::set_static_maintenance_cost(double c)
+{
+  xbt_assert(c >= 0, " : static maintenance cost should be >= 0 (provided: %f)", c);
+  simgrid::kernel::actor::simcall_answered([this, c] { static_maintenance_cost_per_wh_times_h_ = c; });
+}
+
+void Battery::set_variable_maintenance_cost(double c)
+{
+  xbt_assert(c >= 0, " : variable maintenance cost should be >= 0 (provided: %f)", c);
+  simgrid::kernel::actor::simcall_answered([this, c] { variable_maintenance_cost_per_wh_ = c; });
+}
+
+bool Battery::is_charging()
+{
+  update();
+  return power_w_ < 0;
+}
+
+bool Battery::is_active() const
+{
+  return active_;
+}
+
+double Battery::get_power()
+{
+  update();
+  return power_w_;
+}
+
+double Battery::get_state_of_charge()
+{
+  update();
+  return state_of_charge_;
+}
+
+double Battery::get_state_of_charge_min()
+{
+  return state_of_charge_min_;
+}
+
+double Battery::get_state_of_charge_max()
+{
+  return state_of_charge_max_;
+}
+
+double Battery::get_state_of_health()
+{
+  update();
+  return 1 - (energy_exchanged_j_ / energy_budget_j_);
+}
+
+double Battery::get_capacity()
+{
+  update();
+  return capacity_wh_;
+}
+
+double Battery::get_cumulative_cost()
+{
+  update();
+  return cumulative_cost_;
+}
+
+double Battery::get_next_event_date()
+{
+  update();
+  return next_event_;
+}
+
+void Battery::init_battery_params()
+{
+  const char* prop_chars;
+  prop_chars = host_->get_property("battery_capacity");
+  if (prop_chars) {
+    set_capacity(xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+    set_initial_capacity(xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  }
+  prop_chars = host_->get_property("battery_usable_capacity");
+  if (prop_chars)
+    set_usable_capacity(xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_depth_of_discharge");
+  if (prop_chars)
+    set_depth_of_discharge(
+        xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_cycles");
+  if (prop_chars)
+    set_cycles(xbt_str_parse_int(prop_chars, ("cannot parse int: " + std::string(prop_chars)).c_str()));
+  simgrid::kernel::actor::simcall_answered([this] {
+    energy_budget_j_ = (initial_capacity_wh_ * usable_capacity_ * depth_of_discharge_ * 3600 * cycles_ * 2);
+  });
+  prop_chars = host_->get_property("battery_active");
+  if (prop_chars)
+    set_state(xbt_str_parse_int(prop_chars, ("cannot parse int: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_state_of_charge_min");
+  if (prop_chars)
+    set_state_of_charge_min(
+        xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_state_of_charge_max");
+  if (prop_chars)
+    set_state_of_charge_max(
+        xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_charge_efficiency");
+  if (prop_chars)
+    set_charge_efficiency(
+        xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_discharge_efficiency");
+  if (prop_chars)
+    set_discharge_efficiency(
+        xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_state_of_charge");
+  if (prop_chars)
+    set_state_of_charge(xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_eval_cost");
+  if (prop_chars)
+    set_eval_cost(xbt_str_parse_int(prop_chars, ("cannot parse int: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_investment_cost");
+  if (prop_chars)
+    set_investment_cost(xbt_str_parse_int(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_static_maintenance_cost");
+  if (prop_chars)
+    set_static_maintenance_cost(
+        xbt_str_parse_int(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_variable_maintenance_cost");
+  if (prop_chars)
+    set_variable_maintenance_cost(
+        xbt_str_parse_int(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  prop_chars = host_->get_property("battery_power");
+  if (prop_chars)
+    set_power(xbt_str_parse_double(prop_chars, ("cannot parse double: " + std::string(prop_chars)).c_str()));
+  simgrid::kernel::actor::simcall_answered([this] { last_updated_ = simgrid::s4u::Engine::get_clock(); });
+}
+
+void Battery::update()
+{
+  simgrid::kernel::actor::simcall_answered([this] {
+    double now             = simgrid::s4u::Engine::get_clock();
+    double time_delta_real = now - last_updated_;
+    if (time_delta_real <= 0 or not is_active())
+      return;
+    double time_delta_until_event = next_event_ - last_updated_;
+    bool event                    = next_event_ != -1 and time_delta_until_event <= time_delta_real;
+    double power_real_w           = power_w_ < 0 ? power_w_ * charge_efficiency_ : power_w_ / discharge_efficiency_;
+    state_of_charge_ -= power_real_w * (event ? time_delta_until_event : time_delta_real) / (3600 * capacity_wh_);
+    energy_exchanged_j_ += (event ? time_delta_until_event : time_delta_real) * abs(power_real_w);
+    capacity_wh_ = initial_capacity_wh_ * usable_capacity_ * (1 - (energy_exchanged_j_ / energy_budget_j_)) +
+                   initial_capacity_wh_ * (1 - usable_capacity_);
+    capacity_wh_ = std::max(capacity_wh_, 0.0);
+    if (eval_cost_) {
+      double usage_cost_per_wh =
+          (investment_cost_per_wh_ / (depth_of_discharge_ * cycles_ * 2) + variable_maintenance_cost_per_wh_);
+      double usage_cost =
+          usage_cost_per_wh * abs(power_real_w) * (event ? time_delta_until_event : time_delta_real) / 3600;
+      double static_maintenance_cost =
+          static_maintenance_cost_per_wh_times_h_ * initial_capacity_wh_ * time_delta_real / 3600;
+      cumulative_cost_ += usage_cost + static_maintenance_cost;
+    }
+    if (event) {
+      power_w_    = 0;
+      next_event_ = -1;
+    }
+    last_updated_ = now;
+  });
+}
+
+Battery::Battery(simgrid::s4u::Host* host) : host_(host)
+{
+  init_battery_params();
+}
+
+Battery::~Battery() = default;
+} // namespace simgrid::plugin
+
+using simgrid::plugin::Battery;
+
+/* **************************** events  callback *************************** */
+
+static void on_creation(simgrid::s4u::Host& host)
+{
+  if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
+    return;
+  host.extension_set(new Battery(&host));
+}
+
+/* **************************** Public interface *************************** */
+
+static void ensure_plugin_inited()
+{
+  if (not Battery::EXTENSION_ID.valid())
+    throw simgrid::xbt::InitializationError("The Battery plugin is not active. Please call sg_battery_plugin_init() "
+                                            "before calling any function related to that plugin.");
+}
+
+/** @ingroup plugin_battery
+ *  @brief Enable battery plugin.
+ */
+void sg_battery_plugin_init()
+{
+  if (Battery::EXTENSION_ID.valid())
+    return;
+  Battery::EXTENSION_ID = simgrid::s4u::Host::extension_create<Battery>();
+  simgrid::s4u::Host::on_creation_cb(&on_creation);
+}
+
+/** @ingroup plugin_battery
+ *  @param state The state to set.
+ *  @brief Set the state of the battery.
+ * A battery set to inactive (false) will neither update its state of charge nor its state of health.
+ */
+void sg_battery_set_state(const_sg_host_t host, bool state)
+{
+  ensure_plugin_inited();
+  host->extension<Battery>()->set_state(state);
+}
+
+/** @ingroup plugin_battery
+ *  @param power The power to set in W.
+ *  @brief Set the power of the battery.
+ *  @note A negative value makes the battery act as a load and charge.
+ * A positive value makes the battery act as a generator and discharge.
+ */
+void sg_battery_set_power(const_sg_host_t host, double power)
+{
+  ensure_plugin_inited();
+  host->extension<Battery>()->set_power(power);
+}
+
+/** @ingroup plugin_battery
+ *  @brief Return true if the battery is active.
+ */
+bool sg_battery_is_active(const_sg_host_t host)
+{
+  ensure_plugin_inited();
+  return host->extension<Battery>()->is_active();
+}
+
+/** @ingroup plugin_battery
+ *  @brief Return the power of the battery in W.
+ *  @note A negative value indicates that the battery act as a load and charge.
+ * A positive value indicates that the battery act as a generator and discharge.
+ */
+double sg_battery_get_power(const_sg_host_t host)
+{
+  ensure_plugin_inited();
+  return host->extension<Battery>()->get_power();
+}
+
+/** @ingroup plugin_battery
+ *  @brief Return the state of charge of the battery.
+ */
+double sg_battery_get_state_of_charge(const_sg_host_t host)
+{
+  ensure_plugin_inited();
+  return host->extension<Battery>()->get_state_of_charge();
+}
+
+/** @ingroup plugin_battery
+ *  @brief Return the minimal state of charge of the battery.
+ */
+double sg_battery_get_state_of_charge_min(const_sg_host_t host)
+{
+  ensure_plugin_inited();
+  return host->extension<Battery>()->get_state_of_charge_min();
+}
+
+/** @ingroup plugin_battery
+ *  @brief Return the maximal state of charge of the battery.
+ */
+double sg_battery_get_state_of_charge_max(const_sg_host_t host)
+{
+  ensure_plugin_inited();
+  return host->extension<Battery>()->get_state_of_charge_max();
+}
+
+/** @ingroup plugin_battery
+ *  @brief Return the state of health of the battery.
+ */
+double sg_battery_get_state_of_health(const_sg_host_t host)
+{
+  ensure_plugin_inited();
+  return host->extension<Battery>()->get_state_of_health();
+}
+
+/** @ingroup plugin_battery
+ *  @brief Return the capacity of the battery in Wh.
+ *  @note capacity is reduced by the state of health of the battery.
+ */
+double sg_battery_get_capacity(const_sg_host_t host)
+{
+  ensure_plugin_inited();
+  return host->extension<Battery>()->get_capacity();
+}
+
+/** @ingroup plugin_battery
+ *  @brief Return the cumulative cost of the battery.
+ */
+double sg_battery_get_cumulative_cost(const_sg_host_t host)
+{
+  ensure_plugin_inited();
+  return host->extension<Battery>()->get_cumulative_cost();
+}
+
+/** @ingroup plugin_battery
+ *  @brief Return the date of the next event, i.e., when the battery will be empty or full.
+ *  @note If power is null then return -1.
+ */
+double sg_battery_get_next_event_date(const_sg_host_t host)
+{
+  ensure_plugin_inited();
+  return host->extension<Battery>()->get_next_event_date();
+}
index 6cc2d4c..7f458ab 100644 (file)
@@ -453,6 +453,7 @@ set(PLUGINS_SRC
   src/plugins/vm/VmLiveMigration.cpp
   src/plugins/vm/VmLiveMigration.hpp
   src/plugins/vm/dirty_page_tracking.cpp
+  src/plugins/battery.cpp
   )
 
 
@@ -631,6 +632,7 @@ set(headers_to_install
   include/simgrid/chrono.hpp
   include/simgrid/plugins/dvfs.h
   include/simgrid/plugins/energy.h
+  include/simgrid/plugins/battery.hpp
   include/simgrid/plugins/file_system.h
   include/simgrid/plugins/live_migration.h
   include/simgrid/plugins/load.h
@@ -874,17 +876,10 @@ set(DOC_SOURCES
   docs/source/tuto_s4u/master-workers-lab4.cpp
 
   docs/source/Tutorial_DAG.rst
-  docs/source/tuto_dag/dag_lab1.cpp
-  docs/source/tuto_dag/dag_lab2-1.cpp
-  docs/source/tuto_dag/dag_lab2-2.cpp
-  docs/source/tuto_dag/dag_lab2-3.cpp
-  docs/source/tuto_dag/img/dag1.svg
-  docs/source/tuto_dag/img/dag2.svg
-  docs/source/tuto_dag/img/dag.svg
-  docs/source/tuto_dag/simple_dax.xml
-  docs/source/tuto_dag/simple_dot.dot
-  docs/source/tuto_dag/simple_json.json
-  docs/source/tuto_dag/small_platform.xml
+  docs/source/img/battery_degradation.svg
+  docs/source/img/dag1.svg
+  docs/source/img/dag2.svg
+  docs/source/img/dag.svg
 
   docs/source/Tutorial_MPI_Applications.rst
   docs/source/tuto_smpi/3hosts.png
@@ -1076,6 +1071,7 @@ set(CMAKE_SOURCE_FILES
   )
 
 set(PLATFORMS_EXAMPLES
+  examples/platforms/battery_platform.xml
   examples/platforms/bypassRoute.xml
   examples/platforms/bypassZoneRoute.xml
   examples/platforms/cloud.xml