Interfaces¶
This page describes the interfaces provided to customize the LNS search.
All interfaces can be found in the fastlane.interfaces module.
Example implementations of these interfaces can be found in the lib submodule.
Adaptive Strategy Interface¶
This interface gives guidelines on how to implement adaptive strategies for adaptive LNS.
AdaptiveStrategy
¶
Bases: ABC
Adaptive strategy interface to select declarative LNS configuration.
get_initial_config(config_catalog: ConfigCatalog, initial_model: Model) -> ActiveConfig
abstractmethod
¶
Abstract method to get initial LNS configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_catalog
|
ConfigCatalog
|
Full declarative LNS catalog. |
required |
initial_model
|
Model
|
Initial model. |
required |
Returns:
| Type | Description |
|---|---|
ActiveConfig
|
LNS configuration |
update_config(active_config: ActiveConfig, config_catalog: ConfigCatalog, stats: list[dict[str, Any]], lns_object: LNS) -> ActiveConfig
abstractmethod
¶
Abstract method to update LNS configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
active_config
|
ActiveConfig
|
Active LNS configuration. |
required |
config_catalog
|
ConfigCatalog
|
Full LNS configuration catalog. |
required |
stats
|
list[dict[str, Any]]
|
Statistics. |
required |
lns_object
|
LNS
|
LNS object. |
required |
Returns:
| Type | Description |
|---|---|
ActiveConfig
|
New LNS configuration. |
Auto Destruction Converter¶
All custom auto destruction converters (for determining destruction rates automatically) should respect the this interface.
AutoDestructionConverter
¶
Bases: ABC
Converter interface for computing destruction percentages of auto-mode destroy operators.
compute_auto_destruction_percent(config_name: str, project_operators: list[ProjectOperator], destroy_operator_name: str) -> float
abstractmethod
¶
Compute destruction percentage of auto-mode destroy operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_name
|
str
|
Config name. |
required |
project_operators
|
list[ProjectOperator]
|
Project operators. |
required |
destroy_operator_name
|
str
|
Destroy operator name. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Destruction percentage of auto-mode destroy operator. |
convert_auto_in_config(config: ActiveConfig, lns_object: Optional[LNS] = None) -> ActiveConfig
¶
Convert automatic values in LNS configuration into concrete percentages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ActiveConfig
|
Active LNS configuration containing automatic values. |
required |
lns_object
|
Optional[LNS]
|
LNS object. |
None
|
Returns:
| Type | Description |
|---|---|
ActiveConfig
|
LNS configuration with all automatic values replaced by concrete percentages. |
Solver Interface¶
Solver implementations should follow the Solver Interface and make use of the SolverConfig class.
Solver
¶
Bases: ABC
Solver interface.
__init__() -> None
¶
Initialization of the solver object.
Before solving, setup() method must be called to correctly initialize the solver.
add(name: str, parameters: list[str], program: str) -> None
¶
assign_external(external: Union[Symbol, int], truth: bool) -> None
¶
get_name() -> str
abstractmethod
classmethod
¶
Get the name under which the solver will be listed in options.
Returns:
| Type | Description |
|---|---|
str
|
Name of the solver. |
get_stats() -> dict[str, Any]
¶
ground(parts: list[tuple[str, list[Symbol]]] = [('base', [])], context: Any = None) -> None
¶
release_external(external: Union[Symbol, int]) -> None
¶
setup(lns_object: LNS, args: list[str] = [], files: Optional[list[str]] = None) -> None
abstractmethod
¶
solve(config: Optional[SolverConfig], assumptions: list[tuple[clingo.symbol.Symbol, bool]] = [], require_model: bool = False) -> Optional[Model]
abstractmethod
¶
Solve with fixed atoms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[SolverConfig]
|
Solver configuration. |
required |
assumptions
|
list[tuple[Symbol, bool]]
|
Assumptions for solving (fixed atoms). |
[]
|
require_model
|
bool
|
If True, ignore cutoff time until a model is found. |
False
|
Returns:
| Type | Description |
|---|---|
Optional[Model]
|
Last obtained model. |