<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Towards a Domain-Specific Language for Automated Network Management</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Coen De Roover Software Languages Lab</string-name>
          <email>coen.de.roover@vub.be</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Tim Molderez Software Languages Lab Vrije Universiteit Brussel Brussels</institution>
          ,
          <country country="BE">Belgium</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Vrije Universiteit Brussel Brussels</institution>
          ,
          <country country="BE">Belgium</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Wolfgang De Meuter Software Languages Lab Vrije Universiteit Brussel Brussels</institution>
          ,
          <country country="BE">Belgium</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>-Software applications involving networks, in a broad sense of the term, are becoming more complex and are deployed on a growing number of devices. These applications can involve wireless sensor networks, smart grids, intelligent traffic light systems, and so on. Manually managing such networks is becoming increasingly difficult. To automate this management process, this paper introduces the initial design of the Marlon domain-specific language. Marlon is suited to specify the desired management policies that should be achieved. It can automatically apply these policies using machine learning techniques, effectively reducing the amount of effort needed to manage such systems. Index Terms-domain-specific languages, multi-agent systems, machine learning</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>To illustrate the use of Marlon, we will discuss a small
example in this section. This example is situated in the
context of smart grids, i.e. an electrical grid where power
Tim Molderez is supported by the FWO-SBO-SMILE-IT project, funded
by the Research Foundation Flanders (FWO)
usage/production is monitored with the aim of making a more
efficient use of the available energy. An overview of the
example system is given in Fig. 1: it consists of a grid manager
and multiple houses each having a central heating system.
The role of the grid manager is to provide power to each
house, and to keep track of the total power usage. Each heating
system keeps track of how much power it consumes, and its
current temperature. The only policy we want to deploy in
this example is that each house should reach and maintain its
desired temperature.2</p>
      <p>The entire Marlon source code that specifies how to simulate
this system is given in Fig. 2. It also is possible to use Marlon
to deploy this system in a real environment, but this is not
discussed in more detail in this paper. Before examining the
code of Fig. 2 in more detail, it is important to note that
multiagent systems commonly are modeled as discrete systems,
which is also reflected in the design of Marlon. It means
that the execution of a multi-agent system corresponds to an
infinite main loop, where each iteration computes the next state
of the system, based on the state of the previous iteration.</p>
      <p>The code in Fig. 2 consists of four separate sections, each
defining a different part of the smart grid; the defworld
statement on lines 1-10 specifies the grid manager; the
defcomponent statement on lines 12-25 specifies the
central heating system of a house; the defagent statement on
lines 27-46 represents the specification of a house. Finally, the
defgoal statement on lines 48-68 specifies the goal/policy
that each house should reach its desired temperature.</p>
      <p>The code that initializes the entire system is the following:
House.create :h1
House.create :h2
House.add_goal :h1, ReachDesiredTemp
House.add_goal :h2, ReachDesiredTemp
{:ok, world} = World.start_link()
World.set_behaviour world, GridManager
World.add_agent world, :h1
World.add_agent world, :h2</p>
      <p>This code snippet creates two houses, installs the
ReachDesiredTemp policy in each house, initializes the
grid manager and adds the two houses to it.</p>
      <p>We can now examine the code in Fig. 2 in some more
detail. At each iteration of the simulation, the machine learning
algorithm must first make a decision, based on the goals
that have been specified. In our case, there only is the
ReachDesiredTemp goal, installed on both houses. Line
49 states that the goal should choose between the behaviours
of the centralheating component of a house, defined
on line 33. The CentralHeating component itself (lines
1225), has two behaviours: on or off. Let us assume that the
machine learning algorithm has currently decided to choose
the ”on” behaviour in both houses. These chosen behaviours
are now executed: the CentralHeating component updates the
2We chose this policy only for its simplicity. Marlon uses machine learning
to apply this policy, but there are simpler methods to implement a thermostat.
The use of machine learning can be demonstrated in more complex examples,
such as a grid where energy is traded between houses, and the optimal selling
price is learned. This is part of future work.
state of the house it belongs to by raising its temperature and
energy consumption (lines 14-20). After executing the chosen
component behaviours, each agent executes its step function
(lines 42-45) to make any further adjustments to its state. Once
this is done, the grid manager can update its global state, based
on each of the house’s states. More specifically, on lines 5-9,
the grid manager computes the total power consumption of
all houses. On this is done, one iteration of the system has
finished, and the next one can start.</p>
      <p>
        While walking through the code of this example, we have
