Changeset 2107 for coopr.pyomo/trunk/examples/pyomo/pmedian/solver2.py
 Timestamp:
 Jan 2, 2010 2:03:02 AM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

coopr.pyomo/trunk/examples/pyomo/pmedian/solver2.py
r2063 r2107 28 28 soln.value = val 29 29 soln.status = SolutionStatus.feasible 30 for j in range(1,n+1):30 for j in xsequence(n): 31 31 soln.variable[instance.y[j].name] = sol[j1] 32 32 # Return results … … 36 36 def _random(self, instance): 37 37 sol = [0]*instance.N.value 38 for j in range(0,instance.P.value):38 for j in xrange(instance.P.value): 39 39 sol[j] = 1 40 40 # Generate 100 random solutions, and keep the best 41 41 best = None 42 42 best_sol = [] 43 for kk in range(100):43 for kk in xrange(100): 44 44 random.shuffle(sol) 45 45 # Compute value 46 46 val=0.0 47 for j in range(1,instance.M.value+1):47 for j in xsequence(instance.M.value): 48 48 val += min([instance.d[i,j].value 49 for i in range(1,instance.N.value+1)49 for i in xsequence(instance.N.value) 50 50 if sol[i1] == 1]) 51 51 if best is None or val < best:
Note: See TracChangeset
for help on using the changeset viewer.