Sunday, September 6, 2015

Perkun API. Optimizer classes.

Perkun (http://sourceforge.net/projects/perkun/) provides an API allowing to extend it in your own programs. The central class containing the Perkun algorithm is perkun::optimizer:

It is possible to use Perkun just by instantiating the perkun::optimizer. However this would be not very convenient. The Perkun parser requires an instance of the class perkun::optimizer_with_all_data, which contains:
  • perkun::collection_of_values
  • perkun::collection_of_variables
  • perkun::collection_of_visible_states
  • perkun::collection_of_actions
Its base class relies only on the references to these classes instances. It is recommended to instantiate a class inherited from perkun::optimizer_with_all_data and redefine the virtual functions in it. The most important are two functions:

virtual void get_input(std::map<variable*, value*> & m, bool & eof);
virtual void execute(const action * a);

get_input fills the map with the pairs: (variable*,value*) and eventually sets the boolean flag eof, while execute executes the optimal action chosen by the Perkun algorithm. See the Perkun Wars project (http://sourceforge.net/projects/perkunwars/) to learn how these function work in the class npc. They use pipes to communicate with the parent process.


No comments:

Post a Comment