Sunday, August 23, 2015

Perkun. Payoff.

We know already how to declare Perkun (http://sourceforge.net/projects/perkun/) values and variables (see the previous posts). We know that the agent i.e. Perkun program can see the input variables and can control the output variables. The question is how to control the output variables. What do we want to achieve? What is "good" for the agent and what is not?

In order to define it we use the payoff section of the Perkun program. The most simple Perkun program contains four following sections:

values {}
variables {}
payoff {}
model {}

When you place the above text in a file and run perkun it will do nothing. Try replacing it with the following code:

values
{
        value false, true;
        value move, do_nothing;
}

variables
{
        input variable what_I_can_see:{false, true};
        output variable action:{move, do_nothing};
}

payoff
{
        set({what_I_can_see=>false},0.0);
        set({what_I_can_see=>true},1.0);
}


model {}

cout << payoff << eol;

It will print out the contents of the payoff section:

# payoff
what_I_can_see=false payoff 0
what_I_can_see=true payoff 1


The payoff section contains the commands "set" with two arguments:
  1. input state query
  2. payoff value (a real number)
The query contains all input variables followed by "=>" and the corresponding value, separated by commas, enclosed in curly brackets. In short it is an expression:

{INPUT_VARIABLE1=>VALUE,INPUT_VARIABLE2=>VALUE,...}

Note that the query must contain all the input variables.

What does the payoff value mean? It is a value representing "how good" the payoff function is (for the respective combination of the input variable values). The higher the payoff value the "better" it is. In the example above the agent "likes" to see the value "true" on its input (variable what_I_can_see), while it dislikes the value "false", because for "true" the payoff value equals 1.0, while for "false" it equals 0.0.


You already know three different instructions that can follow the model section:
  • cout << values << eol;
  • cout << variables << eol;
  • cout << payoff << eol;

What happens if you fail to specify payoff for some or all input variables values combinations? It will be random. Try:

values {}
variables {}
payoff {}
model {}
cout << payoff << eol;

Anyway it does not make much sense since in this case the payoff function is constant (there are no input variables).

Try:
values
{
        value false, true;
        value move, do_nothing;
}

variables
{
        input variable what_I_can_see:{false, true};
        output variable action:{move, do_nothing};
}

payoff {}

model {}
cout << payoff << eol;

After running the above code with perkun you will see random values for both "false" and "true" of the input variable what_I_can_see.



No comments:

Post a Comment