class GoodApp(ApplicationCore): name = "123" instance = GoodInstanceClass solution = GoodSolutionClass solvers = dict(default=GoodExperiment) schema = get_empty_schema(dict(timeLimit=dict(type="number")), solvers=["default"]) test_cases = [dict()]
class ConcatenatedSolver(ApplicationCore): name = "123" instance = GoodInstanceClass solution = GoodSolutionClass solvers = dict(pulp=GoodExperiment) schema = get_empty_schema(dict(timeLimit=dict(type="number")), solvers=["pulp.cbc"]) test_cases = [dict()]
class GraphColoring(ApplicationCore): name = "graph_coloring" instance = Instance solution = Solution solvers = dict(default=OrToolsCP) schema = get_empty_schema(properties=dict(timeLimit=dict(type="number")), solvers=list(solvers.keys())) @property def test_cases(self) -> List[Dict]: def read_file(filePath): with open(filePath, "r") as f: contents = f.read().splitlines() pairs = (pt.TupList( contents[1:]).vapply(lambda v: v.split(" ")).vapply( lambda v: dict(n1=int(v[0]), n2=int(v[1])))) return dict(pairs=pairs) file_dir = os.path.join(os.path.dirname(__file__), "data") files = os.listdir(file_dir) test_files = pt.TupList(files).vfilter(lambda v: v.startswith("gc_")) return [ read_file(os.path.join(file_dir, fileName)) for fileName in test_files ]
class Timer(ApplicationCore): name = "timer" instance = Instance solution = Solution solvers = dict(default=Solver) schema = get_empty_schema( properties=dict(seconds=dict(type="number"), timeLimit=dict(type="number")), solvers=list(solvers.keys()), ) def test_cases(self): return []
class Knapsack(ApplicationCore): name = "knapsack" instance = Instance solution = Solution solvers = dict( Dynamic=DynamicSolver, Direct=DirectHeuristic, Random=RandomHeuristic, MIP=MIPSolver, ) schema = get_empty_schema( properties=dict(timeLimit=dict(type="number")), solvers=list(solvers.keys()) + ["MIP.cbc"], ) def get_solver_name(self, data, conf): solver_name = conf.get("solver", "Direct") if (data["parameters"]["nb_objects"] * data["parameters"]["weight_capacity"] > threshold and solver_name == "Dynamic"): solver_name = "Direct" return solver_name def solve(self, data, conf): solver_name = self.get_solver_name(data, conf) conf["solver"] = solver_name return super().solve(data, conf) @property def test_cases(self): cwd = os.path.dirname(os.path.realpath(__file__)) path = os.path.join(cwd, "Data", "ks_4_0") data = Instance.from_file(path).to_dict() return [data] def get_solver(self, name: str = "default") -> Union[Type[Experiment], None]: if "." in name: solver, _ = name.split(".") else: solver = name return self.solvers.get(solver)
class VRP(ApplicationCore): name = "vrp" instance = Instance solution = Solution solvers = dict( algorithm1=Algorithm, algorithm2=Heuristic, algorithm3=ORT_Algorithm, mip=modelMIP, ) schema = get_empty_schema( properties=dict(timeLimit=dict(type="number")), solvers=list(solvers.keys()) ) @property def test_cases(self) -> List[Dict]: data = load_json( os.path.join(os.path.dirname(__file__), "data/input_test_1_small.json") ) return [data]
class HackathonApp(ApplicationCore): name = "hk_2020_dag" instance = Instance solution = Solution solvers = solvers schema = get_empty_schema( properties=dict( timeLimit=dict(type="number"), gapAbs=dict(type="number"), gapRel=dict(type="number"), ), solvers=list(solvers.keys()), ) @property def test_cases(self) -> List[Dict]: options = [ ("j10.mm.zip", "j102_4.mm"), ("j10.mm.zip", "j102_5.mm"), ("j10.mm.zip", "j102_6.mm"), ] return [get_test_instance(*op).to_dict() for op in options]
class FacilityLocation(ApplicationCore): name = "facility_location" instance = Instance solution = Solution solvers = dict(Pyomo=PyomoSolver) schema = get_empty_schema( properties=dict(timeLimit=dict(type="number")), solvers=list(solvers.keys()) + ["Pyomo.cbc"], ) def get_solver(self, name: str = "Pyomo") -> Union[Type[Experiment], None]: if "." in name: solver, _ = name.split(".") else: solver = name return self.solvers.get(solver) @property def test_cases(self): data = load_json( os.path.join(os.path.dirname(__file__), "data/input_data_test1.json") ) return [data]
class GoodInstanceClass(InstanceCore): schema = get_empty_schema(dict(number=dict(type="number")))
class Instance(InstanceCore): schema = get_empty_schema()
class Solution(SolutionCore): schema = get_empty_schema()
def setUp(self): super().setUp() self.schema = get_pulp_jsonschema() self.config = get_empty_schema(dict(timeLimit=1, solvers=["cbc"])) self.url = SCHEMA_URL self.schema_name = "solve_model_dag"