def test_language_mars_rovers_load_cpfs(): mr_reader = rddl.Reader('tests/data/rddl/Mars_Rover.rddl') # create sorts and initialize constants domain = mr_reader.rddl_model.domain _ = mr_reader.rddl_model.non_fluents mr_reader.translate_rddl_model() # collect state cpfs state_cpfs = [] for f in domain.state_cpfs: state_cpfs += [rddl.translate_expression(mr_reader.language, f.expr)] # collect intermediate cpfs intermediate_cpfs = [] for f in domain.intermediate_cpfs: intermediate_cpfs += [rddl.translate_expression(mr_reader.language, f.expr)] assert len(state_cpfs) + len(intermediate_cpfs) == 4
def test_language_reservoir_load_cpfs(): res_reader = rddl.Reader('tests/data/rddl/Reservoir.rddl') # create sorts and initialize constants domain = res_reader.rddl_model.domain _ = res_reader.rddl_model.non_fluents res_reader.translate_rddl_model() # collect state cpfs state_cpfs = [] for f in domain.state_cpfs: state_cpfs += [rddl.translate_expression(res_reader.language, f.expr)] intermediate_cpfs = [] for f in domain.intermediate_cpfs: intermediate_cpfs += [rddl.translate_expression(res_reader.language, f.expr)] assert len(state_cpfs) + len(intermediate_cpfs) == 5
def test_language_mars_rovers_load_reward(): mr_reader = rddl.Reader('tests/data/rddl/Mars_Rover.rddl') # create sorts and initialize constants domain = mr_reader.rddl_model.domain _ = mr_reader.rddl_model.non_fluents mr_reader.translate_rddl_model() reward_func = rddl.translate_expression(mr_reader.language, domain.reward) assert isinstance(reward_func, Term)
def test_language_navigation_load_reward(): nav_reader = rddl.Reader('tests/data/rddl/Navigation.rddl') # create sorts and initialize constants domain = nav_reader.rddl_model.domain nav_reader.translate_rddl_model() reward_func = rddl.translate_expression(nav_reader.language, domain.reward) assert isinstance(reward_func, Term) assert nav_reader.parameters.horizon == 20 assert nav_reader.parameters.discount == 1.0 assert nav_reader.parameters.max_actions == 2
def test_language_mars_rovers_load_constraints(): mr_reader = rddl.Reader('tests/data/rddl/Mars_Rover.rddl') # create sorts and initialize constants domain = mr_reader.rddl_model.domain _ = mr_reader.rddl_model.non_fluents mr_reader.translate_rddl_model() precs = [] for prec in domain.preconds: precs += [rddl.translate_expression(mr_reader.language, prec)] assert len(precs) == 1 action_constraints = [] for c in domain.constraints: action_constraints += [rddl.translate_expression(mr_reader.language, c.expr)] assert len(action_constraints) == 0 state_constraints = [] for c in domain.invariants: state_constraints += [rddl.translate_expression(mr_reader.language, c.expr)] assert len(state_constraints) == 0
def test_language_navigation_load_constraints(): nav_reader = rddl.Reader('tests/data/rddl/Navigation.rddl') # create sorts and initialize constants domain = nav_reader.rddl_model.domain nav_reader.translate_rddl_model() precs = [] for prec in domain.preconds: precs += [rddl.translate_expression(nav_reader.language, prec)] assert len(precs) == 2 action_constraints = [] for c in domain.constraints: action_constraints += [rddl.translate_expression(nav_reader.language, c.expr)] assert len(action_constraints) == 0 state_constraints = [] for c in domain.invariants: state_constraints += [rddl.translate_expression(nav_reader.language, c.expr)] assert len(state_constraints) == 0
def test_language_reservoir_load_reward(): res_reader = rddl.Reader('tests/data/rddl/Reservoir.rddl') # create sorts and initialize constants domain = res_reader.rddl_model.domain _ = res_reader.rddl_model.non_fluents res_reader.translate_rddl_model() assert res_reader.parameters.horizon == 40 assert res_reader.parameters.discount == 1.0 assert res_reader.parameters.max_actions is None reward_func = rddl.translate_expression(res_reader.language, domain.reward) assert isinstance(reward_func, Term)