Skip to content

Commit

Permalink
Add the modified Ecole library
Browse files Browse the repository at this point in the history
  • Loading branch information
SelinBayramoglu committed Sep 14, 2023
1 parent a252a82 commit 7b3712e
Show file tree
Hide file tree
Showing 255 changed files with 27,735 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,3 @@ ENV/

# In-tree generated files
*/_version.py

# Do not track ecole for now
ecole/
4 changes: 4 additions & 0 deletions ecole/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Antoine Prouvost
Maxime Gasse
Didier Chételat
Justin Dumouchelle
55 changes: 55 additions & 0 deletions ecole/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.16)

# Adapt compiler flags if using Conda compiler packages. Before project so they are not modified.
include(cmake/Conda.cmake)

# Read the version from file
include(cmake/Version.cmake)
read_version("VERSION" Ecole_VERSION)

# Set default parameters. Assumes Ecole user,
include(cmake/DefaultSettings.cmake)

project(
Ecole
VERSION "${Ecole_VERSION}"
LANGUAGES CXX
DESCRIPTION "Extensible Combinatorial Optimization Learning Environments"
)

# Add option to enable interprocedural optimization
include(cmake/InterproceduralOptimization.cmake)

# Define a target Ecole::warnings with all compiler warnings.
include(cmake/CompilerWarnings.cmake)

# Define a target Ecole::sanitizers with enabled sanitizers.
include(cmake/Sanitizers.cmake)

# Define a target Ecole::coverage with coverage options.
include(cmake/Coverage.cmake)

# Utilities to automatically download missing dependencies
include(cmake/DependenciesResolver.cmake)

# Adapt which Python is found
include(cmake/Python.cmake)

# Enable CTest for registering tests
include(CTest)

# Ecole library
if(ECOLE_BUILD_LIB)
# Build the Ecole library
add_subdirectory(libecole)
else()
# Find the Ecole library of same version already installed
option(ECOLE_DOWNLOAD_DEPENDENCIES "Download the static and header libraries used in Ecole public interface" ON)
find_package(Ecole ${Ecole_VERSION} EXACT REQUIRED)
endif()

# Ecole Python extension
if(ECOLE_BUILD_PY_EXT)
add_subdirectory(python/extension-helper)
add_subdirectory(python/ecole)
endif()
29 changes: 29 additions & 0 deletions ecole/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2019, Antoine Prouvost
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
124 changes: 124 additions & 0 deletions ecole/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
⚠️ **Warning** ⚠️

*Ecole is looking for a new home.*
*It is not being actively developed, only critical issues will be investigated.*


.. image:: https://raw.githubusercontent.com/ds4dm/ecole/master/docs/_static/images/ecole-logo.svg
:target: https://www.ecole.ai
:alt: Ecole logo
:width: 30 %
:align: right

Ecole
=====

.. image:: https://github.com/ds4dm/ecole/actions/workflows/continuous-testing.yml/badge.svg
:target: https://github.com/ds4dm/ecole/actions/workflows/continuous-testing.yml
:alt: Test and deploy on Github Actions

Ecole (pronounced [ekɔl]) stands for *Extensible Combinatorial Optimization Learning
Environments* and aims to expose a number of control problems arising in combinatorial
optimization solvers as Markov
Decision Processes (*i.e.*, Reinforcement Learning environments).
Rather than trying to predict solutions to combinatorial optimization problems directly, the
philosophy behind Ecole is to work
in cooperation with a state-of-the-art Mixed Integer Linear Programming solver
that acts as a controllable algorithm.

The underlying solver used is `SCIP <https://scip.zib.de/>`_, and the user facing API is
meant to mimic the `OpenAI Gym <https://www.gymlibrary.dev/>`_ API (as much as possible).

.. code-block:: python
import ecole
env = ecole.environment.Branching(
reward_function=-1.5 * ecole.reward.LpIterations() ** 2,
observation_function=ecole.observation.NodeBipartite(),
)
instances = ecole.instance.SetCoverGenerator()
for _ in range(10):
obs, action_set, reward_offset, done, info = env.reset(next(instances))
while not done:
obs, action_set, reward, done, info = env.step(action_set[0])
Documentation
-------------
Consult the `user Documentation <https://doc.ecole.ai>`_ for tutorials, examples, and library reference.

Discussions and help
--------------------
Head to `Github Discussions <https://github.com/ds4dm/ecole/discussions>`_ for interaction with the community: give
and recieve help, discuss intresting envirnoment, rewards function, and instances generators.

Installation
------------
Conda
^^^^^

.. image:: https://img.shields.io/conda/vn/conda-forge/ecole?label=version&logo=conda-forge
:target: https://anaconda.org/conda-forge/ecole
:alt: Conda-Forge version
.. image:: https://img.shields.io/conda/pn/conda-forge/ecole?logo=conda-forge
:target: https://anaconda.org/conda-forge/ecole
:alt: Conda-Forge platforms

.. code-block:: bash
conda install -c conda-forge ecole
All dependencies are resolved by conda, no compiler is required.

Pip wheel (binary)
^^^^^^^^^^^^^^^^^^
Currently unavailable.

Pip source
^^^^^^^^^^^
.. image:: https://img.shields.io/pypi/v/ecole?logo=python
:target: https://pypi.org/project/ecole/
:alt: PyPI version

Building from source requires:
- A `C++17 compiler <https://en.cppreference.com/w/cpp/compiler_support>`_,
- A `SCIP <https://www.scipopt.org/>`__ installation.

.. code-block:: bash
pip install ecole
Other Options
^^^^^^^^^^^^^
Checkout the `installation instructions <https://doc.ecole.ai/py/en/stable/>`_ in the
documentation for more installation options.

