Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, program):
self._engine = DefaultEngine()
self._db = self._engine.prepare(PrologString(program))
self._gp = None
self._knowledge = None
def __init__(self, model, gamma, epsilon):
self._model = model
self._gamma = gamma
self._epsilon = epsilon
print(" >> Preprocessing program ...", end=" ")
start = time.clock()
self._db = self._eng.prepare(PrologString(model))
self._build_state_atoms()
self._get_action_atoms()
self._build_action_rules()
self._build_value_function_rules()
self._utilities = dict(self._eng.query(self._db, Term('utility', None, None)))
end = time.clock()
uptime = end-start
print("Done in {0:.3f}sec.".format(uptime))
print(" >> Relevant grounding ...", end=" ")
start = time.clock()
self._gp = self._eng.ground_all(self._db, target=None, queries=self._utilities.keys())
end = time.clock()
uptime = end-start
print("Done in {0:.3f}sec.".format(uptime))
def solve_problog(model, debug=False):
program = PrologString(model)
decisions, score, statistics = dtproblog(program)
if debug:
print('score: %s' % score)
for name, value in decisions.items():
print('%s: %s' % (name, value))
return (score, decisions)