diff --git a/Makefile b/Makefile index 1d1c789..3ca9137 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,24 @@ PYTEST_ARGS := -W ignore::DeprecationWarning -vv -x --log-level=DEBUG all: docs test +develop: + cd src/python && python setup.py develop + julia --project=src/julia -e "using Pkg; Pkg.instantiate()" + +install: + cd src/python && python setup.py install + julia --project=src/julia -e "using Pkg; Pkg.instantiate()" + +uninstall: + pip uninstall miplearn + docs: mkdocs build test: - pytest $(PYTEST_ARGS) + cd src/python && pytest $(PYTEST_ARGS) test-watch: - pytest-watch -- $(PYTEST_ARGS) + cd src/python && pytest-watch -- $(PYTEST_ARGS) .PHONY: test test-watch docs diff --git a/docs-src/figures/benchmark_knapsack_a.png b/docs-src/figures/benchmark_knapsack_a.png deleted file mode 120000 index a88935f..0000000 --- a/docs-src/figures/benchmark_knapsack_a.png +++ /dev/null @@ -1 +0,0 @@ -../../benchmark/knapsack/ChallengeA/performance.png \ No newline at end of file diff --git a/docs-src/figures/benchmark_stab_a.png b/docs-src/figures/benchmark_stab_a.png deleted file mode 120000 index 073c5ec..0000000 --- a/docs-src/figures/benchmark_stab_a.png +++ /dev/null @@ -1 +0,0 @@ -../../benchmark/stab/ChallengeA/performance.png \ No newline at end of file diff --git a/docs-src/figures/benchmark_tsp_a.png b/docs-src/figures/benchmark_tsp_a.png deleted file mode 120000 index 31a74c2..0000000 --- a/docs-src/figures/benchmark_tsp_a.png +++ /dev/null @@ -1 +0,0 @@ -../../benchmark/tsp/ChallengeA/performance.png \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 87b73cc..b0c84c7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -18,7 +18,7 @@ markdown_extensions: extra_javascript: - https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML - js/mathjax.js -docs_dir: docs-src +docs_dir: src/docs site_dir: docs extra_css: - - "css/custom.css" \ No newline at end of file + - "css/custom.css" diff --git a/docs-src/about.md b/src/docs/about.md similarity index 100% rename from docs-src/about.md rename to src/docs/about.md diff --git a/docs-src/benchmark.md b/src/docs/benchmark.md similarity index 100% rename from docs-src/benchmark.md rename to src/docs/benchmark.md diff --git a/docs-src/css/custom.css b/src/docs/css/custom.css similarity index 100% rename from docs-src/css/custom.css rename to src/docs/css/custom.css diff --git a/docs-src/customization.md b/src/docs/customization.md similarity index 100% rename from docs-src/customization.md rename to src/docs/customization.md diff --git a/src/docs/figures/benchmark_knapsack_a.png b/src/docs/figures/benchmark_knapsack_a.png new file mode 120000 index 0000000..14cd94d --- /dev/null +++ b/src/docs/figures/benchmark_knapsack_a.png @@ -0,0 +1 @@ +../../../benchmark/knapsack/ChallengeA/performance.png \ No newline at end of file diff --git a/src/docs/figures/benchmark_stab_a.png b/src/docs/figures/benchmark_stab_a.png new file mode 120000 index 0000000..e9ffa62 --- /dev/null +++ b/src/docs/figures/benchmark_stab_a.png @@ -0,0 +1 @@ +../../../benchmark/stab/ChallengeA/performance.png \ No newline at end of file diff --git a/src/docs/figures/benchmark_tsp_a.png b/src/docs/figures/benchmark_tsp_a.png new file mode 120000 index 0000000..46952f7 --- /dev/null +++ b/src/docs/figures/benchmark_tsp_a.png @@ -0,0 +1 @@ +../../../benchmark/tsp/ChallengeA/performance.png \ No newline at end of file diff --git a/docs-src/index.md b/src/docs/index.md similarity index 100% rename from docs-src/index.md rename to src/docs/index.md diff --git a/docs-src/js/mathjax.js b/src/docs/js/mathjax.js similarity index 100% rename from docs-src/js/mathjax.js rename to src/docs/js/mathjax.js diff --git a/docs-src/problems.md b/src/docs/problems.md similarity index 100% rename from docs-src/problems.md rename to src/docs/problems.md diff --git a/docs-src/usage.md b/src/docs/usage.md similarity index 90% rename from docs-src/usage.md rename to src/docs/usage.md index 08a678a..8ac19ad 100644 --- a/docs-src/usage.md +++ b/src/docs/usage.md @@ -3,14 +3,26 @@ ### Installation -The package is currently available for Python and Pyomo. It can be installed as follows: +MIPLearn is mainly written in Python, with some components written in Julia. For this +reason, both Python 3.6+ and Julia 1.3+ are required. A mixed-integer solver is also required, and +its Python bindings must be properly installed. Currently supported solvers include CPLEX and +Gurobi. To install MIPLearn, run the following commands: ```bash -pip install git+ssh://git@github.com/ANL-CEEESA/MIPLearn.git +git clone https://github.com/ANL-CEEESA/MIPLearn.git +cd MIPLearn +make install ``` -A Julia + JuMP version of the package is planned. +After installation, the package `miplearn` should become available to Python. It can be imported +as follows: +```python +import miplearn +``` + +!!! note + To install MIPLearn in another Python environment, switch to that enviroment before running `make install`. To install the package in development mode, run `make develop` instead. ### Using `LearningSolver` diff --git a/src/julia/Manifest.toml b/src/julia/Manifest.toml new file mode 100644 index 0000000..5de577b --- /dev/null +++ b/src/julia/Manifest.toml @@ -0,0 +1,119 @@ +# This file is machine-generated - editing it directly is not advised + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[CEnum]] +git-tree-sha1 = "62847acab40e6855a9b5905ccb99c2b5cf6b3ebb" +uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" +version = "0.2.0" + +[[CPLEXW]] +deps = ["CEnum", "Libdl"] +git-tree-sha1 = "ebad297748ee2a12cc13b5fb07f9bbfa8a900494" +repo-rev = "master" +repo-url = "git@github.com:iSoron/CPLEXW.git" +uuid = "cfecb002-79c2-11e9-35be-cb59aa640f85" +version = "1.0.0" + +[[CodeTracking]] +deps = ["InteractiveUtils", "UUIDs"] +git-tree-sha1 = "0becdab7e6fbbcb7b88d8de5b72e5bb2f28239f3" +uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" +version = "0.5.8" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" + +[[FileWatching]] +uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[JuliaInterpreter]] +deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] +git-tree-sha1 = "cf43000752f15c92bef4a080966810de886f3560" +uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" +version = "0.7.6" + +[[LibGit2]] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[LoweredCodeUtils]] +deps = ["JuliaInterpreter"] +git-tree-sha1 = "b416a30717e9109fffd4d9869f2f962b5dca3162" +uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" +version = "0.4.2" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[OrderedCollections]] +deps = ["Random", "Serialization", "Test"] +git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1" +uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +version = "1.1.0" + +[[Pkg]] +deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[Revise]] +deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "UUIDs", "Unicode"] +git-tree-sha1 = "2ecbd19f31a934b035bfc38036d5f7ac575d0878" +uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" +version = "2.5.0" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[Test]] +deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[TinyBnB]] +deps = ["CPLEXW", "Printf", "Random", "Revise", "Test"] +git-tree-sha1 = "921ad42ac9dd4d44e42941eb63c59bcb50f30b6f" +repo-rev = "master" +repo-url = "git@github.com:iSoron/TinyBnB.jl.git" +uuid = "1b2a1171-e557-4eeb-a4d6-6c23d7e94fcd" +version = "1.1.0" + +[[UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" diff --git a/src/julia/Project.toml b/src/julia/Project.toml new file mode 100644 index 0000000..dde2a27 --- /dev/null +++ b/src/julia/Project.toml @@ -0,0 +1,8 @@ +name = "MIPLearn" +uuid = "2b1277c3-b477-4c49-a15e-7ba350325c68" +authors = ["Alinson S Xavier "] +version = "0.1.0" + +[deps] +CPLEXW = "cfecb002-79c2-11e9-35be-cb59aa640f85" +TinyBnB = "1b2a1171-e557-4eeb-a4d6-6c23d7e94fcd" diff --git a/src/julia/src/MIPLearn.jl b/src/julia/src/MIPLearn.jl new file mode 100644 index 0000000..a6b9698 --- /dev/null +++ b/src/julia/src/MIPLearn.jl @@ -0,0 +1,5 @@ +module MIPLearn + +greet() = print("Hello World!") + +end # module diff --git a/miplearn/components/branching.jl b/src/julia/src/branching.jl similarity index 100% rename from miplearn/components/branching.jl rename to src/julia/src/branching.jl diff --git a/src/julia/test/runtests.jl b/src/julia/test/runtests.jl new file mode 100644 index 0000000..e69de29 diff --git a/miplearn/__init__.py b/src/python/miplearn/__init__.py similarity index 100% rename from miplearn/__init__.py rename to src/python/miplearn/__init__.py diff --git a/miplearn/benchmark.py b/src/python/miplearn/benchmark.py similarity index 100% rename from miplearn/benchmark.py rename to src/python/miplearn/benchmark.py diff --git a/miplearn/components/__init__.py b/src/python/miplearn/components/__init__.py similarity index 100% rename from miplearn/components/__init__.py rename to src/python/miplearn/components/__init__.py diff --git a/miplearn/components/branching.py b/src/python/miplearn/components/branching.py similarity index 96% rename from miplearn/components/branching.py rename to src/python/miplearn/components/branching.py index 8d29396..e02f6e1 100644 --- a/miplearn/components/branching.py +++ b/src/python/miplearn/components/branching.py @@ -57,9 +57,11 @@ class BranchPriorityComponent(Component): # Run Julia script src_dirname = os.path.dirname(os.path.realpath(__file__)) + julia_dirname = "%s/../../../julia" % src_dirname priority_file = tempfile.NamedTemporaryFile(mode="r") subprocess.run(["julia", - "%s/branching.jl" % src_dirname, + "--project=%s" % julia_dirname, + "%s/src/branching.jl" % julia_dirname, lp_file.name, priority_file.name, str(self.node_limit), diff --git a/miplearn/components/component.py b/src/python/miplearn/components/component.py similarity index 100% rename from miplearn/components/component.py rename to src/python/miplearn/components/component.py diff --git a/miplearn/components/lazy.py b/src/python/miplearn/components/lazy.py similarity index 100% rename from miplearn/components/lazy.py rename to src/python/miplearn/components/lazy.py diff --git a/miplearn/components/objective.py b/src/python/miplearn/components/objective.py similarity index 100% rename from miplearn/components/objective.py rename to src/python/miplearn/components/objective.py diff --git a/miplearn/components/primal.py b/src/python/miplearn/components/primal.py similarity index 100% rename from miplearn/components/primal.py rename to src/python/miplearn/components/primal.py diff --git a/miplearn/components/tests/__init__.py b/src/python/miplearn/components/tests/__init__.py similarity index 100% rename from miplearn/components/tests/__init__.py rename to src/python/miplearn/components/tests/__init__.py diff --git a/miplearn/components/tests/test_branching.py b/src/python/miplearn/components/tests/test_branching.py similarity index 100% rename from miplearn/components/tests/test_branching.py rename to src/python/miplearn/components/tests/test_branching.py diff --git a/miplearn/components/tests/test_objective.py b/src/python/miplearn/components/tests/test_objective.py similarity index 100% rename from miplearn/components/tests/test_objective.py rename to src/python/miplearn/components/tests/test_objective.py diff --git a/miplearn/components/tests/test_primal.py b/src/python/miplearn/components/tests/test_primal.py similarity index 100% rename from miplearn/components/tests/test_primal.py rename to src/python/miplearn/components/tests/test_primal.py diff --git a/miplearn/extractors.py b/src/python/miplearn/extractors.py similarity index 100% rename from miplearn/extractors.py rename to src/python/miplearn/extractors.py diff --git a/miplearn/instance.py b/src/python/miplearn/instance.py similarity index 100% rename from miplearn/instance.py rename to src/python/miplearn/instance.py diff --git a/miplearn/problems/__init__.py b/src/python/miplearn/problems/__init__.py similarity index 100% rename from miplearn/problems/__init__.py rename to src/python/miplearn/problems/__init__.py diff --git a/miplearn/problems/knapsack.py b/src/python/miplearn/problems/knapsack.py similarity index 100% rename from miplearn/problems/knapsack.py rename to src/python/miplearn/problems/knapsack.py diff --git a/miplearn/problems/stab.py b/src/python/miplearn/problems/stab.py similarity index 100% rename from miplearn/problems/stab.py rename to src/python/miplearn/problems/stab.py diff --git a/miplearn/problems/tests/__init__.py b/src/python/miplearn/problems/tests/__init__.py similarity index 100% rename from miplearn/problems/tests/__init__.py rename to src/python/miplearn/problems/tests/__init__.py diff --git a/miplearn/problems/tests/test_knapsack.py b/src/python/miplearn/problems/tests/test_knapsack.py similarity index 100% rename from miplearn/problems/tests/test_knapsack.py rename to src/python/miplearn/problems/tests/test_knapsack.py diff --git a/miplearn/problems/tests/test_stab.py b/src/python/miplearn/problems/tests/test_stab.py similarity index 100% rename from miplearn/problems/tests/test_stab.py rename to src/python/miplearn/problems/tests/test_stab.py diff --git a/miplearn/problems/tests/test_tsp.py b/src/python/miplearn/problems/tests/test_tsp.py similarity index 100% rename from miplearn/problems/tests/test_tsp.py rename to src/python/miplearn/problems/tests/test_tsp.py diff --git a/miplearn/problems/tsp.py b/src/python/miplearn/problems/tsp.py similarity index 100% rename from miplearn/problems/tsp.py rename to src/python/miplearn/problems/tsp.py diff --git a/miplearn/solvers.py b/src/python/miplearn/solvers.py similarity index 100% rename from miplearn/solvers.py rename to src/python/miplearn/solvers.py diff --git a/miplearn/tests/__init__.py b/src/python/miplearn/tests/__init__.py similarity index 100% rename from miplearn/tests/__init__.py rename to src/python/miplearn/tests/__init__.py diff --git a/miplearn/tests/test_benchmark.py b/src/python/miplearn/tests/test_benchmark.py similarity index 100% rename from miplearn/tests/test_benchmark.py rename to src/python/miplearn/tests/test_benchmark.py diff --git a/miplearn/tests/test_extractors.py b/src/python/miplearn/tests/test_extractors.py similarity index 100% rename from miplearn/tests/test_extractors.py rename to src/python/miplearn/tests/test_extractors.py diff --git a/miplearn/tests/test_solver.py b/src/python/miplearn/tests/test_solver.py similarity index 100% rename from miplearn/tests/test_solver.py rename to src/python/miplearn/tests/test_solver.py diff --git a/requirements.txt b/src/python/requirements.txt similarity index 100% rename from requirements.txt rename to src/python/requirements.txt diff --git a/setup.py b/src/python/setup.py similarity index 100% rename from setup.py rename to src/python/setup.py