ml4co_kit.task.base

Base class for all problems in the ML4CO kit.

Classes

TASK_TYPE(value)

Define the task types as an enumeration.

TaskBase(task_type, minimize, precision)

Base class for all tasks in the ML4CO kit.

class ml4co_kit.task.base.TASK_TYPE(value)[source]

Bases: str, Enum

Define the task types as an enumeration.

ATSP = 'ATSP'
CVRP = 'CVRP'
CVRPB = 'CVRPB'
CVRPBL = 'CVRPBL'
CVRPBLTW = 'CVRPBLTW'
CVRPBTW = 'CVRPBTW'
CVRPL = 'CVRPL'
CVRPLTW = 'CVRPLTW'
CVRPTW = 'CVRPTW'
EDAP = 'EDA-P'
EDAR = 'EDA-R'
EDATDP = 'EDA-TDP'
GED = 'GED'
GM = 'GM'
KQAP = 'KQAP'
LP = 'LP'
LQAP = 'LQAP'
MAXRETPO = 'MaxRetPO'
MCL = 'MCl'
MCUT = 'MCut'
MILP = 'MILP'
MINVARPO = 'MinVarPO'
MIP = 'MIP'
MIS = 'MIS'
MOPO = 'MOPO'
MVC = 'MVC'
OP = 'OP'
PCTSP = 'PCTSP'
SATA = 'SAT-A'
SATP = 'SAT-P'
SPCTSP = 'SPCTSP'
TSP = 'TSP'
class ml4co_kit.task.base.TaskBase(task_type: ~ml4co_kit.task.base.TASK_TYPE, minimize: bool, precision: ~numpy.float32 | ~numpy.float64 = <class 'numpy.float32'>)[source]

Bases: object

Base class for all tasks in the ML4CO kit.

check_constraints(sol: ndarray) bool[source]

Check if the given solution satisfies all problem constraints. To be implemented by subclasses.

evaluate(sol: ndarray, check_constr: bool = True) floating[source]

Evaluate the given solution. To be implemented by subclasses.

evaluate_w_gap(check_constr: bool = True) Sequence[floating][source]

Evaluate the given solution with gap.

from_data()[source]

Create a problem instance from raw data. To be implemented by subclasses.

from_pickle(file_path: Path)[source]

Create a problem instance from a pickle file.

get_data_md5() str[source]

Calculate MD5 hash of the task’s data content.

This method computes the MD5 hash based on the actual data content rather than the file content, which is useful for verifying data integrity when pickle files may have different object references.

Returns:

str: MD5 hash of the task’s data content

render()[source]

Render the problem instance. To be implemented by subclasses.

to_pickle(file_path: Path)[source]