Ignore:
Timestamp:
Jan 2, 2010 2:03:02 AM (12 years ago)
Author:
wehart
Message:

Updating solver heuristics to use xrange() and xsequence()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/examples/pyomo/p-median/solver1.py

    r2044 r2107  
    2626        soln.value = val
    2727        soln.status = SolutionStatus.feasible
    28         for j in range(1,n+1):
     28        for j in xsequence(n):
    2929            if instance.y[j].value is 1:
    3030                soln.variable[instance.y[j].name] = 1
     
    3838        fixed=set()
    3939        # Initialize
    40         for j in range(1,n+1):
     40        for j in xsequence(n):
    4141            instance.y[j].value=0
    4242        # Greedily fix the next best facility
    43         for i in range(1,p+1):
     43        for i in xsequence(p):
    4444            best = None
    4545            ndx=j
    46             for j in range(1,n+1):
     46            for j in xsequence(n):
    4747                if j in fixed:
    4848                    continue
     
    5050                # Compute value
    5151                val = 0.0
    52                 for kk in range(1,m+1):
     52                for kk in xsequence(m):
    5353                    tmp=copy.copy(fixed)
    5454                    tmp.add(j)
Note: See TracChangeset for help on using the changeset viewer.