GithubHelp home page GithubHelp logo

ins's Introduction

FrancescoPerrone

ins's People

Contributors

francescoperrone avatar

Watchers

 avatar

ins's Issues

Change name -- lookup/2 inappropriate name

Since lookup/2 is a predicate that provide the ability of creating patterns to accessible worlds (accessible from the standpoint of a given state), it's name should be different, surely more descriptive.

Similarly for #6
Issues related.

action "take" allowed even if dead

Problem:
action "take" is possible even from those states where alive is 0.

Steps to reproduce:
on swipl listener query transient(_-hal-Set).

example output:
?- transient(_-hal-Set).
Set = [1, 2, 2, 1]-[lose, compensate, doNothing] ;
Set = [1, 2, 2, 0]-[lose, compensate, doNothing] ;
Set = [1, 1, 2, 1]-[lose, compensate, doNothing] ;
Set = [1, 1, 2, 0]-[lose, compensate, doNothing] ;
Set = [1, 0, 2, 1]-[lose, doNothing] ;
Set = [1, 0, 2, 0]-[lose, doNothing] ;
Set = [0, 2, 1, 1]-[take, buy, doNothing] ;
Set = [0, 2, 1, 0]-[take, doNothing] ;
Set = [0, 2, 0, 1]-[take, doNothing] ;
Set = [0, 2, 0, 0]-[take, doNothing] ;
Set = [0, 1, 1, 1]-[take, buy, doNothing] ;
Set = [0, 1, 1, 0]-[take, doNothing] ;
Set = [0, 1, 0, 1]-[take, doNothing] ;
Set = [0, 1, 0, 0]-[take, doNothing] ;
Set = [0, 0, 1, 1]-[take, doNothing] ;
Set = [0, 0, 1, 0]-[take, doNothing] ;
Set = [0, 0, 0, 1]-[take, doNothing] ;
Set = [0, 0, 0, 0]-[take, doNothing].

Marek's comment

I would not worry too much about technical details in Trevor's papers.
He is not very well informed about such matters. This is how it goes. In
general.

First, you specify a language -- a set of atoms/variables -- that will
be used to represent states. You can call the state variables/atoms
'attributes' if you like. (Though 'attributes' is usually used for
properties of an object rather than a state. It doesn't matter. Call it
what you want.) For each of these you define a domain -- this is the set
of values that each state variable/attribute can take. We will assume it
is finite, and for simplicity that each domain has at least two
elements. Ordinary boolean atoms/variables/attributes are just a special
case.

One natural way to represent in Prolog is like this. (There are other ways.)

attributes([f,r,a,n]).  % just an example !

domain(f, [1,0]).
domain(r, [good,neutral,bad]).
domain(a, [happy,sad]).
domain(n, [1,2,3,4]).

Now every model of this language consists of an interpretation, which is
a mapping which for every state assigns a value to every attribute. It
is usual, for simplicity, to identify states with the values of
attributes, i.e., in the example there is exactly one state which has
values f=1, r=neutral, a=sad, n=3 (say). (In general there may be many
states which have the same values for all attributes. It is usual to
ignore that.)

So a state is a set of values, one for each attribute. Now there are
many ways to represent sets in Prolog, more or less efficient, more or
less complicated. We don't have to care about efficiency in these small
examples. Let us keep it simple.

So a state will be represented by a simple list of values, like this:

   [1,neutral,happy,3]

In this representation we know which value is for which attribute
because the order is fixed. (There are other ways to do it.) Obviously
we have to remember the order. That can be awkward.

One way to do it is like this. Define a predicate

   value(Attribute,State,Val)

which, given an Attribute and a (representation of a) State, will give
the corresponding value. This way you don't have to remember the order
-- you just call 'value' when you need it. For the example the simplest
way is like this:

value(f, State, Val) :-
   State = [Val,_,_,_],
   domain(f,Dom),
   member(Val,Dom).
value(r, State, Val) :-
   State = [_,Val,_,_],
   domain(r,Dom),
   member(Val,Dom).
