Main page

perkun is an experimental AI language. Attempts to maximize the expected value of the payoff function by appropriate choosing the actions (output variables values).

wlodkowic is a perkun extension. It allows adding some informations about the variables allowing reduction of the states.

zubr is a Java code generator based on the Perkun algorithm.

Abstract

Ever wondered why the IF..THEN pattern is too weak to achieve the real AI? Well, the point is that the outer world is complex and contains lots of parameters that we cannot directly perceive. This package contains a new optimization algorithm based on the concept of hidden variables. The hidden variables are used to construct a state of the agent which reflects its belief concerning the hidden state of its environment. There is nothing random here, no training, no neural networks. Just a pure new algorithm.

Installation

First download and unpack the perkun package:
$ gunzip perkun-0.1.7.tar.gz
Then untar the package:
$ tar -xvf perkun-0.1.7.tar
Enter the perkun-0.1.7 directory:
$ cd perkun-0.1.7
Configure the package: $ ./configure
If any errors occur fix them (install flex, bison, C++ compiler). Once the package has been succesfully configured you can build it:
$ make
It should build the perkun, wlodkowic and zubr. Then you are free to install them. You might need to switch to a superuser (root) using "su" to do it.
$ make install
Check that you can access perkun, wlodkowic and zubr. Read the manuals.
$ perkun -v
$ wlodkowic -v
$ zubr -v

Perkun examples

Perkun is an interpreter attempting to maximize the so called payoff function. Take a look at the manual (type "man perkun"). Enter the directory "examples" and take a look at the file example2_dorban.perkun.

example2_dorban.perkun

