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

Class Model

source code

object --+
         |
        Model

Instance Methods [hide private]
 
__init__(self)
OptSeq model class.
source code
 
__str__(self)
str(x)
source code
 
addActivity(self, name='', duedate='inf', weight=1)
Add an activity to the model.
source code
 
addResource(self, name='', capacity={}, rhs=0, direction='<=')
Add a resource to the model.
source code
 
addTemporal(self, pred, succ, tempType='CS', delay=0)
Add a temporal constraint to the model.
source code
 
optimize(self)
Optimize the model using optseq.exe in the same directory.
source code
 
write(self, filename='optseq.txt')
Output the gantt's chart as a text file.
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 

OptSeq model class.

  • Attbibutes:
    • activities: Dictionary that maps activity names to activity objects in the model.
    • modes: Dictionary that maps mode names to mode objects in the model.
    • resources: Dictionary that maps resource names to resource objects in the model.
    • temporals: Dictionary that maps pairs of activity names to temporal constraint objects in the model.
    • Params: Object including all the parameters of the model.
    • act: List of all the activity objects in the model.
    • res: List of all the resource objects in the model.
    • tempo: List of all the tamporal constraint objects in the model.
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

addActivity(self, name='', duedate='inf', weight=1)

source code 

Add an activity to the model.

  • Arguments:
    • name: Name for new activity. A string object except "source" and "sink." Remark that strings in OptSeq are restricted to a-z, A-Z, 0-9,[],_ and @.
    • duedate(optional): Duedate of activity. A non-nagative integer or string "inf."
    • weight(optional): Panalty of one unit of tardiness. Positive integer.
  • Return value: New activity object.
  • Example usage:
    >>> a = model.addActivity("act1")
    >>> a = model.addActivity(name="act1",duedate=20,weight=100)
    >>> a = model.addActivity("act1",20,100)

addResource(self, name='', capacity={}, rhs=0, direction='<=')

source code 

Add a resource to the model.

  • Arguments:
    • name: Name for new resource. Remark that strings in OptSeq are restricted to a-z, A-Z, 0-9,[],_ and @.
    • capacity (optional): Capacity dictionary of the renewable (standard) resource.
    • Capacity dictionary maps intervals (pairs of start time and finish time) to amounts of capacity.
    • rhs (optional): Right-hand-side constant of nonrenewable resource constraint.
    • direction (optional): Rirection (or sense) of nonrenewable resource constraint; "<=" (default) or ">=" or "=".
  • Return value: New resource object.
  • Example usage:
    >>> r=model.addResource("res1")
    >>> r=model.addResource("res1", {(0,10):1,(12,100):2} )
    >>> r=model.addResource("res2",rhs=10,direction=">=")

addTemporal(self, pred, succ, tempType='CS', delay=0)

source code 

Add a temporal constraint to the model.

A temporal constraint has the following form:

   predecessor's completion (start) time +delay <=
                   successor's start (completion) time.

Parameter "delay" can be negative.

  • Arguments:
    • pred: Predecessor (an activity object) or string "source." Here, "source" specifies a dummy activity that precedes all other activities and starts at time 0.
    • succ: Successor (an activity object) or string "source." Here, "source" specifies a dummy activity that precedes all other activities and starts at time 0.
    • tempType (optional): String that differentiates the temporal type. "CS" (default)=Completion-Start, "SS"=Start-Start, "SC"= Start-Completion, "CC"=Completion-Completion.
    • delay (optional): Time lag between the completion (start) times of two activities.
  • Return value: New temporal object.
  • Example usage:
    >>> t=model.addTemporal(act1,act2)
    >>> t=model.addTemporal(act1,act2,type="SS",delay=-10)

    To specify the start time of activity act is exactly 50, we use two temporal constraints:

    >>> t=model.addTemporal("source",act,type="SS",delay=50)
    >>> t=model.addTemporal(act,"source",type="SS",delay=50)

optimize(self)

source code 

Optimize the model using optseq.exe in the same directory.

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

write(self, filename='optseq.txt')

source code 

Output the gantt's chart as a text file.

  • Argument:
    • filename: Output file name. Default="optseq.txt."
  • Example usage:
    >>> model.write("sample.txt")