Skip to content

Options module

Reference to the options.py module.

options

Options for working with the Nextroute engine.

Verbosity

Bases: str, Enum

Format of an Input.

OFF class-attribute instance-attribute

OFF = 'off'

The check engine is not run.

LOW class-attribute instance-attribute

LOW = 'low'

Low verbosity for the check engine.

MEDIUM class-attribute instance-attribute

MEDIUM = 'medium'

Medium verbosity for the check engine.

HIGH class-attribute instance-attribute

HIGH = 'high'

High verbosity for the check engine.

Options

Bases: BaseModel

Options for using Nextroute.

CHECK_DURATION class-attribute instance-attribute

CHECK_DURATION: float = 30

Maximum duration of the check, in seconds.

CHECK_VERBOSITY class-attribute instance-attribute

CHECK_VERBOSITY: Verbosity = OFF

Verbosity of the check engine.

FORMAT_DISABLE_PROGRESSION class-attribute instance-attribute

FORMAT_DISABLE_PROGRESSION: bool = False

Whether to disable the progression series.

MODEL_CONSTRAINTS_DISABLE_ATTRIBUTES class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_ATTRIBUTES: bool = False

Ignore the compatibility attributes constraint.

MODEL_CONSTRAINTS_DISABLE_CAPACITIES class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_CAPACITIES: list[str] = Field(
    default_factory=list
)

Ignore the capacity constraint for the given resource names.

MODEL_CONSTRAINTS_DISABLE_CAPACITY class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_CAPACITY: bool = False

Ignore the capacity constraint for all resources.

MODEL_CONSTRAINTS_DISABLE_DISTANCELIMIT class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_DISTANCELIMIT: bool = False

Ignore the distance limit constraint.

MODEL_CONSTRAINTS_DISABLE_GROUPS class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_GROUPS: bool = False

Ignore the groups constraint.

MODEL_CONSTRAINTS_DISABLE_MAXIMUMDURATION class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_MAXIMUMDURATION: bool = False

Ignore the maximum duration constraint.

MODEL_CONSTRAINTS_DISABLE_MAXIMUMSTOPS class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_MAXIMUMSTOPS: bool = False

Ignore the maximum stops constraint.

MODEL_CONSTRAINTS_DISABLE_MAXIMUMWAITSTOP class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_MAXIMUMWAITSTOP: bool = False

Ignore the maximum stop wait constraint.

MODEL_CONSTRAINTS_DISABLE_MAXIMUMWAITVEHICLE class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_MAXIMUMWAITVEHICLE: bool = False

Ignore the maximum vehicle wait constraint.

MODEL_CONSTRAINTS_DISABLE_MIXINGITEMS class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_MIXINGITEMS: bool = False

Ignore the do not mix items constraint.

MODEL_CONSTRAINTS_DISABLE_PRECEDENCE class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_PRECEDENCE: bool = False

Ignore the precedence (pickups & deliveries) constraint.

MODEL_CONSTRAINTS_DISABLE_STARTTIMEWINDOWS class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_STARTTIMEWINDOWS: bool = False

Ignore the start time windows constraint.

MODEL_CONSTRAINTS_DISABLE_VEHICLEENDTIME class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_VEHICLEENDTIME: bool = False

Ignore the vehicle end time constraint.

MODEL_CONSTRAINTS_DISABLE_VEHICLESTARTTIME class-attribute instance-attribute

MODEL_CONSTRAINTS_DISABLE_VEHICLESTARTTIME: bool = False

Ignore the vehicle start time constraint.

MODEL_CONSTRAINTS_ENABLE_CLUSTER class-attribute instance-attribute

MODEL_CONSTRAINTS_ENABLE_CLUSTER: bool = False

Enable the cluster constraint.

MODEL_OBJECTIVES_CAPACITIES class-attribute instance-attribute

MODEL_OBJECTIVES_CAPACITIES: str = ''

Capacity objective, provide triple for each resource name=default;factor=1.0;offset=0.0.

MODEL_OBJECTIVES_CLUSTER class-attribute instance-attribute