value(a, State, Val) :-
   State = [_,_,Val,_],
   domain(a,Dom),
   member(Val,Dom).
value(n, State, Val) :-
   State = [_,_,_,Val],
   domain(n,Dom),
   member(Val,Dom).

This is a bit tedious to set up but you only have to do it once and it
is very simple.

What are the valid states? Those satisfying:

state(State) :-
   value(f, State, _),
   value(r, State, _),
   value(a, State, _),
   value(n, State, _).

The above will work, and is even reasonably efficient. But you might
find it a bit awkward, or not very convenient, or tedious to set up.

Refinement 1

Let us separate the representation of a state --- the order in the list
in which the attributes appear --- from the check that each attribute
has a valid value. We can do this by introducing an auxiliary predicate
-- call it 'attribute' say -- which specifies the pattern of the list
representing a state. Like this:

attribute(f, State, Val) :-
   State = [Val,_,_,_].
attribute(r, State, Val) :-
   State = [_,Val,_,_].
attribute(a, State, Val) :-
   State = [_,_,Val,_].
attribute(n, State, Val) :-
   State = [_,_,_,Val].

Now we have one general definition for 'value', like this:

value(Attribute,State,Val) :-
   attribute(Attribute,State,Val),
   domain(Attribute,Dom),
   member(Val,Dom).

The rest stays the same. In particular we still have

state(State) :-
   value(f, State, _),
   value(r, State, _),
   value(a, State, _),
   value(n, State, _).

Maybe you don't like this, or find it inconvenient.

So here is another possible way. (There are many others.)

Refinement 2

We have the list of possible attributes. So we can construct the
possible states by means of a recursive program, like this:

attributes([f,r,a,n]).  % just an example !

domain(f, [1,0]).
domain(r, [good,neutral,bad]).
domain(a, [happy,sad]).
domain(n, [1,2,3,4]).


state(State) :-
   attributes(Attributes),
   state2(Attributes,State). % an auxiliary predicate

state2([],[]).
state2([Attribute|Rest], [Val|More]) :-
   domain(Attribute,Dom),
   member(Val,Dom),
   state2(Rest, More).

You never call state2 directly. It is just an auxiliary predicate. A
query state(S) will generate all the valid states. You can also use it
to check that a given state S is valid, obviously.

If you want, you can also adjust 'value' in similar style. And now we
don't need the auxiliary predicate 'attribute' any more. Like this:

value(Attribute,State,Val) :-
   attributes(Attributes),
   value4(Attribute,Attributes,State,Val).

value4(Attribute,[Attribute|_],[Val|_],Val) :-
   domain(Attribute,Dom),
   member(Val,Dom).
value4(Attribute,[_|MoreAttributes],[_|RestState],Val) :-
   value4(Attribute,MoreAttributes,RestState,Val).

Again, you never call value4 directly -- it is just an auxiliary helper.
You call 'value' when you want to access or to set the value of an
attribute in a particular state. There is a bit of inefficiency here but
for these tiny examples it does no harm.

For instance, in the above, if you want to generate all states S which
have value 1 for attribute f and value 3 for attribute n, you call the
query:

?- state(S), value(f,S,1), value(n,S,3).

Or use any combination of the above methods. Whichever you find most
convenient.

We can discuss further on Monday if you like.

m

On transitions and joint actions

According to Bench-Capon paper, a transition between two states take place by performing a joint action from the initial state to get to the next state. At the moment the implementation does not perform a joint action in a transition.

Also, the implementation of a joint action has to be improved.

Contingency in predicates

Check that the contingency created by world/1 and restriction/1 is healthy through out all predicates.

action(State-Ag, lose):-
    agent(Ag),
    world(State-Ag),
    insulin(State, 1).

world(State-Ag):-
    state(State),
    agent(Ag),
    restriction(State).

restriction(State):-
    state(State),
    insulin(State, 1) -> alive(State, 2).
restriction(State):-
   state(State),
    insulin(State, 0) -> alive(State, Val),
    member(Val, [1,0]).

