示例#1
0
	def formAnalysis(self, SSM, isViz = False, topk = 5):
		self.__TOPK = topk

		"""
		視覺化Matrix
		"""
		if isViz:
			self.__SSMViz(SSM)

		"""
		計算 SSM 中所有的 Block Family
		"""
		startTime = time.time()
		(self.__allFamilyM, cohesionM) = self.__allBlockFamily(SSM)
		endTime = time.time()
		print "LyricsForm: Family Matrix Construction Time = %.2fsec" % (endTime - startTime)

	
		"""
		產生 Cohesion Matrix
		"""
		#self.__viz.grayMatrix(cohesionM, "Cohesion Matrix")


		"""
		Block Family Combination
		"""
		self.__allFamilyM = numpy.insert(self.__allFamilyM, 0, 0, axis = 0)
		startTime = time.time()
		ff = FormFinder(self.__allFamilyM, self.__TOPK)
		combineList = ff.computing()
		endTime = time.time()

		print "LyricsForm: Block Combination Time = %.2fsec" % (endTime - startTime)
		print



		"""
		combineList 轉換成詞式格式
		"""
		lineNum = SSM.shape[0]
		formList = self.__resultForm(combineList, lineNum)


		return formList
示例#2
0
	def formAnalysis(self, SSM, isViz = False):

		"""
		視覺化Matrix
		"""
		if isViz:
			self.__SSMViz(SSM)


		
		"""
		NMF test
		from nmf import nmf
		n = SSM.shape[0]
		r = 5
		w = numpy.random.random([n, r])
		h = numpy.random.random([r, n])
		
		(wo,ho) = nmf(SSM, w, h, 0.001, 1000, 100)

		if isViz:
			self.__SSMViz(numpy.dot(wo, ho))
			
			for k in range(r):
				print k
				wmask = numpy.zeros((n, r))
				wmask[:, k] = numpy.ones(n)
				hmask = numpy.zeros((r, n))
				hmask[k, :] = numpy.ones(n)

				self.__SSMViz(numpy.dot(wo * wmask, hmask * ho))
		"""




		"""
		計算 SSM 中所有的 Block Family
		"""
		startTime = time.time()
		self.__allFamilyM = self.__allBlockFamily(SSM)
		endTime = time.time()
		print "LyricsForm: Family Matrix Construction Time = %.2fsec" % (endTime - startTime)

		self.__allFamilyM = numpy.insert(self.__allFamilyM, 0, 0, axis = 0)

		"""
		Block Family Combination
		"""
		startTime = time.time()
		ff = FormFinder(self.__allFamilyM, self.__TOPK)
		combineList = ff.computing()
		endTime = time.time()

		print "LyricsForm: Block Combination Time = %.2fsec" % (endTime - startTime)
		print



		"""
		combineList 轉換成詞式格式
		"""
		lineNum = SSM.shape[0]
		formList = self.__resultForm(combineList, lineNum)


		return formList
示例#3
0
from FormFinder import FormFinder
from Element import Element
from Structure import Structure
from Vizulization import Vizulization
from Evolution import Evolution

import matplotlib.pyplot as plt
import numpy as np

Solver = FormFinder()

plt.ion()

# Control Panel
debug = False
showViz = True
updatefreq = 1

# Variables you tune
#-----------------------------------
population = 9
num_bars = 4
niche_radius = int(np.ceil((num_bars * 2) * 0.1))
print(niche_radius)
load = 50
p_c = 0.1  #proability that you mutate the connections when you mutate
p_reset = 0.1  # proability that you reset the bars when you mutate
p_mutateL = 0.25  # amount of bars to mutate when you do mutate
p_mutateLofCB = 0.75  #proability that you mutate a cable vs a strut when you mutate the lengths
step_c = 1
step_l = 2