not explained much yet regarding how the machine learning
algorithm works. The algorithm we have currently implemented
is a basic Q-learning [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] algorithm, in which a “Q-table” is
maintained to learn which action needs to be taken when
the system is in a given state. In this example, there are
only two actions: turning the heating component on, or off.
Representing the system’s state is more complex: as the system
can be in an infinite amount of different states, an abstraction
must be defined over the state in order to create a finite amount
of abstract states. This abstraction is defined on lines 51-57,
in which the current system state is mapped to either -1, 0
or 1. The 1 value represents an abstracted state where the
temperature is too hot; -1 is too cold, and 0 is just right.
Once the abstracted state space, and the list of possible actions
is defined, we only need to specify the reward function that
computes a reward value for a given combination of current
abstracted state, and the action that is taken. This function
is defined in lines 58-66. This completes the specification of
the ReachDesiredTemp goal. To illustrate the Q-learning
algorithm in action, Fig. 3 shows how the temperature of
one house (y-axis) changes per iteration (x-axis). The learning
algorithm keeps increasing the heating system’s temperature,
until it crosses the desired temperature (22 C) in iteration 20,
after which the temperature remains fairly stable. (Note that
the temperature slowly drops when the heating is turned off
due to line 43.)
      </p>
    </sec>
    <sec id="sec-2">
      <title>III. MARLON OVERVIEW After illustrating Marlon with an example, we can now describe the language’s concepts and informal semantics in general terms.</title>
      <p>The four main concepts used in the language are: world,
agents, components and goals.</p>
      <p>World - A Marlon multi-agent system has one ”world”,
an actor that maintains any global state in the system,
which is shared with all agents. The input_data and
output_data fields (lines 2-9 in Fig. 2) respectively define
which data the world receives from its agents, and which parts
of its state are published to all agents.</p>
      <p>Agent - An agent corresponds to an actor. The fields
field (line 28) specifies an agent’s internal state. The
components field lists which components are contained
by this agent. The input_data and output_data fields
respectively define which data the agent receives from the
world, and which parts of its state are published to the world.</p>
      <p>An agent also defines a ”step” function; this function is used
],
reward: fn (attributes, _components, _old_components, _knowledge, _old_knowledge, agent_state,
old_agent_state) -&gt;
target_temperature = attributes.target_temperature
if (abs(agent_state.temperature - target_temperature) &lt;= 1) do</p>
      <p>10000
else
old_difference = abs(old_agent_state.temperature - target_temperature)
new_difference = abs(agent_state.temperature - target_temperature)
if (old_difference &gt;= new_difference), do: 5, else: -500
end
end
],
output_data: [
{:data, :power_consumption,
fn(_components, agent_state, _knowledge) -&gt; agent_state[:power_consumption] end}
],
step: fn(_identifier, components, knowledge, agent_state) -&gt;
agent_state = %{agent_state | temperature: agent_state.temperature - 0.125} # Subtraction to account
for colder outside temperature
{components, agent_state}
end</p>
      <p>Fig. 2. Marlon code of the example smart grid
to compute the agents’ next state, based on its current state
and the world’s state.</p>
      <p>Component - A component is part of an agent. It can
(optionally) have its own internal state. It only contains a
number functions that define the possible behaviours of this
component. Only one of these functions is executed at each
iteration of the system. Which function will be executed is
determined by the machine learning algorithm. 3</p>
      <p>Goal - Finally, a goal specifies a desired property that
an agent should reach, by means of a Q-learning algorithm.</p>
      <p>The components field (line 49 in Fig. 2) determines which
components the machine learning algorithm can control. It is
possible to attach multiple goals to the same component, but a
weight function (not shown) should then be specified to
determine which goal has the highest priority. The attributes
field specifies any parameters that may be relevant to the goal.</p>
      <p>The state_fields field defines the abstract state space
used by the Q-learning algorithm, together with a function that
maps the current state to an abstracted state. Finally, there is
the reward function that computes a reward value for the
current state of the system, given the previous state.</p>
      <p>As mentioned before, the multi-agent systems implemented
with Marlon are discrete. The execution of such a system
corresponds to a loop where each iteration represents the
system’s next state. The pseudocode in Fig. 4 gives a more
precise idea of what happens in each iteration: first, for each
goal, an action/behaviour is selected from the components it
may affect. This selection is then executed. Next, all agents
make their output data available to the world, which the world
uses to update its input data. After this, all agent execute their
step function. Once this is done, the world publishes its output
data, and makes it available as the input data for all agents. The
computation of the system’s new current state is now finished,
and all that remains is to use the reward function of each goal
to compute how effective its chosen action was.</p>
      <p>3Alternatively, it also is possible to write your own function that chooses
which behaviour is executed, rather than letting the machine learning
algorithm choose.
1 step = 1
2 executeAndUpdate(step)
3
4 loop {
5 step++
6 Action selection + execution
7 executeAndUpdate(step)
8 Learning reward is computed
9 }
10
11 def executeAndUpdate(int x) {
12 Agents publish output data
13 World updates input data
14 World and all agents execute step x
15 World publishes output data
16 Agents update input data
17 }</p>
      <p>Regarding related work, there are several existing
frameworks and domain-specific languages that cater to specific
types of multi-agent systems:</p>
      <p>
        For instance, Frenetic [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] and Nettle [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] focus on
