How to use the problog.logic.And function in problog

To help you get started, we’ve selected a few problog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thiagopbueno / mdp-problog / mdp-problog.py View on Github external
n = math.ceil(math.log2(len(self._action_atoms)))
		for i in range(1, n+1):
			f = Term('a{}'.format(i), p=Term('?'))
			self._action_decision_facts.append(f)
			self._db.add_fact(f)

		valuation = [0]*n
		for i in range(len(self._action_atoms)):
			body_atoms = []
			for pos in range(n):
				if valuation[pos] == 1:
					body_atoms.append(self._action_decision_facts[pos])
				else:
					body_atoms.append(~self._action_decision_facts[pos])

			body = And.from_list(body_atoms)
			head = self._action_atoms[i]
			r = head << body
			self._action_rules.append(r)
			self._db.add_clause(r)

			MDPProbLog.next_valuation(valuation)
github thiagopbueno / mdp-problog / mdp-problog.py View on Github external
def _build_value_function_rules(self):
		self._value_function_atoms = []
		n = len(self._next_state_atoms)
		valuation = [0]*n
		for i in range(2**n):
			body_atoms = []
			for pos in range(n):
				if valuation[pos] == 1:
					body_atoms.append(self._next_state_atoms[pos])
				else:
					body_atoms.append(~self._next_state_atoms[pos])
			body = And.from_list(body_atoms)
			head = Term('__s{}__'.format(i))
			self._value_function_atoms.append(head)
			rule = head << body
			self._db.add_clause(rule)

			value = Term('utility', head.with_probability(None), Constant(0.0))
			self._db.add_fact(value)

			MDPProbLog.next_valuation(valuation)