Example #1
0
 def schedule(dist,task,node_list):
     """
     Simple scheduler. For every appropriate node (Compute node)
     finds the sum to the prior nodes
     """
     priorities = Scheduler.prepare_priority_list(task,node_list)
     min_dist = sys.maxint
     min_glob = sys.maxint
     min_id = -1
     for node in node_list:
         if not isinstance(node,Node.ComputeNode):
             continue
         max_route = sys.maxint()
         for prior in priorities:
             traf = dist[node.id][prior[0]]*prior[1]
             if traf > max_route: # We are searching for maximum traffic on route link
                 max_route = traf
         if max_route < min_glob:
             min_glob = max_route
             min_id = node.id
         #    sum += dist[node.id][prior[0]]*prior[1] # the sum of <distance to prior node> * <priority of node>
         # sys.stdout.write("For node " + str(node.id) + " distance is " + str(sum) + "\n") # debug line
         #if sum < min_dist:
         #    min_dist = sum
         #    min_id = node.id
     return min_id
Example #2
0
 def schedule(dist, task, node_list):
     """
     Simple scheduler. For every appropriate node (Compute node)
     finds the sum to the prior nodes
     """
     priorities = Scheduler.prepare_priority_list(task, node_list)
     min_dist = sys.maxint
     min_glob = sys.maxint
     min_id = -1
     for node in node_list:
         if not isinstance(node, Node.ComputeNode):
             continue
         max_route = sys.maxint()
         for prior in priorities:
             traf = dist[node.id][prior[0]] * prior[1]
             if traf > max_route:  # We are searching for maximum traffic on route link
                 max_route = traf
         if max_route < min_glob:
             min_glob = max_route
             min_id = node.id
         #    sum += dist[node.id][prior[0]]*prior[1] # the sum of <distance to prior node> * <priority of node>
         # sys.stdout.write("For node " + str(node.id) + " distance is " + str(sum) + "\n") # debug line
         #if sum < min_dist:
         #    min_dist = sum
         #    min_id = node.id
     return min_id
Example #3
0
    def chooseNode():
        if not self.nodes:
            return False
        least_used_node = None
        least_node_amount = maxint()
        for node in self.nodes:
            if node.instancesAmount() < least_node_amount:
                least_used_node = node
                least_node_amount = node.instancesAmount()
        return least_used_node
        

 

         




          
#triangleIntersection.py
"""
Jens V Hansen 
jensvhansen.com

A triangle class primaily written to check the distance between point 'q' and triangle 'n'.
Which is why the functions return True or False instead of numeric values as in distances.

A basic implementation of a 3D vector is needed to use the clasees.
"""
# import 'myVector' as Veector3 
from sys import maxint

global MAX = maxint() 

class Edge(object):
    def __init__(self, v0, v1):
        """
        Structure to hold the references of the edge.
        """
        # edge vertices
        self.v0 = v0
        self.v1 = v1
        
        # edge vector
        self.ev = self.v1 - self.v0
        
    def normal(self):
        return self.ev.normal()
    
    def length(self):
Example #5
0
import sys
import fnmatch
import subprocess
import shutil

# Check the system platform first
platform = sys.platform
print "This is a " + platform + " system"

if platform.startswith('linux'):
    messenger_dir = 'mexa64'
elif platform.startswith('darwin'):
    messenger_dir = 'mexmaci64'
if platform.startswith('win32'):
    # We further need to differniate 32 from 64 bit:
    maxint = sys.maxint()
    if maxint == 9223372036854775807:
        messenger_dir = 'mexw64'
    elif maxint == 2147483647:
        messenger_dir = 'mexw32'
    
# Open the configure file and start parsing
config = open(os.path.join(messenger_dir, 'local.cfg'), 'r')

for line in config:
    path = line.split('=')

    if path[0] == "MATLAB_BIN":
        print "Searching for Matlab bin folder in local.cfg ..."
        matlab_bin = path[1].rstrip('\r\n')
        if matlab_bin == "":
Example #6
0
#GAUSSIAN INTEGER

import cmath as cm
import sys 

final_div_sum = [0]
sum_divi = 0
n = sys.maxint(raw_input( ))

divi = [1]



def complex_divisor(divi,n,k):

	for i in range(1,n+1):
		 






for l in range(1,n+1):
	divi = [1]
	for i in range(2,l+1):   # real valued factors
		if l%i == 0:
			divi.append(i)

	print divi               #comment this line out
Example #7
0
     Python 2: x = 0755   # 0开头
     Python 3: x = 0o755  # 0o开头
   2.long 类型
     Python 2有为非浮点数准备的 int 和 long 类型。 int 类型的最大值不能超过 sys.maxint,而且这个最大值是平台相关的。
       整数可以通过在数字的末尾附上一个L来定义长整型,显然,它比 int 类型表示的数字范围更大。
     Python 3里,只有一种整数类型 int,大多数情况下,它很像Python 2里的长整型。
       由于已经不存在两种类型的整数,所以就没有必要使用特殊的语法去区别他们。

     由于 long 类型在Python 3的取消,引起以下改变
          Python 2              Python 3            说明
      ① x = 1000000000000L    x = 1000000000000   # 十进制的普通整数
      ② x = 0xFFFFFFFFFFFFL   x = 0xFFFFFFFFFFFF  # 十六进制的普通整数
      ③ long(x)               int(x)              # long()函数没有了。可以使用int()函数强制转换一个变量到整型。
      ④ type(x) is long       type(x) is int      # 检查一个变量是否是整型
      ⑤ isinstance(x, long)   isinstance(x, int)  # 也可以使用 isinstance()函数来检查数据类型
   3.sys.maxint(sys.maxsize)
     由于长整型和整型被整合在一起了, sys.maxint常量不再精确。
     因为这个值对于检测特定平台的能力还是有用处的,所以它被Python 3保留,并且重命名为 sys.maxsize。
         Python 2                Python 3
     ① from sys import maxint  from sys import maxsize  # maxint变成了maxsize。
     ② a_function(sys.maxint)  a_function(sys.maxsize)  # 所有的sys.maxint都变成了sys.maxsize。

  int 是 types.IntType 的代名词
    print(id(int)) # 打印如:505210872
    import types;print(id(types.IntType)) # 打印如:505210872


  高精度的数值类型
    float 精度不够高,有时候需要更高精度的类型 decimal
    python 支持的是:
        from decimal import Decimal