MODEL_OBJECTIVES_CLUSTER: float = 0.0

Factor to weigh the cluster objective.

MODEL_OBJECTIVES_DISTANCE class-attribute instance-attribute

MODEL_OBJECTIVES_DISTANCE: float = 0.0

Factor to weigh the distance objective.

MODEL_OBJECTIVES_EARLYARRIVALPENALTY class-attribute instance-attribute

MODEL_OBJECTIVES_EARLYARRIVALPENALTY: float = 1.0

Factor to weigh the early arrival objective.

MODEL_OBJECTIVES_LATEARRIVALPENALTY class-attribute instance-attribute

MODEL_OBJECTIVES_LATEARRIVALPENALTY: float = 1.0

Factor to weigh the late arrival objective.

MODEL_OBJECTIVES_MINSTOPS class-attribute instance-attribute

MODEL_OBJECTIVES_MINSTOPS: float = 1.0

Factor to weigh the min stops objective.

MODEL_OBJECTIVES_STOPBALANCE class-attribute instance-attribute

MODEL_OBJECTIVES_STOPBALANCE: float = 0.0

Factor to weigh the stop balance objective.

MODEL_OBJECTIVES_TRAVELDURATION class-attribute instance-attribute

MODEL_OBJECTIVES_TRAVELDURATION: float = 0.0

Factor to weigh the travel duration objective.

MODEL_OBJECTIVES_UNPLANNEDPENALTY class-attribute instance-attribute

MODEL_OBJECTIVES_UNPLANNEDPENALTY: float = 1.0

Factor to weigh the unplanned objective.

MODEL_OBJECTIVES_VEHICLEACTIVATIONPENALTY class-attribute instance-attribute

MODEL_OBJECTIVES_VEHICLEACTIVATIONPENALTY: float = 1.0

Factor to weigh the vehicle activation objective.

MODEL_OBJECTIVES_VEHICLESDURATION class-attribute instance-attribute

MODEL_OBJECTIVES_VEHICLESDURATION: float = 1.0

Factor to weigh the vehicles duration objective.

MODEL_PROPERTIES_DISABLE_DURATIONGROUPS class-attribute instance-attribute

MODEL_PROPERTIES_DISABLE_DURATIONGROUPS: bool = False

Ignore the durations groups of stops.

MODEL_PROPERTIES_DISABLE_DURATIONS class-attribute instance-attribute

MODEL_PROPERTIES_DISABLE_DURATIONS: bool = False

Ignore the durations of stops.

MODEL_PROPERTIES_DISABLE_INITIALSOLUTION class-attribute instance-attribute

MODEL_PROPERTIES_DISABLE_INITIALSOLUTION: bool = False

Ignore the initial solution.

MODEL_PROPERTIES_DISABLE_STOPDURATIONMULTIPLIERS class-attribute instance-attribute

MODEL_PROPERTIES_DISABLE_STOPDURATIONMULTIPLIERS: bool = (
    False
)

Ignore the stop duration multipliers defined on vehicles.

MODEL_PROPERTIES_MAXIMUMTIMEHORIZON class-attribute instance-attribute

MODEL_PROPERTIES_MAXIMUMTIMEHORIZON: int = 15552000

Maximum time horizon for the model in seconds.

MODEL_VALIDATE_DISABLE_RESOURCES class-attribute instance-attribute

MODEL_VALIDATE_DISABLE_RESOURCES: bool = False

Disable the resources validation.

MODEL_VALIDATE_DISABLE_STARTTIME class-attribute instance-attribute

MODEL_VALIDATE_DISABLE_STARTTIME: bool = False

Disable the start time validation.

MODEL_VALIDATE_ENABLE_MATRIX class-attribute instance-attribute

MODEL_VALIDATE_ENABLE_MATRIX: bool = False

Enable matrix validation.

MODEL_VALIDATE_ENABLE_MATRIXASYMMETRYTOLERANCE class-attribute instance-attribute

MODEL_VALIDATE_ENABLE_MATRIXASYMMETRYTOLERANCE: int = 20

Percentage of acceptable matrix asymmetry, requires matrix validation enabled.