Related Projects
----------------

* `OR-Gym <https://github.com/hubbs5/or-gym>`_ is a gym-like library providing gym-like environments to produce feasible solutions
directly, without the need for an MILP solver;
* `MIPLearn <https://github.com/ANL-CEEESA/MIPLearn>`_ for learning to configure solvers.

Use It, Cite It
---------------

.. image:: https://img.shields.io/badge/arxiv-2011.06069-red
:target: https://arxiv.org/abs/2011.06069
:alt: Ecole publication on Arxiv


If you use Ecole in a scientific publication, please cite the Ecole publication

.. code-block:: text
@inproceedings{
prouvost2020ecole,
title={Ecole: A Gym-like Library for Machine Learning in Combinatorial Optimization Solvers},
author={Antoine Prouvost and Justin Dumouchelle and Lara Scavuzzo and Maxime Gasse and Didier Ch{\'e}telat and Andrea Lodi},
booktitle={Learning Meets Combinatorial Algorithms at NeurIPS2020},
year={2020},
url={https://openreview.net/forum?id=IVc9hqgibyB}
}
10 changes: 10 additions & 0 deletions ecole/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See PEP 440 for valid version specification
# The following should include only numbers
VERSION_MAJOR 0
VERSION_MINOR 8
VERSION_PATCH 1
# The following should include their whole string and can be combined.
# They must be numbered, starting from 0.
VERSION_PRE # Pre release without leading dot, e.g. `a0` (alpha), `b0` (beta), or `rc0` (release candidate)
VERSION_POST # Post release with leading dot, e.g. `.post0`
VERSION_DEV # Dev release with leading dot, e.g. `.dev0`
128 changes: 128 additions & 0 deletions ecole/cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Module to set default compiler warnings.
#
# File adapted from Jason Turner's cpp_starter_project
# https://github.com/lefticus/cpp_starter_project/blob/master/cmake/CompilerWarnings.cmake
# Using INTERFACE targets is not so desirable as they need to be installed when building
# static libraries.

function(ecole_target_add_compile_warnings target)
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)

set(msvc_warnings
# Baseline reasonable warnings
/W4
# "identfier": conversion from "type1" to "type1", possible loss of data
/w14242
# "operator": conversion from "type1:field_bits" to "type2:field_bits", possible
# loss of data
/w14254
# "function": member function does not override any base class virtual member
# function
/w14263
# "classname": class has virtual functions, but destructor is not virtual instances
# of this class may not be destructed correctly
/w14265
# "operator": unsigned/negative constant mismatch
/w14287
# Nonstandard extension used: "variable": loop control variable declared in the
# for-loop is used outside the for-loop scope
/we4289
# "operator": expression is always "boolean_value"
/w14296
# "variable": pointer truncation from "type1" to "type2"
/w14311
# Expression before comma evaluates to a function which is missing an argument list
/w14545
# Function call before comma missing argument list
/w14546
# "operator": operator before comma has no effect; expected operator with side-effect
/w14547
# "operator": operator before comma has no effect; did you intend "operator"?
/w14549
# Expression has no effect; expected expression with side- effect
/w14555
# Pragma warning: there is no warning number "number"
/w14619
# Enable warning on thread un-safe static member initialization
/w14640
# Conversion from "type1" to "type_2" is sign-extended. This may cause unexpected
# runtime behavior.
/w14826
# Wide string literal cast to "LPSTR"
/w14905
# String literal cast to "LPWSTR"
/w14906
# Illegal copy-initialization; more than one user-defined conversion has been
# implicitly applied
/w14928
)

set(clang_warnings
# Some default set of warnings
-Wall
# Reasonable and standard
-Wextra
# Warn the user if a variable declaration shadows one from a parent context
-Wshadow
# Warn the user if a class with virtual functions has a non-virtual destructor.
# This helps catch hard to track down memory errors
-Wnon-virtual-dtor
# Warn for c-style casts
-Wold-style-cast
# Warn for potential performance problem casts
-Wcast-align
# Warn on anything being unused
-Wunused
# Warn if you overload (not override) a virtual function
-Woverloaded-virtual
# Warn if non-standard C++ is used
-Wpedantic
# Warn on type conversions that may lose data
-Wconversion
# Warn on sign conversions
-Wsign-conversion
# Warn if a null dereference is detected
-Wnull-dereference
# Warn if float is implicit promoted to double
-Wdouble-promotion
# Warn on security issues around functions that format output (ie printf)
-Wformat=2
# Warn on code that cannot be executed
-Wunreachable-code
# Warn if a variable is used before being initialized
-Wuninitialized
)

if (WARNINGS_AS_ERRORS)
set(clang_warnings ${clang_warnings} -Werror)
set(msvc_warnings ${msvc_warnings} /WX)
endif()

set(gcc_warnings
${clang_warnings}
# FIXME currently not adding more warning for GCC because they fail on clang-tidy
# warn if identation implies blocks where blocks do not exist
# -Wmisleading-indentation
# warn if if / else chain has duplicated conditions
# -Wduplicated-cond
# warn if if / else branches have duplicated code
# -Wduplicated-branches
# warn about logical operations being used where bitwise were probably wanted
# -Wlogical-op
# warn if you perform a cast to the same type
# -Wuseless-cast
)

if(MSVC)
set(warnings ${msvc_warnings})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(warnings ${clang_warnings})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(warnings ${clang_warnings})
else()
set(warnings ${gcc_warnings})
endif()

target_compile_options("${target}" PRIVATE ${warnings})

endfunction()
Loading

0 comments on commit 7b3712e

Please sign in to comment.