コード例 #1
0
ファイル: GeneticOperations.py プロジェクト: mag420/ArchToCE
def cross(solution1, solution2):
    levelS1 = solution1.levelSkeleton
    levelS2 = solution2.levelSkeleton
    resultWalls1 = []
    resultWalls2 = []
    for wall1, wall2 in zip(levelS1.wallSkeletons, levelS2.wallSkeletons):
        w1, w2 = crossWalls(wall1, wall2, random.uniform(0, 1))
        resultWalls1.append(w1)
        resultWalls2.append(w2)
    s1 = Solution(
        LevelSkeleton(resultWalls1, levelS1.slabSkeleton, levelS1.level))
    s2 = Solution(
        LevelSkeleton(resultWalls2, levelS1.slabSkeleton, levelS1.level))
    return s1, s2
コード例 #2
0
def cross(solution1, solution2):
    levelS1 = solution1.levelSkeleton
    levelS2 = solution2.levelSkeleton
    resultWalls1 = []
    resultWalls2 = []
    wallSkeletons1 = []
    wallSkeletons2 = []
    reserve1 = []
    reserve2 = []

    for wallskeleton in levelS1.wallSkeletons:
        if not wallskeleton.iscolumnParent:
            wallSkeletons1.append(wallskeleton)
        else:
            reserve1.append(wallskeleton)

    for wallskeleton in levelS2.wallSkeletons:
        if not wallskeleton.iscolumnParent:
            wallSkeletons2.append(wallskeleton)
        else:
            reserve2.append(wallskeleton)

    for wall1, wall2 in zip(wallSkeletons1, wallSkeletons2):
        rand = random.uniform(0, 1)
        if rand < 0.5:
            resultWalls1.append(wall1)
            resultWalls2.append(wall2)
        else:
            resultWalls1.append(wall2)
            resultWalls2.append(wall1)

    for wall in reserve1:
        resultWalls1.append(wall)
    for wall in reserve2:
        resultWalls2.append(wall)
    s1 = Solution(
        LevelSkeleton(resultWalls1, levelS1.slabSkeleton, levelS1.level))
    s2 = Solution(
        LevelSkeleton(resultWalls2, levelS1.slabSkeleton, levelS1.level))
    a = s1.levelSkeleton.ScoreOfUnacceptableVoiles()
    b = s2.levelSkeleton.ScoreOfUnacceptableVoiles()
    # print(a,b)
    if 0 < a[0] < 0.9:
        s1 = fixShortbeam(s1, a)
    if 0 < b[0] < 0.9:
        s1 = fixShortbeam(s2, b)
    return s1, s2
コード例 #3
0
ファイル: GeneticOperations.py プロジェクト: mag420/ArchToCE
def merge(solution1, solution2):
    levelS1 = solution1.levelSkeleton
    levelS2 = solution2.levelSkeleton
    resultWalls = []
    for wall1, wall2 in zip(levelS1.wallSkeletons, levelS2.wallSkeletons):
        resultWalls.append(mergeWalls(wall1, wall2))
    return Solution(
        LevelSkeleton(resultWalls, levelS1.slabSkeleton, levelS1.level))
コード例 #4
0
def cross(solution1,solution2):
    levelS1 = solution1.levelSkeleton
    levelS2 = solution2.levelSkeleton
    resultWalls1 = []
    resultWalls2 = []
    for wall1,wall2 in zip(levelS1.wallSkeletons,levelS2.wallSkeletons):
        rand = random.uniform(0,1)
        if rand < 0.5:
            resultWalls1.append(wall1)
            resultWalls2.append(wall2)
        else:
            resultWalls1.append(wall2)
            resultWalls2.append(wall1)

    s1 = Solution(LevelSkeleton(resultWalls1,levelS1.slabSkeleton,levelS1.level))
    s2 = Solution(LevelSkeleton(resultWalls2,levelS1.slabSkeleton,levelS1.level))
    return s1,s2
コード例 #5
0
ファイル: GeneticAlgorithm.py プロジェクト: ressay/ArchToCE
def generatePopulation(levelSkeleton,popSize, ratio):
    solutions = []
    while len(solutions)< popSize:
        ReserveWallS = []
        for wallskeleton in levelSkeleton.wallSkeletons:
            if wallskeleton.iscolumnParent:
                ReserveWallS.append(wallskeleton)
        for wallskeleton in ReserveWallS: levelSkeleton.wallSkeletons.remove(wallskeleton)

        Ssolution=Solution.createRandomSolutionFromSkeleton2(levelSkeleton, ratio)
        for wallskeleton in ReserveWallS:
            levelSkeleton.wallSkeletons.append(wallskeleton)
            Ssolution.levelSkeleton.wallSkeletons.append(wallskeleton)
        if Ssolution.levelSkeleton.ScoreOfUnacceptableVoiles()[0]>0.99:
            solutions.append(Ssolution)
    return solutions
コード例 #6
0
def generatePopulation(levelSkeleton, popSize, ratio):
    solutions = []
    for i in range(popSize):
        solutions.append(
            Solution.createRandomSolutionFromSkeleton2(levelSkeleton, ratio))
    return solutions