Skip to content

Commit ab15223

Browse files
Change type signature on NumExprNumeric. Remove implicit on modeler
1 parent 2dfe097 commit ab15223

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/main/scala/com/decisionbrain/cplex/IntExprNumeric.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
package com.decisionbrain.cplex
88

9-
import com.decisionbrain.cplex.cp.CpModel
10-
119
/**
1210
* Created by dgodard on 11/02/2017.
1311
*/
@@ -16,7 +14,7 @@ import com.decisionbrain.cplex.cp.CpModel
1614
*
1715
* @param modeler is the optimization model
1816
*/
19-
class IntExprNumeric(implicit modeler: Modeler) extends Numeric[IntExpr] {
17+
class IntExprNumeric(modeler: Modeler) extends Numeric[IntExpr] {
2018

2119
override def fromInt(x: Int): IntExpr = modeler.linearIntExpr(x)
2220

@@ -42,7 +40,7 @@ class IntExprNumeric(implicit modeler: Modeler) extends Numeric[IntExpr] {
4240

4341
object IntExprNumeric {
4442

45-
def apply(modeler: Modeler): Numeric[IntExpr] = new IntExprNumeric()(implicitly(modeler))
43+
def apply(modeler: Modeler): IntExprNumeric = new IntExprNumeric(modeler)
4644

47-
implicit def num(implicit modeler: Modeler): Numeric[IntExpr] = modeler.getIntExprNumeric()
45+
implicit def num(implicit modeler: Modeler): IntExprNumeric = modeler.getIntExprNumeric()
4846
}

src/main/scala/com/decisionbrain/cplex/Modeler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ abstract class Modeler {
894894
* </pre>
895895
* @return the numeric for numeric expression
896896
*/
897-
def getNumExprNumeric(): Numeric[NumExpr] = numExprNumeric
897+
def getNumExprNumeric(): NumExprNumeric = numExprNumeric
898898

899899
/**
900900
* Returns the numeric for numeric expressions. This allows to do things such as calling method sum on list of
@@ -908,7 +908,7 @@ abstract class Modeler {
908908
* </pre>
909909
* @return the numeric for integer expression
910910
*/
911-
def getIntExprNumeric(): Numeric[IntExpr] = intExprNumeric
911+
def getIntExprNumeric(): IntExprNumeric = intExprNumeric
912912

913913
}
914914

src/main/scala/com/decisionbrain/cplex/NumExprNumeric.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ package com.decisionbrain.cplex
1414
*
1515
* @param modeler is the mathematical programming model
1616
*/
17-
class NumExprNumeric(implicit modeler: Modeler) extends Numeric[NumExpr] {
17+
class NumExprNumeric(modeler: Modeler) extends Numeric[NumExpr] {
1818

1919
override def fromInt(x: Int): NumExpr = modeler.linearNumExpr(x)
2020

@@ -39,7 +39,7 @@ class NumExprNumeric(implicit modeler: Modeler) extends Numeric[NumExpr] {
3939

4040
object NumExprNumeric {
4141

42-
def apply(modeler: Modeler): Numeric[NumExpr] = new NumExprNumeric()(implicitly(modeler))
42+
def apply(modeler: Modeler): NumExprNumeric = new NumExprNumeric(modeler)
4343

44-
implicit def num(implicit model: Modeler): Numeric[NumExpr] = model.getNumExprNumeric()
44+
implicit def num(implicit model: Modeler): NumExprNumeric = model.getNumExprNumeric()
4545
}

src/main/scala/com/decisionbrain/cplex/cp/CpModel.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2226,6 +2226,14 @@ class CpModel(val name: String=null) extends Modeler {
22262226
*/
22272227
def isFixed(expr: NumVar) : Boolean = cp.isFixed(expr.getIloNumVar())
22282228

2229+
/**
2230+
* Returns true if and only if interval variable a is present in the invoking instance of CpModel.
2231+
*
2232+
* @param v is an IntervalVar
2233+
* @return a boolean
2234+
*/
2235+
def isPresent(v: IntervalVar): Boolean = cp.isPresent(v.getIloIntervalVar())
2236+
22292237
/**
22302238
* Returns the start of the interval variable.
22312239
*
@@ -3915,7 +3923,7 @@ object CpModel {
39153923
* @param f is the cumul function expression
39163924
* @param a is the interval variable
39173925
* @param v is the value of the cumul funcfion expression if the interval variable is present
3918-
* @return a new constraint on the cumul functoin expression
3926+
* @return a new constraint on the cumul function expression
39193927
*/
39203928
def alwaysEqual(f: CumulFunctionExpr, a: IntervalVar, v: Int)(implicit model: CpModel): Constraint =
39213929
model.alwaysEqual(f, a, v)

0 commit comments

Comments
 (0)