Skip to content

Commit

Permalink
Small compiler fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-gimelfarb committed Jun 21, 2024
1 parent 96b8eb6 commit 17df5a8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pyRDDLGym_gurobi/core/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, rddl: RDDLLiftedModel,
rollout_horizon: int=None,
epsilon: float=1e-5,
float_range: Tuple[float, float]=(1e-15, 1e15),
model_params: Dict[str, object]={'NonConvex': 2},
model_params: Dict[str, object]=None,
piecewise_options: str='',
logger: Logger=None,
verbose: int=1) -> None:
Expand Down Expand Up @@ -62,6 +62,8 @@ def __init__(self, rddl: RDDLLiftedModel,
:param verbose: whether to print nothing (0), summary (1),
or detailed (2) messages to console
'''
if model_params is None:
model_params = {'NonConvex': 2}
self.plan = plan
if rollout_horizon is None:
rollout_horizon = rddl.horizon
Expand Down Expand Up @@ -110,6 +112,7 @@ def summarize_hyperparameters(self):
f' float_range ={self.float_range}\n'
f' float_equality_tol={self.epsilon}\n'
f' lookahead_horizon ={self.horizon}\n'
f' verbose ={self.verbose}\n'
f'Gurobi model hyper-params:\n'
f' user_args ={self.model_params}\n'
f' user_args_pw ={self.pw_options}')
Expand Down Expand Up @@ -159,7 +162,7 @@ def _compile_rollout(self, model, plan, params, subs, value_bounds: bool=False):

# logging
if self.logger is not None:
message = f'[info] compiling initial bound information for Gurobi:'
message = '[info] compiling initial bound information for Gurobi:'
for (name, (_, _, lb, ub, _)) in subs.items():
message += f'\n\t{name}, bounds=({lb}, {ub})'
self.logger.log(message + '\n')
Expand Down Expand Up @@ -280,7 +283,7 @@ def _compile_cpfs(self, model, subs) -> None:
_, expr = rddl.cpfs[cpf]
subs[cpf] = self._gurobi(expr, model, subs)

def _compile_reward(self, model, subs) -> object:
def _compile_reward(self, model, subs) -> tuple:
reward, _, lb, ub, _ = self._gurobi(self.rddl.reward, model, subs)
return reward, (lb, ub)

Expand Down

0 comments on commit 17df5a8

Please sign in to comment.