Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgodard committed Mar 11, 2017
2 parents 5b7aaa0 + 36dc4b4 commit a4f9974
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ A scala library for IBM ILOG CPLEX.

This library combines functional programming, mathematical programming and constraint programming allowing to
model optimization problems with a syntax that is close to the standard presentation of these problems in textbooks and
scientific papers. For instance, an expression such as:
scientific papers. For instance, a constraint such as:


![](equation.jpg)
![](equation.gif)

can be written as:

```
#!scala
sum (for (i <- 1 until n) yield a(i) * x(i)
model.add(sum (for (i <- 1 to n) yield a(i) * x(i)) <= c(j))
```

To get up to speed, the easiest way to start with this library is to study the examples:

* src/examples/mp: examples of optimization models based on mathematical programming
* src/examples/cp: examples of optimization models based on constraint programming

This library has been tested using IBM ILOG CPLEX 12.6.3 and scala 2.11.8.
This library has been tested using IBM ILOG CPLEX 12.6.1, 12.6.2, 12.6.3, 12.7.0 and scala 2.11.8.

To build the library install gradle 2.10 and set the environment variable `CPLEX_STUDIO_HOME` (e.g.
on windows `C:\IBM\ILOG\CPLEX_Studio1263`).
Expand Down
33 changes: 28 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
group 'com.decisionbrain'
version '1.0.0'
version '1.0.1'

apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'eclipse'

//
// Maven repository configuration
//

def mavenFilename = 'maven.gradle'
def gradleHome = System.getProperty("user.home") + '/.gradle/'

if (file(gradleHome + mavenFilename).exists()) {
def filename = gradleHome + mavenFilename
println("Importing gradle file $filename")
apply from: filename
}
else if (file(mavenFilename).exists()) {
def filename = mavenFilename
println("Importing gradle file $filename")
apply from: filename
}
else {
println("Warning: File $mavenFilename not found")
}


//
// CPLEX Home
//

if (!hasProperty('cplexStudioHome')) {
def cplexStudioHome = System.getenv()["CPLEX_STUDIO_DIR1263"]
if (!cplexStudioHome) {
cplexStudioHome = System.getenv()["CPLEX_STUDIO_HOME"]
}
def cplexStudioHome = System.getenv()["CPLEX_STUDIO_HOME"]
project.ext.set("cplexStudioHome", cplexStudioHome)
}

Expand Down
Binary file added equation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed equation.jpg
Binary file not shown.
3 changes: 2 additions & 1 deletion src/main/scala/com/decisionbrain/cplex/cp/Objective.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class Objective(o: IloObjective)(implicit model: CpModel) extends Addable {

/**
* Convert the objective to a character string.
* @return
*
* @return a character string
*/
override def toString: String = o.toString
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import ilog.concert.IloRange
import ilog.cp.IloCP

/**
* Created by dgodard on 09/02/2017.
* Constructor of class RangeConstraint.
*
* @param r is a CPLEX range constraint
* @param model is the constraint programming model
*/
class RangeConstraint(r: IloRange)(implicit model: CpModel) extends Constraint(r) {

Expand Down
19 changes: 15 additions & 4 deletions src/main/scala/com/decisionbrain/cplex/cp/SearchPhase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,38 @@ package com.decisionbrain.cplex.cp
import ilog.cp.IloSearchPhase

/**
* Constructor of class Objective.
* Constructor of class SearchPhase.
*
* @param s is the CPO search phase
* @param model is the constraint programming model
*/
class SearchPhase(s: IloSearchPhase)(implicit model: CpModel) {

/**
* Returns the CPLEX objective.
* Returns the CPLEX search phase.
*
* @return the CPLEX objective
* @return the CPLEX search phase
*/
def getIloSearchPhase(): IloSearchPhase = s

/**
* Convert the objective to a character string.
* Convert the search phase to a character string.
* @return
*/
override def toString: String = s.toString
}

/**
* Companion object for class SearchPhase
*/
object SearchPhase {

/**
* Creates and returns a new search phase.
*
* @param s is the CPLEX search phase
* @param model is the constraint programming model
* @return a new search phase
*/
def apply(s: IloSearchPhase)(implicit model: CpModel) = new SearchPhase(s)
}

0 comments on commit a4f9974

Please sign in to comment.