Execution scenario

This module allows the execution of solvers in clusters through the creation of execution scenarios. This module is scheduler agnostic, and only assumes a shared filesystem between the nodes of the cluster.

class optilog.running.SolverRunner(tasks, scenario_dir, submit_file, constraints, name=None, solver_path=None, solvers=None, logs=None, slots=1, seeds=1, working_dir=None, timestamp=True, unbuffer=True, runsolver=True)

Handles the creation of the execution scenario.

Parameters
  • tasks (Union[str, List[str]]) – Glob string that matches the instances to execute. A list of instances may also be provided.

  • scenario_dir (str) – Path where the execution scenario will be saved

  • submit_file (str) – Script used to submit a job to the cluster. The Execution Scenario is agnostic to the system where jobs will be executed. See the Examples for submit_command section for some examples of submission commands for different systems

  • constraints (ExecutionConstraints) – Defines the execution constraints for the Configuration Process

  • name – _description_, defaults to None

  • solver_path – _description_, defaults to None

  • solvers (Union[str, Dict[str, str], None]) – Either a dictionary or a string. If it is a dictionary, it must contain the name of the solvers as keys and the path to the solvers as values. If it is a string, it must point to a directory where the solvers will be located.

  • logs (Optional[str]) – Path used to save the logs of the execution (both stdout and stderr). By default, they are saved in a logs folder in the scenario directory.

  • slots (int) – Number of slots to reserve on the cluster. Usually corresponds with the number of execution threads.

  • seeds (Union[int, List[int], None]) – List of seeds for the execution.

  • working_dir (Optional[str]) – Working directory of execution environment. Defaults to the current working directory.

  • timestamp (bool) – Whether to record the timestamp of every line or not.

  • unbuffer (bool) – Whether to force the solver through the unbuffer command. unbuffer must be in the PATH.

  • runsolver (bool) – Whether to force the solver through the runsolver command. runsolver must be in the PATH. If runsolver is not enabled, OptiLog doesn’t overconsume resources (time and memory).

generate_scenario(log=True)

Generates all the files required for the scenario

Parameters

log (bool) – If True, will print a log to the console

>>> from optilog.running import SolverRunner
>>>
>>> running = SolverRunner(
>>>     solvers = "./solvers_test/*",
>>>     tasks="/share/instances/sat/sat2011/app/**/*.cnf.gz",
>>>     scenario_dir="./scenario",
>>>     submit_file="./enque_sge.sh",
>>>     constraints=ExecutionConstraints(
>>>         wall_time=5000,
>>>         memory='24G'
>>>     ),
>>>     unbuffer=False,  # true by default
>>>     runsolver=False,  # true by default
>>>     # by default:
>>>     # slots=1
>>>     # seeds=[1] (or it may also be a list. i.e [1,46,82])
>>>     # working_dir=None
>>>     # timestamp=True
>>> )
>>>
>>> running.generate_scenario()

We could also define the solvers explicitly:

>>> running = SolverRunner(
>>>     solvers = {
>>>         "glucose": "./path/to/glucose",
>>>         "cadical": "./path/to/cadical",
>>>     },
>>>     tasks="/share/instances/sat/sat2011/app/**/*.cnf.gz",
>>>     ...
>>> )
>>>

The solver will always be called with two arguments. The first one is the path to the instance and the second one is the seed. In this example we can see how we can adapt the glucose41 binary to accept parameters in this order:

glucose.sh

#!/bin/bash
./glucose41 -model -rnd-seed=$2 $1

The Execution Scenario is agnostic to the system where jobs will be executed. See the Examples for submit_command section for some examples of submission commands for different systems.

Then, you can use the optilog-scenario command to perform operations on the scenario.

Here are some examples:

# Launch all instances
> optilog-scenario ./example_glucose launch

# Launch all instances (overwrite previous logs)
> optilog-scenario ./example_glucose launch --overwrite

# Delete execution logs
> optilog-scenario ./example_glucose clean

# List all tasks. This will print the task's id and instance path.
> optilog-scenario ./example_glucose list

# Launch a specific task, overwrite the logs and use a different seed
> optilog-scenario ./example_glucose launch --overwrite --task 3 --seed 64

# Launch a specific task, overwrite the logs and use multiple seeds
> optilog-scenario ./example_glucose launch --overwrite --task 3 --seed 64,82

# Launch multiple tasks, overwrite the logs and use multiple seeds
> optilog-scenario ./example_glucose launch --overwrite --task 3,8,9 --seed 64,82

When the tasks have finished running, you can proceed to parse and analyze the results.

Please refer to the Parsing an execution scenario section to proceed.