SOLVE_DURATION class-attribute instance-attribute

SOLVE_DURATION: float = 5

Maximum duration, in seconds, of the solver.

SOLVE_ITERATIONS class-attribute instance-attribute

SOLVE_ITERATIONS: int = -1

Maximum number of iterations, -1 assumes no limit; iterations are counted after start solutions are generated.

SOLVE_PARALLELRUNS class-attribute instance-attribute

SOLVE_PARALLELRUNS: int = -1

Maximum number of parallel runs, -1 results in using all available resources.

SOLVE_PLATEAU_DELAY class-attribute instance-attribute

SOLVE_PLATEAU_DELAY: float = 0.0

Delay before starting to monitor for a plateau.

SOLVE_PLATEAU_ABSOLUTETHRESHOLD class-attribute instance-attribute

SOLVE_PLATEAU_ABSOLUTETHRESHOLD: float = -1

Absolute threshold for significant improvement.

SOLVE_PLATEAU_DURATION class-attribute instance-attribute

SOLVE_PLATEAU_DURATION: float = 0.0

Maximum duration, in seconds, without (significant) improvement.

SOLVE_PLATEAU_ITERATIONS class-attribute instance-attribute

SOLVE_PLATEAU_ITERATIONS: int = 0

Maximum number of iterations without (significant) improvement.

SOLVE_PLATEAU_RELATIVETHRESHOLD class-attribute instance-attribute

SOLVE_PLATEAU_RELATIVETHRESHOLD: float = 0.0

Relative threshold for significant improvement.

SOLVE_RUNDETERMINISTICALLY class-attribute instance-attribute

SOLVE_RUNDETERMINISTICALLY: bool = False

Run the parallel solver deterministically.

SOLVE_SOLVER_PLANGROUPSIZE_DELTA class-attribute instance-attribute

SOLVE_SOLVER_PLANGROUPSIZE_DELTA: int = 0

Delta for the plan group size parameter.

SOLVE_SOLVER_PLANGROUPSIZE_DELTAAFTERITERATIONS class-attribute instance-attribute

SOLVE_SOLVER_PLANGROUPSIZE_DELTAAFTERITERATIONS: int = (
    1000000000
)

Delta after each iteration for the plan group size parameter.

SOLVE_SOLVER_PLANGROUPSIZE_MAXVALUE class-attribute instance-attribute

SOLVE_SOLVER_PLANGROUPSIZE_MAXVALUE: int = 2

Maximum value for the plan group size parameter.

SOLVE_SOLVER_PLANGROUPSIZE_MINVALUE class-attribute instance-attribute

SOLVE_SOLVER_PLANGROUPSIZE_MINVALUE: int = 2

Minimum value for the plan group size parameter.

SOLVE_SOLVER_PLANGROUPSIZE_SNAPBACKAFTERIMPROVEMENT class-attribute instance-attribute

SOLVE_SOLVER_PLANGROUPSIZE_SNAPBACKAFTERIMPROVEMENT: bool = True

Snap back to start value after improvement of best solution for the plan group size parameter.

SOLVE_SOLVER_PLANGROUPSIZE_STARTVALUE class-attribute instance-attribute

SOLVE_SOLVER_PLANGROUPSIZE_STARTVALUE: int = 2

Start value for the plan group size parameter.

SOLVE_SOLVER_PLANGROUPSIZE_ZIGZAG class-attribute instance-attribute

SOLVE_SOLVER_PLANGROUPSIZE_ZIGZAG: bool = True

Zigzag between min and max value like a jig saw for the plan group size parameter.

SOLVE_SOLVER_UNPLANUNITS_DELTA class-attribute instance-attribute

SOLVE_SOLVER_UNPLANUNITS_DELTA: int = 2

Delta for the unplan units parameter.

SOLVE_SOLVER_UNPLANUNITS_DELTAAFTERITERATIONS class-attribute instance-attribute

SOLVE_SOLVER_UNPLANUNITS_DELTAAFTERITERATIONS: int = 125

Delta after each iteration for the unplan units parameter.