On the meaning of actions and their performance

What is the meaning of an action?
What does it mean to perform an action?
How does the performance of an action affect the status of the shops attribute?
Does it make sense to include lose in the set of actions?

Improve names of propositional variables

I would like to improve the propositional variables' names I used in the predicate transmute/2.

Following the paper, names should be like following:

loseInsulin-Ag
hasMoney-Ag
isAlive-Ag
world-Ag

State representation hard to read

If possible, improve the representation of the state for a given agent.

Current representation:

    [1, 2, 2, 1]-hal

Too long, specially if you want to add a complex label in the transitions.

Temporary predicates name change

Find a proper name for the ancillary predicates x/2 and y/2.

y(State-Ag, State-PossibleAction):-
    state(State), agent(Ag),
    findall(Action, action(State-Ag, Action), PossibleAction),
    setFormat.

x(State-Ag, Pi):-
    agent(Ag),
    (insulin(State, 1) *-> I = insulin-Ag; I = not_insulin-Ag),
    (money(State, M), mem(M, [1,2]) *-> D = money-Ag; D = not_money-Ag),
    (alive(State, A), mem(A, [1,2]) *-> E = alive-Ag; E = not_alive-Ag),
    (time(State, 1) *-> T = open; T = closed),
    Pi = [I, D, E, T].

Agents in values.pl

make sure it makes sense to have Ag in both promotes/4 demotes/4, neutral/4 and also in promotes/4 demotes/4.. and so on. Make sure it has a good meaning to hava agent/1 in states.pl

To does before finalising

  • refine transition/3 in tmp/trans.pl
  • refine jact/2 in jact.pl
  • see if promote/2 and demote/2 can be joint into affect/2
  • restrict state to one without shops attribute. This complicate the model and it's not how it changes.
  • refine values/s. Set V is not really needed.
  • explain why your goal state has 2 elements and not 3
  • intial/1, cstate/1 in initial.pl and compare/4 in trans.pl are still not general. Improve.

Action "take" allowed even if dead!

Comment:
Here, only doNothing should be permitted.

Steps to reproduce:

  1. on swipl listener
  2. query lookup([0, 2, 0, 0]-hal, State).

Problem:
One of the action permitted is: "take".
This should not be possible since alive is 0.

?- lookup([0, 2, 0, 0]-hal, State).
State = take-[1, 2, 2, 0]-hal ;
State = doNothing-[0, 2, 0, 0]-hal ;
false.

Action "lose" has unexpected outcomes

Problem:
Performing action "lose" on [1, 1, 2, 0]-hal gives unexpected results.

Steps to reproduce:

  1. swipl listener
  2. query ?- lookup2([1, 1, 2, 0]-hal, State).

Example output:

?- lookup2([1, 1, 2, 0]-hal, State).
State = [lose-[0, 1, 1, 0], lose-[0, 1, 0, 0], compensate-[1, 0, 2, 0], doNothing-[1, 1, 2, 0]].

Expected result:
The expected result is:

State = [lose-[0, 1, 1, 0], lose-[0, 1, 1, 0], compensate-[1, 0, 2, 0], doNothing-[1, 1, 2, 0]].

Actions are unique to agents?

From Bench-Capon (2006) p 4

Each agent i is associated with a set Aci of possible actions and
[...] actions are unique to agents.

Check this is the case in the code.

Wrong transition for "time"

Problem:
At the moment all transition do not respect the description on the paper.

Step to reproduce:

  1. open swipl in terminal
  2. consult test
  3. run any lookup/2 query

Expected Output:

?- lookup([0,2,1,0]-hal, NextState).
NextState = (take-->[1, 2, 2, 1]-hal) ;
NextState = (doNothing-->[0, 2, 0, 1]-hal) ;
false.

Actual Output:

?- lookup([0,2,1,0]-hal, NextState).
NextState = (take-->[1, 2, 2, 0]-hal) ;
NextState = (doNothing-->[0, 2, 0, 0]-hal) ;
false.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.