programming computer networks. TeenyLime [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], TinyDb [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and
Semantic Streams [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] tackle querying and composing data in
the area of wireless sensor networks. Whereas these papers do
not involve machine learning techniques to manage networks,
the work of Kara et al. [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] presents a learning-based framework
to automate smart grid management. While the example we
presented is also situated in a smart grid context, our aim for
Marlon is to focus on the more general domain of multi-agent
systems.
      </p>
    </sec>
    <sec id="sec-3">
      <title>V. CONCLUSION AND FUTURE WORK</title>
      <p>This paper has presented an initial version of Marlon, a
DSL for automating the management of multi-agent systems.
The DSL was illustrated by means of an example in a smart
grid context. As this initial version of the language was also
developed starting from this context, one direction of future
work is to apply the language in other types of multi-agent
systems, and to evolve and extend the language with new
features on an as-needed basis. We also need to evaluate
the language in terms of its expressiveness, how it compares
to frameworks/DSLs that focus on a specific domain, and
how effective Marlon it is at reaching its machine learning
goals. Another direction of future work is to add support
for collaboration among agents, so it becomes possible to
specify goals that span across groups of agents, rather than
only specifying goals that apply to individual agents.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Paolo</given-names>
            <surname>Costa</surname>
          </string-name>
          , Luca Mottola, Amy L Murphy,
          <article-title>and Gian Pietro Picco</article-title>
          .
          <article-title>Teenylime: transiently shared tuple space middleware for wireless sensor networks</article-title>
          .
          <source>In Proceedings of the international workshop on Middleware for sensor networks</source>
          , pages
          <fpage>43</fpage>
          -
          <lpage>48</lpage>
          . ACM,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Nate</given-names>
            <surname>Foster</surname>
          </string-name>
          , Rob Harrison, Michael J Freedman, Christopher Monsanto, Jennifer Rexford, Alec Story, and David Walker.
          <article-title>Frenetic: A network programming language</article-title>
          .
          <source>In ACM Sigplan Notices</source>
          , volume
          <volume>46</volume>
          , pages
          <fpage>279</fpage>
          -
          <lpage>291</lpage>
          . ACM,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>Leslie</given-names>
            <surname>Pack Kaelbling</surname>
          </string-name>
          , Michael L Littman, and Andrew W Moore.
          <article-title>Reinforcement learning: A survey</article-title>
          .
          <source>Journal of artificial intelligence research</source>
          ,
          <volume>4</volume>
          :
          <fpage>237</fpage>
          -
          <lpage>285</lpage>
          ,
          <year>1996</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Emre</given-names>
            <surname>Can</surname>
          </string-name>
          <string-name>
            <surname>Kara</surname>
          </string-name>
          , Mario Berges, Bruce Krogh, and
          <string-name>
            <given-names>Soummya</given-names>
            <surname>Kar</surname>
          </string-name>
          .
          <article-title>Using smart devices for system-level management and control in the smart grid: A reinforcement learning framework</article-title>
          .
          <source>In Smart Grid Communications (SmartGridComm)</source>
          ,
          <source>2012 IEEE Third International Conference on</source>
          , pages
          <fpage>85</fpage>
          -
          <lpage>90</lpage>
          . IEEE,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>Samuel</surname>
            <given-names>R Madden</given-names>
          </string-name>
          , Michael J Franklin, Joseph M Hellerstein,
          <string-name>
            <given-names>and Wei</given-names>
            <surname>Hong</surname>
          </string-name>
          .
          <article-title>Tinydb: an acquisitional query processing system for sensor networks</article-title>
          .
          <source>ACM Transactions on database systems (TODS)</source>
          ,
          <volume>30</volume>
          (
          <issue>1</issue>
          ):
          <fpage>122</fpage>
          -
          <lpage>173</lpage>
          ,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Andreas</given-names>
            <surname>Voellmy</surname>
          </string-name>
          and
          <string-name>
            <given-names>Paul</given-names>
            <surname>Hudak</surname>
          </string-name>
          .
          <article-title>Nettle: Taking the sting out of programming network routers</article-title>
          .
          <source>Practical Aspects of Declarative Languages</source>
          , pages
          <fpage>235</fpage>
          -
          <lpage>249</lpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>Christopher</surname>
            <given-names>JCH</given-names>
          </string-name>
          <string-name>
            <surname>Watkins and Peter Dayan</surname>
          </string-name>
          .
          <article-title>Q-learning</article-title>
          .
          <source>Machine learning</source>
          ,
          <volume>8</volume>
          (
          <issue>3</issue>
          -4):
          <fpage>279</fpage>
          -
          <lpage>292</lpage>
          ,
          <year>1992</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Kamin</given-names>
            <surname>Whitehouse</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Feng</given-names>
            <surname>Zhao</surname>
          </string-name>
          , and Jie Liu.
          <article-title>Semantic streams: A framework for composable semantic interpretation of sensor data</article-title>
          .
          <source>Wireless Sensor Networks</source>
          , pages
          <fpage>5</fpage>
          -
          <lpage>20</lpage>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>