def solve(file): instance = CVRPInstance.from_file(file) logger.info("Finetunning on evaluation instance.") model_finetuned = finetune(model, instance) logger.info("Starting to dynamic route.") for delivery in tqdm(instance.deliveries): model_finetuned = route(model_finetuned, delivery) solution = finish(instance, model_finetuned) solution.to_file(output_dir / f"{instance.name}.json")
eval_files = ([eval_path] if eval_path.is_file() else list(eval_path.iterdir())) train_path = Path(args.train_instances) train_path_dir = train_path if train_path.is_dir() else train_path.parent train_files = ([train_path] if train_path.is_file() else list(train_path.iterdir())) # params = params_class.from_file(args.params) if args.params else None params = None output_dir = Path(args.output or ".") output_dir.mkdir(parents=True, exist_ok=True) train_instances = [CVRPInstance.from_file(f) for f in train_files[:240]] logger.info("Pretraining on training instances.") model = pretrain(train_instances) def solve(file): instance = CVRPInstance.from_file(file) logger.info("Finetunning on evaluation instance.") model_finetuned = finetune(model, instance) logger.info("Starting to dynamic route.") for delivery in tqdm(instance.deliveries): model_finetuned = route(model_finetuned, delivery) solution = finish(instance, model_finetuned)
def solve(file): instance = CVRPInstance.from_file(file) solution = method(instance, params) solution.to_file(output_dir / f"{instance.name}.json")