mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Remove obsolete benchmark files
This commit is contained in:
@@ -13,38 +13,6 @@ from scipy.stats.distributions import rv_frozen
|
||||
from miplearn.instance.base import Instance
|
||||
|
||||
|
||||
class ChallengeA:
|
||||
"""
|
||||
- 250 variables, 10 constraints, fixed weights
|
||||
- w ~ U(0, 1000), jitter ~ U(0.95, 1.05)
|
||||
- K = 500, u ~ U(0., 1.)
|
||||
- alpha = 0.25
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
seed: int = 42,
|
||||
n_training_instances: int = 500,
|
||||
n_test_instances: int = 50,
|
||||
) -> None:
|
||||
np.random.seed(seed)
|
||||
self.gen = MultiKnapsackGenerator(
|
||||
n=randint(low=250, high=251),
|
||||
m=randint(low=10, high=11),
|
||||
w=uniform(loc=0.0, scale=1000.0),
|
||||
K=uniform(loc=500.0, scale=0.0),
|
||||
u=uniform(loc=0.0, scale=1.0),
|
||||
alpha=uniform(loc=0.25, scale=0.0),
|
||||
fix_w=True,
|
||||
w_jitter=uniform(loc=0.95, scale=0.1),
|
||||
)
|
||||
np.random.seed(seed + 1)
|
||||
self.training_instances = self.gen.generate(n_training_instances)
|
||||
|
||||
np.random.seed(seed + 2)
|
||||
self.test_instances = self.gen.generate(n_test_instances)
|
||||
|
||||
|
||||
class MultiKnapsackInstance(Instance):
|
||||
"""Representation of the Multidimensional 0-1 Knapsack Problem.
|
||||
|
||||
@@ -93,19 +61,6 @@ class MultiKnapsackInstance(Instance):
|
||||
|
||||
return model
|
||||
|
||||
@overrides
|
||||
def get_instance_features(self) -> np.ndarray:
|
||||
return np.array([float(np.mean(self.prices))] + list(self.capacities))
|
||||
|
||||
@overrides
|
||||
def get_variable_features(self, names: np.ndarray) -> np.ndarray:
|
||||
features = []
|
||||
for i in range(len(self.weights)):
|
||||
f = [self.prices[i]]
|
||||
f.extend(self.weights[:, i])
|
||||
features.append(f)
|
||||
return np.array(features)
|
||||
|
||||
|
||||
# noinspection PyPep8Naming
|
||||
class MultiKnapsackGenerator:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# MIPLearn: Extensible Framework for Learning-Enhanced Mixed-Integer Optimization
|
||||
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
from typing import List, Dict
|
||||
|
||||
import networkx as nx
|
||||
@@ -14,28 +15,6 @@ from scipy.stats.distributions import rv_frozen
|
||||
from miplearn.instance.base import Instance
|
||||
|
||||
|
||||
class ChallengeA:
|
||||
def __init__(
|
||||
self,
|
||||
seed: int = 42,
|
||||
n_training_instances: int = 500,
|
||||
n_test_instances: int = 50,
|
||||
) -> None:
|
||||
np.random.seed(seed)
|
||||
self.generator = MaxWeightStableSetGenerator(
|
||||
w=uniform(loc=100.0, scale=50.0),
|
||||
n=randint(low=200, high=201),
|
||||
p=uniform(loc=0.05, scale=0.0),
|
||||
fix_graph=True,
|
||||
)
|
||||
|
||||
np.random.seed(seed + 1)
|
||||
self.training_instances = self.generator.generate(n_training_instances)
|
||||
|
||||
np.random.seed(seed + 2)
|
||||
self.test_instances = self.generator.generate(n_test_instances)
|
||||
|
||||
|
||||
class MaxWeightStableSetInstance(Instance):
|
||||
"""An instance of the Maximum-Weight Stable Set Problem.
|
||||
|
||||
@@ -65,30 +44,6 @@ class MaxWeightStableSetInstance(Instance):
|
||||
model.clique_eqs.add(sum(model.x[v] for v in clique) <= 1)
|
||||
return model
|
||||
|
||||
@overrides
|
||||
def get_variable_features(self, names: np.ndarray) -> np.ndarray:
|
||||
features = []
|
||||
assert len(names) == len(self.nodes)
|
||||
for i, v1 in enumerate(self.nodes):
|
||||
assert names[i] == f"x[{v1}]".encode()
|
||||
neighbor_weights = [0.0] * 15
|
||||
neighbor_degrees = [100.0] * 15
|
||||
for v2 in self.graph.neighbors(v1):
|
||||
neighbor_weights += [self.weights[v2] / self.weights[v1]]
|
||||
neighbor_degrees += [self.graph.degree(v2) / self.graph.degree(v1)]
|
||||
neighbor_weights.sort(reverse=True)
|
||||
neighbor_degrees.sort()
|
||||
f = []
|
||||
f += neighbor_weights[:5]
|
||||
f += neighbor_degrees[:5]
|
||||
f += [self.graph.degree(v1)]
|
||||
features.append(f)
|
||||
return np.array(features)
|
||||
|
||||
@overrides
|
||||
def get_variable_categories(self, names: np.ndarray) -> np.ndarray:
|
||||
return np.array(["default" for _ in names], dtype="S")
|
||||
|
||||
|
||||
class MaxWeightStableSetGenerator:
|
||||
"""Random instance generator for the Maximum-Weight Stable Set Problem.
|
||||
|
||||
@@ -17,30 +17,6 @@ from miplearn.solvers.pyomo.base import BasePyomoSolver
|
||||
from miplearn.types import ConstraintName
|
||||
|
||||
|
||||
class ChallengeA:
|
||||
def __init__(
|
||||
self,
|
||||
seed: int = 42,
|
||||
n_training_instances: int = 500,
|
||||
n_test_instances: int = 50,
|
||||
) -> None:
|
||||
np.random.seed(seed)
|
||||
self.generator = TravelingSalesmanGenerator(
|
||||
x=uniform(loc=0.0, scale=1000.0),
|
||||
y=uniform(loc=0.0, scale=1000.0),
|
||||
n=randint(low=350, high=351),
|
||||
gamma=uniform(loc=0.95, scale=0.1),
|
||||
fix_cities=True,
|
||||
round=True,
|
||||
)
|
||||
|
||||
np.random.seed(seed + 1)
|
||||
self.training_instances = self.generator.generate(n_training_instances)
|
||||
|
||||
np.random.seed(seed + 2)
|
||||
self.test_instances = self.generator.generate(n_test_instances)
|
||||
|
||||
|
||||
class TravelingSalesmanInstance(Instance):
|
||||
"""An instance ot the Traveling Salesman Problem.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user