Utils
utils
¶
Collection of utility functions used for LNS.
calculate_variability(list1: set[Any], list2: set[Any]) -> float
¶
Calculate variability of two sets in percent.
0 - no variability (same sets or bigger one contains smaller one)
100 - completely different
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
list1
|
set[Any]
|
First set. |
required |
list2
|
set[Any]
|
Second set. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Variability of both sets. |
get_unique_list(seq: Sequence[Any]) -> list[Any]
¶
increase_cutoff(*, current_cutoff: int, cutoff_threshold: Optional[int], increase_rate: int, timer: Timer, time_limit: Optional[int], latest_stats: dict[str, Any]) -> int
¶
Update the solver's cutoff for the next iteration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_cutoff
|
int
|
Current cutoff value. |
required |
cutoff_threshold
|
Optional[int]
|
Threshold for increasing the cutoff. |
required |
increase_rate
|
int
|
Percentage to increase the cutoff (e.g., 20 for 20%). |
required |
timer
|
Timer
|
Timer object. |
required |
time_limit
|
Optional[int]
|
Overall time limit in seconds (or None for unlimited). |
required |
latest_stats
|
dict[str, Any]
|
Latest statistics dictionary containing "no_improvement_cutoff_count". |
required |
Returns:
| Type | Description |
|---|---|
int
|
New cutoff value. |
increase_solve_limit(current_solve_limit: str, increase_rate: float) -> str
¶
Increase solve limit by a percentage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_solve_limit
|
str
|
Current solve limit as string (e.g., "1000,1000", "1000,umax"). |
required |
increase_rate
|
float
|
Percentage to increase the solve limit (e.g., 20 for 20%). |
required |
Returns:
| Type | Description |
|---|---|
str
|
New solve limit as string. |
increase_time_limit(timer: Timer, time_limit: Optional[int], solver_time_limit: int, increase_rate: float) -> int
¶
Increase time limit by a percentage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timer
|
Timer
|
Timer object. |
required |
time_limit
|
Optional[int]
|
Overall time limit in seconds (or None for unlimited). |
required |
solver_time_limit
|
int
|
Current solver time limit in seconds. |
required |
increase_rate
|
float
|
Percentage to increase the time limit (e.g., 20 for 20%). |
required |
Returns:
| Type | Description |
|---|---|
int
|
New time limit in seconds (or None for unlimited). |
update_time_limit(lns_object: 'LNS', solver_config: 'SolverConfig') -> None
¶
Update solve time-limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lns_object
|
'LNS'
|
LNS object. |
required |
solver_config
|
'SolverConfig'
|
Solver configuration to update. |
required |