Esempio n. 1
0
	def Decomposition(self,mole,oldMol,index,shiftcost,flowcost,N):
		operator = Operators()
		newMol1, newMol2 = operator.Decomposition(oldMol)
		#print('DEcom ',newMol1,'\n',newMol2)
		pe1 = CRO().CalculatePE(newMol1,shiftcost,flowcost,N)
		pe2 = CRO().CalculatePE(newMol2,shiftcost,flowcost,N)
		mole.moleculeTable.append(newMol1)
		mole.moleculeTable.append(newMol2)
		#print(mole.moleculeTable)
		mole.PE.append(pe1)
		mole.PE.append(pe2)

		e_dec = 0
		gamma1 = 0
		gamma2 = 0
		gamma3 = 0
		gamma1 = random.uniform(0,1)
		gamma2 = random.uniform(0,1)

		if ((mole.PE[index] + mole.KE1[index]) >= (pe1+pe2)):
			e_dec = (mole.PE[index] + mole.KE1[index]) - (pe1 + pe2)
		else:
			e_dec = (mole.PE[index] + mole.KE1[index]) + gamma1 * gamma2 * self.buffer - (pe1 + pe2)
		# endif
		mole.KE1.append(e_dec * gamma3)

		if (e_dec>=0):
			self.buffer = self.buffer * (1 -( gamma1*gamma2))
			gamma3 = random.uniform(0,1)

			#mole.moleculeTable[index] = newMol1
			#mole.PE[index] = pe1
			mole.KE1[index] = e_dec * gamma3
			#mole.numHit[index] = 0
			#mole.minHit[index] = 0
			#mole.minStruct[index] = newMol1
			#mole.minPE[index] = pe1

			#mole.moleculeTable.append(newMol1)
			#mole.PE.append(pe1)
			#mole.KE1.append(e_dec * gamma3)
			mole.numHit.append(0)
			mole.minHit.append(0)
			mole.minStruct.append(newMol1)
			mole.minPE.append(pe1)
Esempio n. 2
0
    def Decomposition(self, mole, oldMol, index):
        operator = Operators()
        newMol1, newMol2 = operator.Decomposition(oldMol)
        pe1 = CRO().CalculatePE(mole, newMol1)
        pe2 = CRO().CalculatePE(mole, newMol2)

        e_dec = 0
        gamma1 = 0
        gamma2 = 0
        gamma3 = 0
        gamma1 = random.uniform(0, 1)
        gamma2 = random.uniform(0, 1)

        if ((mole.PE1[index] + mole.KE1[index]) >= (pe1 + pe2)):
            e_dec = (mole.PE1[index] + mole.KE1[index]) - (pe1 + pe2)
        else:
            e_dec = (mole.PE1[index] + mole.KE1[index]
                     ) + gamma1 * gamma2 * self.buffer - (pe1 + pe2)
        # endif

        if (e_dec >= 0):
            self.buffer = self.buffer * (1 - (gamma1 * gamma2))
            gamma3 = random.uniform(0, 1)

            mole.moleculeTable[index] = newMol1
            mole.PE1[index] = pe1
            mole.KE1[index] = e_dec * gamma3
            mole.numHit[index] = 0
            mole.minHit[index] = 0
            mole.minStruct[index] = newMol1
            mole.minPE[index] = pe1

            mole.moleculeTable.append(newMol1)
            mole.PE1.append(pe1)
            mole.KE1.append(e_dec * gamma3)
            mole.numHit.append(0)
            mole.minHit.append(0)
            mole.minStruct.append(newMol1)
            mole.minPE.append(pe1)

        else:
            mole.numHit[index] = mole.numHit[index] + 1