Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Modules
- :- use_module(library(lists)).
- % Files to include
- :- ensure_loaded('iterator.pl').
- :- ensure_loaded('formulation.pl').
- :- ensure_loaded('choices2.pl').
- :- ensure_loaded('iconics.pl').
- :- ensure_loaded('utilities.pl').
- %--------------------------------------------
- policy_value(Species, Policy_value) :-
- species_policy(Species, Policy),
- create_tarcs(Policy),
- discount(Gamma),
- all_nodes(Nodes),
- values(Nodes, Gamma, Values),
- average(Values, Policy_value).
- create_tarcs(Policy) :-
- retractall(tarc(_, _, _, _)),
- forall(arc(X, A, Y), add_tarc(X, A, Y, Policy)).
- add_tarc(Icon, _, _, _) :-
- iconic_goal(Icon), !.
- add_tarc((StateN, Perception), A, (StateDestN, PerceptionDest),
- Policy) :-
- member((Perception, A), Policy), !,
- state(StateDestN, StateDest),
- reward(StateDestN, PerceptionDest, Reward),
- probability(A, StateDest, PerceptionDest, Probability),
- assert(tarc((StateN, Perception),
- Probability, Reward,
- (StateDestN, PerceptionDest))).
- add_tarc(_, _, _, _).
- reward(State, Perception, Reward) :-
- iconic_goal((State, Perception)), !,
- jackpot(Reward).
- reward(_, _, Reward) :- penalty(Reward).
- probability(dr, _, _, 1) :- !.
- probability(gr, _, _, 1) :- !.
- probability(_, State, Perception, 1) :-
- length(State, 0), perc(Perception, (s(0), _)), !.
- probability(_, _, Perception, 0.5) :-
- perc(Perception, (s(0), _)), !.
- probability(_, State, Perception, Probability) :-
- perc(Perception, (s(T), _)),
- length(State, StateL), count_occurences(T, State, Count),
- Probability is (0.5 * (StateL / Count)).
- count_occurences(E, List, Count) :-
- findall(Element, (member(Element, List), Element == E), Bag),
- length(Bag, Count).
- average(List, Average) :-
- sumlist(List, 0, Sum),
- length(List, Length),
- Average is (Sum / Length).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement