Module scop2 :: Class Model
[hide private]
[frames] | no frames]

Class Model

source code

object --+
         |
        Model

Instance Methods [hide private]
 
__init__(self)
SCOP model class.
source code
 
__str__(self)
Returns the information of the problem.
source code
 
addConstraint(self, con)
Adds a constraint to the model.
source code
 
addVariable(self, name='', domain=[])
Adds a variable to the model.
source code
 
addVariables(self, names=[], domain=[])
Adds variables and their (identical) domain.
source code
 
optimize(self)
Optimizes the model using scop.exe in the same directory.
source code
 
update(self)
Prepares a string representing the current model in the scop input format.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

SCOP model class.

  • Attbibutes:
    • constraints: Set of constraint objects in the model.
    • variables: Set of variable objects in the model.
    • Params: Object including all the parameters of the model.
    • varDict: Dictionary that maps variable names to their domains.
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

Returns the information of the problem. Constraints are expanded and are shown in a readable format

Overrides: object.__str__

addConstraint(self, con)

source code 

Adds a constraint to the model.

  • Argument:
    • con: A constraint object (Linear, Quadratic or AllDiff).
  • Example usage:
    >>> model.addConstraint(L)

addVariable(self, name='', domain=[])

source code 

Adds a variable to the model.

  • Arguments:
    • name: Name for new variable. A string object.
    • domain: Domain (list of values) of new variable. Each value must be a string or numeric object.
  • Return value: New variable object.
  • Example usage:
    >>> x = model.addVarriable("var")
    >>> x = model.addVariable(name="var",domain=[1,2,3])
    >>> x = model.addVariable("var",["A","B","C"])

addVariables(self, names=[], domain=[])

source code 

Adds variables and their (identical) domain.

  • Arguments:
    • names: list of new variables. A list of string objects.
    • domain: Domain (list of values) of new variables. Each value must be a string or numeric object.
  • Return value: List of new variable objects.
  • Example usage:
    >>> varlist=["var1","var2","var3"]
    >>> x = model.addVariables(varlist)
    >>> x = model.addVariables(names=varlist,domain=[1,2,3]
    >>> x = model.addVariables(varlist,["A","B","C"]

optimize(self)

source code 

Optimizes the model using scop.exe in the same directory.

  • Example usage:
    >>> model.optimize()