mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Merge branch 'gh-actions' into dev
This commit is contained in:
18
.github/workflows/main.yml
vendored
18
.github/workflows/main.yml
vendored
@@ -1,18 +0,0 @@
|
|||||||
name: Test
|
|
||||||
on: push
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: self-hosted
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
|
||||||
rm -rf ~/.conda/envs/miplearn-test
|
|
||||||
yes | conda create --name miplearn-test python=3.6
|
|
||||||
(cd /opt/gurobi900/linux64 && ~/.conda/envs/miplearn-test/bin/python setup.py install)
|
|
||||||
(cd /opt/cplex-12.8/cplex/python/3.6/x86-64_linux && ~/.conda/envs/miplearn-test/bin/python setup.py install)
|
|
||||||
make install test \
|
|
||||||
PYTHON=~/.conda/envs/miplearn-test/bin/python \
|
|
||||||
PIP=~/.conda/envs/miplearn-test/bin/pip3 \
|
|
||||||
PYTEST=~/.conda/envs/miplearn-test/bin/pytest
|
|
||||||
|
|
||||||
27
.github/workflows/test.yml
vendored
Normal file
27
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: Test
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [3.6, 3.7, 3.8]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out source code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install -i https://pypi.gurobi.com gurobipy
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
pytest
|
||||||
@@ -32,7 +32,7 @@ def test_instance():
|
|||||||
[1., 2., 1., 0.],
|
[1., 2., 1., 0.],
|
||||||
])
|
])
|
||||||
instance = TravelingSalesmanInstance(n_cities, distances)
|
instance = TravelingSalesmanInstance(n_cities, distances)
|
||||||
for solver_name in ['gurobi', 'cplex']:
|
for solver_name in ['gurobi']:
|
||||||
solver = LearningSolver(solver=solver_name)
|
solver = LearningSolver(solver=solver_name)
|
||||||
solver.solve(instance)
|
solver.solve(instance)
|
||||||
x = instance.solution["x"]
|
x = instance.solution["x"]
|
||||||
@@ -58,7 +58,7 @@ def test_subtour():
|
|||||||
])
|
])
|
||||||
distances = squareform(pdist(cities))
|
distances = squareform(pdist(cities))
|
||||||
instance = TravelingSalesmanInstance(n_cities, distances)
|
instance = TravelingSalesmanInstance(n_cities, distances)
|
||||||
for solver_name in ['gurobi', 'cplex']:
|
for solver_name in ['gurobi']:
|
||||||
solver = LearningSolver(solver=solver_name)
|
solver = LearningSolver(solver=solver_name)
|
||||||
solver.solve(instance)
|
solver.solve(instance)
|
||||||
assert hasattr(instance, "found_violated_lazy_constraints")
|
assert hasattr(instance, "found_violated_lazy_constraints")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, 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 miplearn import BasePyomoSolver, GurobiSolver, GurobiPyomoSolver, CplexPyomoSolver
|
from miplearn import BasePyomoSolver, GurobiSolver, GurobiPyomoSolver
|
||||||
from miplearn.problems.knapsack import KnapsackInstance, GurobiKnapsackInstance
|
from miplearn.problems.knapsack import KnapsackInstance, GurobiKnapsackInstance
|
||||||
|
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ def _get_instance(solver):
|
|||||||
|
|
||||||
|
|
||||||
def _get_internal_solvers():
|
def _get_internal_solvers():
|
||||||
return [GurobiPyomoSolver, CplexPyomoSolver, GurobiSolver]
|
return [GurobiPyomoSolver, GurobiSolver]
|
||||||
|
|||||||
Reference in New Issue
Block a user