SOLVE_SOLVER_UNPLANUNITS_MAXVALUE class-attribute instance-attribute

SOLVE_SOLVER_UNPLANUNITS_MAXVALUE: int = -1

Maximum value for the unplan units parameter.

SOLVE_SOLVER_UNPLANUNITS_MINVALUE class-attribute instance-attribute

SOLVE_SOLVER_UNPLANUNITS_MINVALUE: int = 2

Minimum value for the unplan units parameter.

SOLVE_SOLVER_UNPLANUNITS_SNAPBACKAFTERIMPROVEMENT class-attribute instance-attribute

SOLVE_SOLVER_UNPLANUNITS_SNAPBACKAFTERIMPROVEMENT: bool = (
    True
)

Snap back to start value after improvement of best solution for the unplan units parameter.

SOLVE_SOLVER_UNPLANUNITS_STARTVALUE class-attribute instance-attribute

SOLVE_SOLVER_UNPLANUNITS_STARTVALUE: int = 2

Start value for the unplan units parameter.

SOLVE_SOLVER_UNPLANUNITS_ZIGZAG class-attribute instance-attribute

SOLVE_SOLVER_UNPLANUNITS_ZIGZAG: bool = True

Zigzag between min and max value like a jig saw for the unplan units parameter.

SOLVE_SOLVER_UNPLANWEIGHTS class-attribute instance-attribute

SOLVE_SOLVER_UNPLANWEIGHTS: str = (
    "Vehicle:3,Island:1,Location:293"
)

Unplan heuristic weights parameter.

SOLVE_STARTSOLUTIONS class-attribute instance-attribute

SOLVE_STARTSOLUTIONS: int = -1

Number of solutions to generate on top of those passed in; one solution generated with sweep algorithm, the rest generated randomly.

to_args

to_args() -> list[str]

Convert the options to command-line arguments.

RETURNS DESCRIPTION
List[str]

The flattened options as a list of strings.

Source code in nextroute/src/nextroute/options.py
def to_args(self) -> list[str]:
    """
    Convert the options to command-line arguments.

    Returns
    ----------
    List[str]
        The flattened options as a list of strings.
    """

    opt_dict = self.to_dict()

    default_options = Options()
    default_options_dict = default_options.to_dict()

    args = []
    for key, value in opt_dict.items():
        # We only care about custom options, so we skip the default ones.
        default_value = default_options_dict.get(key)
        if value == default_value:
            continue

        key = f"-{key.replace('_', '.').lower()}"

        str_value = json.dumps(value)
        if key in _DURATIONS_ARGS:
            str_value = str_value + "s"  # Transforms into seconds.

        if str_value.startswith('"') and str_value.endswith('"'):
            str_value = str_value[1:-1]

        # Nextroute’s Go implementation does not support boolean flags with
        # values. If the value is a boolean, then we only append the key if
        # the value is True.
        should_append_value = True
        if isinstance(value, bool):
            if not value:
                continue

            should_append_value = False

        args.append(key)
        if should_append_value:
            args.append(str_value)

    return args

extract_from_dict classmethod

extract_from_dict(data: dict[str, Any]) -> Options

Extracts options from a dictionary. This dictionary may contain more keys that are not part of the Nextroute options.

PARAMETER DESCRIPTION
data

The dictionary to extract options from.

TYPE: Dict[str, Any]

RETURNS DESCRIPTION
Options

The Nextroute options.

Source code in nextroute/src/nextroute/options.py
@classmethod
def extract_from_dict(cls, data: dict[str, Any]) -> "Options":
    """
    Extracts options from a dictionary. This dictionary may contain more
    keys that are not part of the Nextroute options.

    Parameters
    ----------
    data : Dict[str, Any]
        The dictionary to extract options from.

    Returns
    ----------
    Options
        The Nextroute options.
    """

    options = cls()
    for key, value in data.items():
        key = key.upper()
        if not hasattr(options, key):
            continue

        # Enums need to be handled manually.
        if key == "CHECK_VERBOSITY":
            value = Verbosity(value)

        setattr(options, key, value)

    return options