• R/O
  • SSH

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

File Info

Rev. 7cdeba5a3e541f1591a63d099e7246b7cce041ea
大小 1,072 字节
时间 2015-07-01 19:50:06
作者 Lorenzo Isella
Log Message

I completed the Python code to generate the analytical results for fragmenting the unit segment.

Content

#! /usr/bin/env python


import numpy as np
import scipy as s


def break_segment(n):
        x = np.arange(1, n + 1, 1)
        d = 1. / n * (1. / (n - x + 1)).cumsum()
        return d


# def break_segment(n, r_to_n):
#         x = np.arange(1, n + 1, 1)
#         d = 1. / n * (1. / (n - x + 1)).cumsum()
#         return d



number_frag=100


nvec=s.zeros(0)
frag_vec=s.zeros(0)
kvec=s.zeros(0)

# fragments=break_segment(n)

# print(fragments)

for j in xrange(number_frag):
        n=j+1
        temp= break_segment(n)
        temp2=s.tile(n, len(temp))
        temp3=s.arange(1, len(temp)+1,1)
        temp3=s.flipud(temp3)
        
        frag_vec=s.hstack((frag_vec, temp))
        nvec=s.hstack((nvec, temp2))
        kvec=s.hstack((kvec, temp3))


print(frag_vec)

s.savetxt("fragmentation.dat", frag_vec)
s.savetxt("fragmentation-number-cuts.dat", nvec,fmt='%d')
s.savetxt("fragmentation-number-of-the-piece.dat", kvec,fmt='%d')

res=s.transpose(s.vstack((frag_vec, nvec, kvec)))
s.savetxt("results-frag.dat", res,"%f, %d, %d ")



print ("So far so good")