#
#
#

from phidias.Types import *
from phidias.Lib import *
from phidias.Main import *

class new_object(Procedure): pass
class weight(Belief): pass # weight('A', 30)
class threshold(SingletonBelief): pass
class select_container(Procedure): pass

def_vars('W', 'CandidateContainer', 'MinWeight', 'C', 'NewC', 'NewW', 'T')

new_object(W) >> [ select_container(W) ]

select_container(W) / weight(CandidateContainer, MinWeight) >> \
	[ select_container(W, CandidateContainer, MinWeight) ]

select_container(W, CandidateContainer, MinWeight) / (weight(NewC, NewW) & lt(NewW, MinWeight)) >> \
	[ select_container(W, NewC, NewW) ]

select_container(W, CandidateContainer, MinWeight) >> \
	[ show_line('Container selezionato ', CandidateContainer),
	  -weight(CandidateContainer, MinWeight),
	  "MinWeight = MinWeight + W",
	  +weight(CandidateContainer, MinWeight) ]

+weight(C, W) / (threshold(T) & gt(W, T)) >> \
	[ show_line('Svuotamento container ', C),
	  -weight(C, W), +weight(C, 0) ]

PHIDIAS.assert_belief(weight('A', 0))
PHIDIAS.assert_belief(weight('B', 0))
PHIDIAS.assert_belief(weight('C', 0))

PHIDIAS.run()
PHIDIAS.shell(globals())


