Skip to content

Commit

Permalink
Merge branch 'master' into feature/alldifferent
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreTsr committed Apr 26, 2021
2 parents 4f7f737 + 1015890 commit 2637d00
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 51 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
41 changes: 25 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
Copyright (c) 2020 "Ilan Coulon", "Félix Chalumeau"
BSD 3-Clause License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Copyright (c) 2021: CORAIL-research

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
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.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SeaPearl"
uuid = "c13076dc-bdcd-48ba-bc88-4b44c2587ab3"
authors = ["Ilan Coulon", "Félix Chalumeau"]
version = "0.1.0"
version = "0.2.0"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
33 changes: 13 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
# SeaPearl
# SeaPearl.jl

[![Build Status](https://travis-ci.com/ilancoulon/SeaPearl.jl.svg?token=txSsK23gqDP8efBDxJzv&branch=master)](https://travis-ci.com/ilancoulon/SeaPearl.jl)
SeaPearl is a Constraint Programming solver that can use Reinforcement Learning agents as value-selection heuristics, using graphs as inputs for the agent's approximator. It is to be seen as a tool for researchers that gives the possibility to go above and beyond what has already been done with it.

Hybrid solver using Constraint programming and Reinforcement learning.
Ilan Coulon, Félix Chalumeau & Quentin Cappart.
The paper accompanying this solver can be found on the [arXiv](https://arxiv.org/abs/2102.09193v1). If you use SeaPearl in your research, please cite our work.

## Useful links
The RL agents are defined using [ReinforcementLearning.jl](https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl), their inputs are dealt with using [GeometricFlux.jl](https://github.com/FluxML/GeometricFlux.jl) and [Flux.jl](https://github.com/FluxML/Flux.jl). The CP part, inspired from [MiniCP](http://www.minicp.org/), is focused on readability. The code is meant to be clear and modulable so that researchers could easily get access to CP data and use it as input for their ML model.

Here are useful links
## Installation

### User interface:
Documentation of the modeling language we want to use, called JuMP http://www.juliaopt.org/JuMP.jl/v0.19.0/
```julia
]add SeaPearl
```

### Constraint Programming:
The architecture is inspired by miniCP, which is a CP solver in Java. Here is its documentation: http://www.minicp.org/
One can also check slides used to present miniCP's structure: https://school.a4cp.org/summer2017/slidedecks/MiniCP.pdf
## Use

### Reinforcement Learning:
We are using native julia packages ReinforcementLearning.jl https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl
The types were inheriting are in ReinforcementLearningBase.jl and ReinforcementLearningCore.jl and some interesting examples can be found in ReinforcementLearningZoo.jl and ReinforcementLearningEnvironments.jl
Working examples can be found in [SeaPearlZoo](https://github.com/corail-research/SeaPearlZoo).

### Machine Learning:
They are two main packages for ML at the moment. KNet.jl & Flux.jl
We are planning to use Flux.jl. Github repo : https://github.com/FluxML/Flux.jl & documentation : https://fluxml.ai/
## Contribution

All PRs and issues are welcome.

### Working on graphs:
Even if this part is still under debate, we might be working with graphs. In this case, we will use LightGraphs.jl https://github.com/JuliaGraphs/LightGraphs.jl
And the machine learning on graphs would be eased by GeometricFlux.jl https://github.com/yuehhua/GeometricFlux.jl
7 changes: 4 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ makedocs(
format = Documenter.HTML(),
modules = [SeaPearl],
pages = ["Home" => "index.md",
"Trailer" => "trailer.md",
"Constraint Programming solver" =>
["Variables" => "CP/int_variable.md"],
"Constraint Programming solver" => [
"Variables" => "CP/int_variable.md",
"Trailer" => "CP/trailer.md",
],
"Building Models" =>
["Basics" => "models/basics.md"],
"Community" => "community.md"],
Expand Down
25 changes: 19 additions & 6 deletions docs/src/CP/int_variable.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Variables

The implementation of variables in SeaPearl is heavily inspired on [MiniCP](https://minicp.readthedocs.io/en/latest/learning_minicp/part_2.html). If you have some troubles understanding how it works, you can get more visual explanations by reading their [slides](https://inginious.org/course/minicp/domains).
## Integer variables

The implementation of integer variables in SeaPearl is heavily inspired on [MiniCP](https://minicp.readthedocs.io/en/latest/learning_minicp/part_2.html). If you have some troubles understanding how it works, you can get more visual explanations by reading their [slides](https://inginious.org/course/minicp/domains).

The variables are all a subset of `AbstractIntVar`.
```@docs
SeaPearl.AbstractIntVar
```


Every `AbstractIntVar` must have a unique `id` that you can retrieve with `id`.
```@docs
Expand All @@ -15,14 +15,14 @@ SeaPearl.assign!(::SeaPearl.AbstractIntVar, ::Int)
SeaPearl.assignedValue
```

## IntVar
### IntVar

```@docs
SeaPearl.IntVar
SeaPearl.IntVar(::Int, ::Int, ::String, ::SeaPearl.Trailer)
```

## IntDomain
### IntDomain

```@docs
SeaPearl.AbstractIntDomain
Expand All @@ -44,3 +44,16 @@ SeaPearl.updateBoundsFromRemovedVal!
SeaPearl.minimum
SeaPearl.maximum
```

If you want to express some variations of an integer variable ``x`` (for example ``-x`` or ``a x`` with ``a > 0``) in a constraint, you can use the `IntVarView` types:

### IntVarView

```@docs
SeaPearl.IntVarViewMul
SeaPearl.IntVarViewMul(x::AbstractIntVar, a::Int, id::String)
SeaPearl.IntVarViewOpposite
SeaPearl.IntVarViewOpposite(x::AbstractIntVar, id::String)
SeaPearl.IntVarViewOffset
SeaPearl.IntVarViewOffset(x::AbstractIntVar, id::String)
```
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
SeaPearl was created as a way for researchers to have a constraint programming solver that can
integrate seamlessly with Reinforcement Learning technologies, using them as heuristics for value selection during branching.

The paper accompanying this solver can be found on the [arXiv](https://arxiv.org/abs/2102.09193v1). If you use SeaPearl in your research, please cite our work.

The Julia language was chosen for this project as we believe it is one of the few languages that can be used for Constraint Programming as well as Machine/Deep Learning.

The constraint programming part, whose architecture is heavily inspired from [Mini-CP framework](https://minicp.readthedocs.io/en/latest/intro.html), is focused on readability. The code was meant to be clear and modulable so that researchers could easily get access to CP data and use it as input for their ML model.

SeaPearl comes with a set of examples that can be found in the [SeaPearlZoo](https://github.com/corail-reseach/SeaPearlZoo) repository.

The new thing in SeaPearl is that the Reinforcement Learning part does *not* directly solve the CP problem, it is only used as a value-selection heuristic and therefore lets you use constraint propagation and different search strategies to, for example, prove optimality. The RL agent is only called when the CP solver has to branch and assign an arbitrary value to a variable.
Therefore, the RL agent can be trained to find good solutions as well as proving their optimality and is completely integrated into the CP framework.
6 changes: 3 additions & 3 deletions src/CP/variables/IntVarView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct IntVarViewMul <: IntVarView
id ::String

"""
IntVarViewMul(x::IntVar, a::Int, id::String)
IntVarViewMul(x::AbstractIntVar, a::Int, id::String)
Create a *fake* variable `y`, such that `y == a*x`. This variable behaves like an usual one.
"""
Expand All @@ -32,7 +32,7 @@ struct IntVarViewOpposite <: IntVarView
id ::String

"""
IntVarViewOpposite(x::IntVar, id::String)
IntVarViewOpposite(x::AbstractIntVar, id::String)
Create a *fake* variable `y`, such that `y = -x`. This variable behaves like an usual one.
"""
Expand All @@ -54,7 +54,7 @@ struct IntVarViewOffset <: IntVarView
id ::String

"""
IntDomainViewOffset(x::IntVar, id::String)
IntVarViewOffset(x::AbstractIntVar, id::String)
Create a *fake* variable `y`, such that `y = x + c`. This variable behaves like an usual one.
"""
Expand Down

0 comments on commit 2637d00

Please sign in to comment.