mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Optimize imports
This commit is contained in:
@@ -19,21 +19,17 @@ Options:
|
|||||||
--test-time-limit=<n> Solver time limit during test in seconds [default: 900]
|
--test-time-limit=<n> Solver time limit during test in seconds [default: 900]
|
||||||
--solver-threads=<n> Number of threads the solver is allowed to use [default: 4]
|
--solver-threads=<n> Number of threads the solver is allowed to use [default: 4]
|
||||||
"""
|
"""
|
||||||
|
import glob
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
import pathlib
|
|
||||||
import pickle
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import gzip
|
from pathlib import Path
|
||||||
import glob
|
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import pandas as pd
|
||||||
|
import seaborn as sns
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
from numpy import median
|
from numpy import median
|
||||||
from pathlib import Path
|
|
||||||
import pandas as pd
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import seaborn as sns
|
|
||||||
|
|
||||||
from miplearn import (
|
from miplearn import (
|
||||||
LearningSolver,
|
LearningSolver,
|
||||||
|
|||||||
@@ -7,18 +7,18 @@ from .classifiers import (
|
|||||||
Classifier,
|
Classifier,
|
||||||
Regressor,
|
Regressor,
|
||||||
)
|
)
|
||||||
|
from .classifiers.adaptive import AdaptiveClassifier
|
||||||
from .classifiers.sklearn import (
|
from .classifiers.sklearn import (
|
||||||
ScikitLearnRegressor,
|
ScikitLearnRegressor,
|
||||||
ScikitLearnClassifier,
|
ScikitLearnClassifier,
|
||||||
)
|
)
|
||||||
from .classifiers.adaptive import AdaptiveClassifier
|
|
||||||
from .classifiers.threshold import MinPrecisionThreshold
|
from .classifiers.threshold import MinPrecisionThreshold
|
||||||
from .components.component import Component
|
from .components.component import Component
|
||||||
from .components.dynamic_lazy import DynamicLazyConstraintsComponent
|
from .components.dynamic_lazy import DynamicLazyConstraintsComponent
|
||||||
from .components.dynamic_user_cuts import UserCutsComponent
|
from .components.dynamic_user_cuts import UserCutsComponent
|
||||||
from .components.static_lazy import StaticLazyConstraintsComponent
|
|
||||||
from .components.objective import ObjectiveValueComponent
|
from .components.objective import ObjectiveValueComponent
|
||||||
from .components.primal import PrimalSolutionComponent
|
from .components.primal import PrimalSolutionComponent
|
||||||
|
from .components.static_lazy import StaticLazyConstraintsComponent
|
||||||
from .components.steps.convert_tight import ConvertTightIneqsIntoEqsStep
|
from .components.steps.convert_tight import ConvertTightIneqsIntoEqsStep
|
||||||
from .components.steps.drop_redundant import DropRedundantInequalitiesStep
|
from .components.steps.drop_redundant import DropRedundantInequalitiesStep
|
||||||
from .components.steps.relax_integrality import RelaxIntegralityStep
|
from .components.steps.relax_integrality import RelaxIntegralityStep
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import Dict, Union, List
|
from typing import Dict, List
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from copy import deepcopy
|
from typing import Dict, Optional
|
||||||
from typing import Dict, Callable, Optional
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from sklearn.linear_model import LogisticRegression
|
from sklearn.linear_model import LogisticRegression
|
||||||
@@ -14,8 +13,8 @@ from sklearn.pipeline import make_pipeline
|
|||||||
from sklearn.preprocessing import StandardScaler
|
from sklearn.preprocessing import StandardScaler
|
||||||
|
|
||||||
from miplearn.classifiers import Classifier
|
from miplearn.classifiers import Classifier
|
||||||
from miplearn.classifiers.sklearn import ScikitLearnClassifier
|
|
||||||
from miplearn.classifiers.counting import CountingClassifier
|
from miplearn.classifiers.counting import CountingClassifier
|
||||||
|
from miplearn.classifiers.sklearn import ScikitLearnClassifier
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional, Callable, List
|
from typing import Optional, List
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from sklearn.dummy import DummyClassifier
|
from sklearn.dummy import DummyClassifier
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ from typing import Any, List, TYPE_CHECKING, Tuple, Dict, Hashable
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from miplearn.features import TrainingSample, Features
|
||||||
from miplearn.instance import Instance
|
from miplearn.instance import Instance
|
||||||
from miplearn.types import LearningSolveStats
|
from miplearn.types import LearningSolveStats
|
||||||
from miplearn.features import TrainingSample, Features
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from miplearn.solvers.learning import LearningSolver
|
from miplearn.solvers.learning import LearningSolver
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ from sklearn.linear_model import LinearRegression
|
|||||||
from miplearn.classifiers import Regressor
|
from miplearn.classifiers import Regressor
|
||||||
from miplearn.classifiers.sklearn import ScikitLearnRegressor
|
from miplearn.classifiers.sklearn import ScikitLearnRegressor
|
||||||
from miplearn.components.component import Component
|
from miplearn.components.component import Component
|
||||||
|
from miplearn.features import TrainingSample, Features
|
||||||
from miplearn.instance import Instance
|
from miplearn.instance import Instance
|
||||||
from miplearn.types import LearningSolveStats
|
from miplearn.types import LearningSolveStats
|
||||||
from miplearn.features import TrainingSample, Features
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from miplearn.solvers.learning import LearningSolver
|
from miplearn.solvers.learning import LearningSolver
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ from miplearn.classifiers.adaptive import AdaptiveClassifier
|
|||||||
from miplearn.classifiers.threshold import MinPrecisionThreshold, Threshold
|
from miplearn.classifiers.threshold import MinPrecisionThreshold, Threshold
|
||||||
from miplearn.components import classifier_evaluation_dict
|
from miplearn.components import classifier_evaluation_dict
|
||||||
from miplearn.components.component import Component
|
from miplearn.components.component import Component
|
||||||
|
from miplearn.features import TrainingSample, Features
|
||||||
from miplearn.instance import Instance
|
from miplearn.instance import Instance
|
||||||
from miplearn.types import (
|
from miplearn.types import (
|
||||||
Solution,
|
Solution,
|
||||||
LearningSolveStats,
|
LearningSolveStats,
|
||||||
)
|
)
|
||||||
from miplearn.features import TrainingSample, Features
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import pickle
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Any, List, Optional, Hashable, IO, cast
|
from typing import Any, List, Optional, Hashable, IO, cast
|
||||||
|
|
||||||
from miplearn.types import VarIndex
|
|
||||||
from miplearn.features import TrainingSample, Features
|
from miplearn.features import TrainingSample, Features
|
||||||
|
from miplearn.types import VarIndex
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import warnings
|
|
||||||
import traceback
|
import traceback
|
||||||
|
import warnings
|
||||||
|
|
||||||
_formatwarning = warnings.formatwarning
|
_formatwarning = warnings.formatwarning
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from miplearn.instance import Instance
|
from miplearn.instance import Instance
|
||||||
from miplearn.types import (
|
from miplearn.types import (
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from typing import Optional, Dict, Callable, Any, Union, Tuple, TYPE_CHECKING
|
|||||||
from mypy_extensions import TypedDict
|
from mypy_extensions import TypedDict
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
from miplearn.solvers.learning import InternalSolver
|
from miplearn.solvers.learning import InternalSolver
|
||||||
|
|
||||||
VarIndex = Union[str, int, Tuple[Union[str, int]]]
|
VarIndex = Union[str, int, Tuple[Union[str, int]]]
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import numpy as np
|
|||||||
from numpy.linalg import norm
|
from numpy.linalg import norm
|
||||||
from sklearn.svm import SVC
|
from sklearn.svm import SVC
|
||||||
|
|
||||||
from miplearn.classifiers.sklearn import ScikitLearnClassifier
|
|
||||||
from miplearn.classifiers.cv import CrossValidatedClassifier
|
from miplearn.classifiers.cv import CrossValidatedClassifier
|
||||||
|
from miplearn.classifiers.sklearn import ScikitLearnClassifier
|
||||||
from tests.classifiers import _build_circle_training_data
|
from tests.classifiers import _build_circle_training_data
|
||||||
|
|
||||||
E = 0.1
|
E = 0.1
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ import numpy as np
|
|||||||
from miplearn.classifiers import Classifier
|
from miplearn.classifiers import Classifier
|
||||||
from miplearn.components.steps.drop_redundant import DropRedundantInequalitiesStep
|
from miplearn.components.steps.drop_redundant import DropRedundantInequalitiesStep
|
||||||
from miplearn.components.steps.relax_integrality import RelaxIntegralityStep
|
from miplearn.components.steps.relax_integrality import RelaxIntegralityStep
|
||||||
|
from miplearn.features import TrainingSample, Features
|
||||||
from miplearn.instance import Instance
|
from miplearn.instance import Instance
|
||||||
from miplearn.solvers.gurobi import GurobiSolver
|
from miplearn.solvers.gurobi import GurobiSolver
|
||||||
from miplearn.solvers.internal import InternalSolver
|
from miplearn.solvers.internal import InternalSolver
|
||||||
from miplearn.solvers.learning import LearningSolver
|
from miplearn.solvers.learning import LearningSolver
|
||||||
from miplearn.features import TrainingSample, Features
|
|
||||||
from tests.fixtures.infeasible import get_infeasible_instance
|
from tests.fixtures.infeasible import get_infeasible_instance
|
||||||
from tests.fixtures.redundant import get_instance_with_redundancy
|
from tests.fixtures.redundant import get_instance_with_redundancy
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
from typing import Hashable, Dict
|
from typing import Hashable, Dict
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
import pytest
|
import pytest
|
||||||
from numpy.testing import assert_array_equal
|
from numpy.testing import assert_array_equal
|
||||||
|
|
||||||
@@ -15,8 +16,6 @@ from miplearn.solvers.learning import LearningSolver
|
|||||||
from miplearn.solvers.pyomo.gurobi import GurobiPyomoSolver
|
from miplearn.solvers.pyomo.gurobi import GurobiPyomoSolver
|
||||||
from tests.fixtures.knapsack import get_knapsack_instance
|
from tests.fixtures.knapsack import get_knapsack_instance
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def instance(features: Features) -> Instance:
|
def instance(features: Features) -> Instance:
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# MIPLearn: Extensible Framework for Learning-Enhanced Mixed-Integer Optimization
|
# MIPLearn: Extensible Framework for Learning-Enhanced Mixed-Integer Optimization
|
||||||
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
from typing import Dict
|
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -12,9 +11,9 @@ from miplearn.classifiers import Classifier
|
|||||||
from miplearn.classifiers.threshold import Threshold
|
from miplearn.classifiers.threshold import Threshold
|
||||||
from miplearn.components import classifier_evaluation_dict
|
from miplearn.components import classifier_evaluation_dict
|
||||||
from miplearn.components.primal import PrimalSolutionComponent
|
from miplearn.components.primal import PrimalSolutionComponent
|
||||||
|
from miplearn.features import TrainingSample, VariableFeatures, Features
|
||||||
from miplearn.instance import Instance
|
from miplearn.instance import Instance
|
||||||
from miplearn.problems.tsp import TravelingSalesmanGenerator
|
from miplearn.problems.tsp import TravelingSalesmanGenerator
|
||||||
from miplearn.features import TrainingSample, VariableFeatures, Features
|
|
||||||
from miplearn.solvers.learning import LearningSolver
|
from miplearn.solvers.learning import LearningSolver
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,18 +11,18 @@ from numpy.testing import assert_array_equal
|
|||||||
from miplearn.classifiers import Classifier
|
from miplearn.classifiers import Classifier
|
||||||
from miplearn.classifiers.threshold import Threshold, MinProbabilityThreshold
|
from miplearn.classifiers.threshold import Threshold, MinProbabilityThreshold
|
||||||
from miplearn.components.static_lazy import StaticLazyConstraintsComponent
|
from miplearn.components.static_lazy import StaticLazyConstraintsComponent
|
||||||
from miplearn.instance import Instance
|
|
||||||
from miplearn.solvers.internal import InternalSolver
|
|
||||||
from miplearn.solvers.learning import LearningSolver
|
|
||||||
from miplearn.types import (
|
|
||||||
LearningSolveStats,
|
|
||||||
)
|
|
||||||
from miplearn.features import (
|
from miplearn.features import (
|
||||||
TrainingSample,
|
TrainingSample,
|
||||||
InstanceFeatures,
|
InstanceFeatures,
|
||||||
ConstraintFeatures,
|
ConstraintFeatures,
|
||||||
Features,
|
Features,
|
||||||
)
|
)
|
||||||
|
from miplearn.instance import Instance
|
||||||
|
from miplearn.solvers.internal import InternalSolver
|
||||||
|
from miplearn.solvers.learning import LearningSolver
|
||||||
|
from miplearn.types import (
|
||||||
|
LearningSolveStats,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import dill
|
|
||||||
import pickle
|
|
||||||
import tempfile
|
|
||||||
import os
|
import os
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
import dill
|
||||||
|
|
||||||
from miplearn.instance import PickleGzInstance, write_pickle_gz, read_pickle_gz
|
from miplearn.instance import PickleGzInstance, write_pickle_gz, read_pickle_gz
|
||||||
from miplearn.solvers.gurobi import GurobiSolver
|
from miplearn.solvers.gurobi import GurobiSolver
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
from miplearn.benchmark import BenchmarkRunner
|
|
||||||
from miplearn.problems.stab import MaxWeightStableSetGenerator
|
|
||||||
from scipy.stats import randint
|
from scipy.stats import randint
|
||||||
|
|
||||||
|
from miplearn.benchmark import BenchmarkRunner
|
||||||
|
from miplearn.problems.stab import MaxWeightStableSetGenerator
|
||||||
from miplearn.solvers.learning import LearningSolver
|
from miplearn.solvers.learning import LearningSolver
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user