Dorban is a witcher. He is hunting a vampire. In any moment he can see where he is (one input variable called where_is_Dorban can have one of the three values: place_Wyzima, place_Novigrad and place_Shadizar. There is also another input variable do_I_see_vampire which can have value false or true. There is also a hidden variable where_is_vampire with the three possible places as values. Execute perkun with the example2_dorban.perkun as a parameter:
$ perkun example2_dorban.perkun
It will answer with a short info and a prompt: loop with depth 3
I expect the values of the variables: where_is_Dorban do_I_see_vampire
perkun>
Type two values:
place_Wyzima false
This means that Dorban is in Wyzima and that he cannot see the vampire.
The answer is:

belief:
where_is_vampire=place_Wyzima where_is_Dorban=place_Wyzima do_I_see_vampire=false 0.00000
where_is_vampire=place_Shadizar where_is_Dorban=place_Wyzima do_I_see_vampire=false 0.500000
where_is_vampire=place_Novigrad where_is_Dorban=place_Wyzima do_I_see_vampire=false 0.500000
optimal action:
action=goto_Shadizar

The answer contains the so called belief and the chosen optimal action (output variables value). The belief is a probability distribution. It says that the vampire must be in Shadizar (50%) or in Novigrad (50%). It knows that the vampire is not in Wyzima because Dorban is in Wyzima and he cannot see him. The optimal decision is goto_Shadizar. It could also be goto_Novigrad because it is equally possible to meet the vampire in both these places. Perkun constantly asks for new input variable values, produces a belief and the optimal action. When you use perkun in your own projects you must link your program against the libperkun library and run the interpreter as shown in the PerkunWars project (http://sourceforge.net/projects/perkunwars). Now let us enter "place_Shadizar false":
perkun> place_Shadizar false

belief:
where_is_vampire=place_Wyzima where_is_Dorban=place_Shadizar do_I_see_vampire=false 0.00000
where_is_vampire=place_Shadizar where_is_Dorban=place_Shadizar do_I_see_vampire=false 0.00000
where_is_vampire=place_Novigrad where_is_Dorban=place_Shadizar do_I_see_vampire=false 1.00000
optimal action:
action=goto_Novigrad
The decision is now to go to Novigrad and the belief reflects that now Dorban is CERTAIN the vampire must be there. Let us go there: perkun> place_Novigrad true
Now we inserted true as the second variable, which means that now Dorban can see the vampire. The belief won't change now and the optimal action will be do_nothing. How do we specify that Dorban should always follow the vampire? This is specified in the Perkun code, in the payoff section (take a look at example2_dorban.perkun and find "payoff"). Whenever it can see a vampire its payoff equals 100.0, while if he does not see him it is 0.0.

example3_pregor.perkun

Pregor is not a witcher, he is a normal human. He tries to avoid vampires. He also can be in one of the three places (Wyzima, Novigrad, Shadizar). If he can see the vampire - he goes somewhere else. Let us run perkun with the example3_pregor.perkun as a parameter:

loop with depth 3
I expect the values of the variables: where_is_Pregor do_I_see_vampire

Let us enter "place_Wyzima true":
perkun> place_Wyzima true

Now the belief will indicate that the vampire is in Wyzima and the optimal decision will be to go to Shadizar. Let us now type "place_Shadizar false":
perkun> place_Shadizar false
The belief will reflect now that the vampire is still in Wyzima, but because Pregor does not see him he decides to do nothing. It is not always necessary to know the values of the hidden variables in order to make a good decision. For example if we start "perkun example3_pregor.perkun" again:
$ perkun example3_pregor.perkun
We can tell the Pregor he is in Wyzima and cannot see the vampire:
perkun> place_Wyzima false
Now the belief will be:
belief:
where_is_vampire=place_Wyzima where_is_Pregor=place_Wyzima do_I_see_vampire=false 0.00000
where_is_vampire=place_Shadizar where_is_Pregor=place_Wyzima do_I_see_vampire=false 0.500000
where_is_vampire=place_Novigrad where_is_Pregor=place_Wyzima do_I_see_vampire=false 0.500000
optimal action:
action=do_nothing
And the optimal action will be do_nothing. So even though Pregor does not know where the vampire is he does not care. The point is he does not see the vampire.
Introducing hidden variables is an important extension of the traditional IF..THEN programming pattern. The more hidden variables we have the more complex the state of the agent is. IF..THEN is stateless. When we introduce the hidden variables we make the agent to understand the processes beneath the pure input and therefore we make the decisions to be rational. The hidden variables are just another way to represent the agent's state, his history.

Wlodkowic

Wlodkowic is a kind of Perkun on steroids. It is also an interpreter. If you write a medical system you may wonder why do we assume that all options are equally possible. For example a hidden variable patient_has_cancer should not assume that 50% is true and 50% false. The apriori distribution in nature is different, for example 10% is true and 90% false. Wlodkowic has a separate section (called apriori section) to address this issue. Also in Wlodkowic it is possible to enter a special knowledge about the variables denoting when it is not important to distinguish between certain values. Take a look at the wlodkowic examples in the "examples" directory. We might have a patient who can have disease_1 with the values true or false, and a hidden variable temperature with the values low, medium, high. We could tell Wlodkowic (in the "knowledge" section) that if the patient has the disease_1 then it is not important whether his temperature is low or medium. In other words we only need to consider two equivalence classes: {low,medium} and {high}. If we have an input variable patient_is_alive we might tell Wlodkowic that if patient is NOT alive then his temperature is not important at all. This allows to reduce the amount of states generated.

An important difference when you work with Wlodkowic is that it asks for each input variable separately and you can type multiple values there. This is interpreted as an equivalence class.
If you want to see a real application based on Wlodkowic I suggest you download my game http://sourceforge.net/projects/thragos. It is not a good game but it is a good example of how Wlodkowic can be used.

Zubr

Zubr is not an interpreter. It is a Java code generator. It is based on the same optimization algorithm as Perkun and Wlodkowic. Please take a look at example11_simple.zubr to see the Zubr specification structure. Try to run:

$ zubr example11_simple.zubr > Optimizer.java

This will create a Java source code containing an Optimizer class. Try out other zubr examples. Zubr is slightly better than Perkun or Wlodkowic because it does not create all the states initially. Instead it creates them on the fly, like a chess playing program. Please take a look at the zubr manual.