From d2faa150797ca0315057e2c2c011ec4f1a8ce4cc Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Sun, 28 Jan 2024 20:47:16 -0600 Subject: [PATCH] Reformat; remove unused imports --- docs/guide/features.ipynb | 2 +- docs/guide/primal.ipynb | 8 ++++---- docs/guide/problems.ipynb | 18 +++++++++--------- tests/components/cuts/test_mem.py | 16 +--------------- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/docs/guide/features.ipynb b/docs/guide/features.ipynb index 2abbece..d2ae648 100644 --- a/docs/guide/features.ipynb +++ b/docs/guide/features.ipynb @@ -166,7 +166,7 @@ "\n", " # Extract and print constraint features\n", " x3 = ext.get_constr_features(h5)\n", - " print(\"constraint features\", x3.shape, \"\\n\", x3)\n" + " print(\"constraint features\", x3.shape, \"\\n\", x3)" ] }, { diff --git a/docs/guide/primal.ipynb b/docs/guide/primal.ipynb index 3aedb9c..056992d 100644 --- a/docs/guide/primal.ipynb +++ b/docs/guide/primal.ipynb @@ -120,7 +120,7 @@ " extractor=H5FieldsExtractor(instance_fields=[\"static_var_obj_coeffs\"]),\n", " constructor=MergeTopSolutions(k=3, thresholds=[0.25, 0.75]),\n", " action=EnforceProximity(3),\n", - ")\n" + ")" ] }, { @@ -175,7 +175,7 @@ " ),\n", " extractor=AlvLouWeh2017Extractor(),\n", " action=SetWarmStart(),\n", - ")\n" + ")" ] }, { @@ -230,7 +230,7 @@ " instance_fields=[\"static_var_obj_coeffs\"],\n", " ),\n", " action=SetWarmStart(),\n", - ")\n" + ")" ] }, { @@ -263,7 +263,7 @@ "# Configures an expert primal component, which reads a pre-computed\n", "# optimal solution from the HDF5 file and provides it to the solver\n", "# as warm start.\n", - "comp = ExpertPrimalComponent(action=SetWarmStart())\n" + "comp = ExpertPrimalComponent(action=SetWarmStart())" ] } ], diff --git a/docs/guide/problems.ipynb b/docs/guide/problems.ipynb index 4ffbd36..24a551e 100644 --- a/docs/guide/problems.ipynb +++ b/docs/guide/problems.ipynb @@ -194,7 +194,7 @@ "\n", "# Optimize first instance\n", "model = build_binpack_model(data[0])\n", - "model.optimize()\n" + "model.optimize()" ] }, { @@ -397,7 +397,7 @@ "\n", "# Build model and optimize\n", "model = build_multiknapsack_model(data[0])\n", - "model.optimize()\n" + "model.optimize()" ] }, { @@ -577,7 +577,7 @@ "\n", "# Build and optimize model\n", "model = build_pmedian_model(data[0])\n", - "model.optimize()\n" + "model.optimize()" ] }, { @@ -726,7 +726,7 @@ "\n", "# Build and optimize model\n", "model = build_setcover_model_gurobipy(data[0])\n", - "model.optimize()\n" + "model.optimize()" ] }, { @@ -862,7 +862,7 @@ "\n", "# Build and optimize model\n", "model = build_setpack_model(data[0])\n", - "model.optimize()\n" + "model.optimize()" ] }, { @@ -999,7 +999,7 @@ "\n", "# Load and optimize the first instance\n", "model = build_stab_model(data[0])\n", - "model.optimize()\n" + "model.optimize()" ] }, { @@ -1174,7 +1174,7 @@ "\n", "# Load and optimize the first instance\n", "model = build_tsp_model(data[0])\n", - "model.optimize()\n" + "model.optimize()" ] }, { @@ -1412,7 +1412,7 @@ "\n", "# Load and optimize the first instance\n", "model = build_uc_model(data[0])\n", - "model.optimize()\n" + "model.optimize()" ] }, { @@ -1553,7 +1553,7 @@ "\n", "# Load and optimize the first instance\n", "model = build_vertexcover_model(data[0])\n", - "model.optimize()\n" + "model.optimize()" ] }, { diff --git a/tests/components/cuts/test_mem.py b/tests/components/cuts/test_mem.py index e766331..108802b 100644 --- a/tests/components/cuts/test_mem.py +++ b/tests/components/cuts/test_mem.py @@ -2,30 +2,16 @@ # Copyright (C) 2020-2023, UChicago Argonne, LLC. All rights reserved. # Released under the modified BSD license. See COPYING.md for more details. -from typing import Any, List, Hashable, Dict +from typing import Any, List, Dict from unittest.mock import Mock -import gurobipy as gp -import networkx as nx -from gurobipy import GRB, quicksum from sklearn.dummy import DummyClassifier from sklearn.neighbors import KNeighborsClassifier from miplearn.components.cuts.mem import MemorizingCutsComponent from miplearn.extractors.abstract import FeaturesExtractor from miplearn.problems.stab import build_stab_model -from miplearn.solvers.gurobi import GurobiModel from miplearn.solvers.learning import LearningSolver -import numpy as np - - -# def test_usage() -> None: -# model = _build_cut_model() -# solver = LearningSolver(components=[]) -# solver.optimize(model) -# assert model.cuts_ is not None -# assert len(model.cuts_) > 0 -# assert False def test_mem_component(