├── tools ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── nfp_utls.cpython-37.pyc │ ├── input_utls.cpython-37.pyc │ ├── calculate_npf.cpython-37.pyc │ └── placement_worker.cpython-37.pyc ├── input_utls.py ├── calculate_npf.py └── placement_worker.py ├── .gitignore ├── images ├── nfp.png ├── belowleft.png ├── bigfirst.png ├── parallel.png ├── afterPacking.png ├── square_like.png ├── beforePacking.png └── problem_description.png ├── out └── uml │ ├── 优化流程图 │ └── 优化流程图.png │ └── 评估流程图 │ └── 评估流程图.png ├── doc ├── software_description.docx └── software_description.pptx ├── uml ├── 主程序流程图.plantuml ├── 评估流程图.plantuml └── 优化流程图.plantuml ├── run ├── placement.c ├── data ├── polygon_area_etc_input_0.txt ├── result_0.txt ├── polygon_area_etc_input_1.txt ├── polygon_area_etc_input_13.txt ├── polygon_area_etc_input_2.txt ├── polygon_area_etc_input_8.txt ├── polygon_area_etc_input_10.txt ├── polygon_area_etc_input_7.txt ├── polygon_area_etc_input_3.txt ├── polygon_area_etc_input_9.txt ├── polygon_area_etc_input_6.txt ├── polygon_area_etc_input_4.txt ├── polygon_area_etc_input_12.txt ├── polygon_area_etc_input_5.txt └── polygon_area_etc_input_11.txt ├── setting.py ├── LICENCE ├── README.md ├── GAlgo.py ├── main.py └── nest.py /tools/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | .vs -------------------------------------------------------------------------------- /images/nfp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/images/nfp.png -------------------------------------------------------------------------------- /images/belowleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/images/belowleft.png -------------------------------------------------------------------------------- /images/bigfirst.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/images/bigfirst.png -------------------------------------------------------------------------------- /images/parallel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/images/parallel.png -------------------------------------------------------------------------------- /images/afterPacking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/images/afterPacking.png -------------------------------------------------------------------------------- /images/square_like.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/images/square_like.png -------------------------------------------------------------------------------- /out/uml/优化流程图/优化流程图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/out/uml/优化流程图/优化流程图.png -------------------------------------------------------------------------------- /out/uml/评估流程图/评估流程图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/out/uml/评估流程图/评估流程图.png -------------------------------------------------------------------------------- /images/beforePacking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/images/beforePacking.png -------------------------------------------------------------------------------- /doc/software_description.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/doc/software_description.docx -------------------------------------------------------------------------------- /doc/software_description.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/doc/software_description.pptx -------------------------------------------------------------------------------- /images/problem_description.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/images/problem_description.png -------------------------------------------------------------------------------- /tools/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/tools/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /tools/__pycache__/nfp_utls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/tools/__pycache__/nfp_utls.cpython-37.pyc -------------------------------------------------------------------------------- /tools/__pycache__/input_utls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/tools/__pycache__/input_utls.cpython-37.pyc -------------------------------------------------------------------------------- /tools/__pycache__/calculate_npf.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/tools/__pycache__/calculate_npf.cpython-37.pyc -------------------------------------------------------------------------------- /tools/__pycache__/placement_worker.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mrlution/RectilinearPackingProblemSolver/HEAD/tools/__pycache__/placement_worker.cpython-37.pyc -------------------------------------------------------------------------------- /uml/主程序流程图.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | '主程序流程图 3 | scale 1080 width 4 | start 5 | floating note left: 主程序流程图 6 | ->Mpi fork; 7 | fork 8 | :optimization进程; 9 | fork again 10 | :evaluation进程; 11 | end fork 12 | end 13 | @enduml 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -D__USE_XOPEN2K8 -E ./placement.c -o placement.i 3 | gcc -D__USE_XOPEN2K8 -S ./placement.i -o placement.s 4 | gcc -D__USE_XOPEN2K8 -c ./placement.s -o placement.o 5 | gcc -D__USE_XOPEN2K8 placement.o -o placement.exe 6 | rm ./placement.i 7 | rm ./placement.s 8 | rm ./placement.o 9 | -------------------------------------------------------------------------------- /placement.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int main(int argc,char *argv[]) { 5 | char command[50]={"python3 /home/eda20303/project/code/main.py -d "}; 6 | strcat(command,argv[1]); 7 | printf("%s",command); 8 | system(command); 9 | } 10 | -------------------------------------------------------------------------------- /uml/评估流程图.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | scale 1080 width 3 | start 4 | floating note left: slave评估程序流程图 5 | 6 | while(接收信号) is (不是终止信号) 7 | 8 | if(接收信号是计算NFP信号)then(yes) 9 | :接收图形信息; 10 | :计算NFP; 11 | :返回计算结果; 12 | endif 13 | if(接收信号是评估个体信号)then(yes) 14 | :接收个体信息; 15 | :评估个体; 16 | :返回计算结果; 17 | endif 18 | endwhile(终止信号) 19 | end 20 | @enduml 21 | 22 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_0.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (60,131)(77,131)(77,129)(68,129)(68,123)(60,123) 3 | Polygon: 4 | (60,72)(60,84)(69,84)(69,72) 5 | Polygon: 6 | (68,116)(68,111)(66,111)(66,106)(60,106)(60,123)(65,123)(65,116) 7 | Polygon: 8 | (5,131)(5,123)(0,123)(0,131) 9 | Polygon: 10 | (3,140)(3,146)(0,146)(0,140) 11 | Polygon: 12 | (86,63)(80,63)(80,55)(86,55) 13 | Polygon: 14 | (47,99)(49,99)(49,89)(40,89)(40,91)(47,91) -------------------------------------------------------------------------------- /uml/优化流程图.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | scale 1080 width 3 | start 4 | floating note left: 优化程序流程图 5 | '优化程序流程图 6 | :加载数据文件; 7 | :加载超参数; 8 | :计算图形之间,图形和容器之间的NFP,并发送给slave; 9 | 10 | partition 初始化种群 { 11 | :创建placement基因; 12 | :创建rotation基因; 13 | while(种群中个体足够了吗?) is (不够) 14 | :创建个体; 15 | endwhile(够了) 16 | } 17 | while(达到代数) is (没有) 18 | :将种群发送给评估脚本slave评估; 19 | :得到每个个体的评估结果fitness; 20 | partition 生成下一代种群{ 21 | :选择操作; 22 | :交叉操作; 23 | :变异操作; 24 | } 25 | endwhile(达到了) 26 | :保存结果; 27 | end 28 | 29 | @enduml 30 | 31 | -------------------------------------------------------------------------------- /data/result_0.txt: -------------------------------------------------------------------------------- 1 | In Polygon: 2 | (60,131)(77,131)(77,129)(68,129)(68,123)(60,123) 3 | Out Polygon: 4 | (6.0,9.0)(6.0,0.0)(8.0,0.0)(8.0,17.0)(0.0,17.0)(0.0,9.0) 5 | In Polygon: 6 | (60,72)(60,84)(69,84)(69,72) 7 | Out Polygon: 8 | (15.0,10.0)(24.0,10.0)(24.0,22.0)(15.0,22.0) 9 | In Polygon: 10 | (68,116)(68,111)(66,111)(66,106)(60,106)(60,123)(65,123)(65,116) 11 | Out Polygon: 12 | (14.0,5.0)(16.0,5.0)(16.0,10.0)(13.0,10.0)(13.0,17.0)(8.0,17.0)(8.0,0.0)(14.0,0.0) 13 | In Polygon: 14 | (5,131)(5,123)(0,123)(0,131) 15 | Out Polygon: 16 | (5.0,8.0)(0.0,8.0)(0.0,0.0)(5.0,0.0) 17 | In Polygon: 18 | (3,140)(3,146)(0,146)(0,140) 19 | Out Polygon: 20 | (0.0,22.0)(0.0,19.0)(6.0,19.0)(6.0,22.0) 21 | In Polygon: 22 | (86,63)(80,63)(80,55)(86,55) 23 | Out Polygon: 24 | (16.0,0.0)(22.0,0.0)(22.0,8.0)(16.0,8.0) 25 | In Polygon: 26 | (47,99)(49,99)(49,89)(40,89)(40,91)(47,91) 27 | Out Polygon: 28 | (5.0,19.0)(5.0,17.0)(13.0,17.0)(13.0,10.0)(15.0,10.0)(15.0,19.0) -------------------------------------------------------------------------------- /setting.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | ''' 3 | @File : setting.py 4 | @Time : 2020/11/19 19:16:36 5 | @Author : KingofCode 6 | @Version : 1.0 7 | @Contact : mrlution@qq.com 8 | @Desc : 程序运行参数 9 | ''' 10 | # here put the import lib 11 | import platform 12 | 13 | class Settings: 14 | DEBUG=True #开发模式 15 | 16 | #自动选择操作系统 17 | SysOS=platform.system() 18 | if SysOS == "Windows": 19 | LINUXOS=False #windows OS 20 | DRAWPIC=True #是否绘图 21 | NWORKER=4 # 线程数目 22 | else: 23 | LINUXOS=True #Linux OS 24 | DRAWPIC=False #勿改动 linux服务器不绘图 25 | NWORKER=31 #勿改动 26 | 27 | #遗传算法参数 28 | POPULATION_SIZE = 31 # 基因组数 29 | MUTA_RATE = 10 # 变异概率 30 | 31 | #初始容器参数 32 | USE_FORMULA=True 33 | SQRT_LENTH_SCALE=1.2 #容器高度BIN_HEIGHT为总面积乘以SQRT_LENTH_SCALE 34 | 35 | #中止条件 36 | STOP_GENERATION=1 37 | SMALLCASE_EXPECTATION=0.84 38 | 39 | #复杂度分类后按面积排序策略 40 | ORINGINAL_STRATEGY=False #为True时 图形不分类,从大到小排 41 | COMPLEX_FIRST_STRATEGY=True #为True时 分三类,每类从大到小排,一个类一个类排. 42 | COMPLEX_FIRST_AREA_SECOND_STRATEGY=False #为True复杂的大的先,不复杂的小的后,复杂的小的,不复杂的小的 43 | MIXED_COMPLEX_STRATEGY=False #为True时,分两类,每类从大到小排 44 | 45 | # Warning: 以下参数请勿改动 46 | # 容器尺寸 47 | BIN_NORMAL = [[0, 0], [0, 1000], [2000, 1000], [2000, 0]] #顺时针顺序 # 一般布是无限长 48 | SQRT_LENTH_SCALE2=2.0 #容器长度BIN_WIDTH为总面积乘以SQRT_LENTH_SCALE2 2是为了保证足够长 49 | SCALE=10.0 50 | SPACING = 0 # 图形间隔空间 51 | ROTATIONS = 4 # 旋转选择, 1: 不能旋转 52 | 53 | settings=Settings() -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Mr.Lution 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_1.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (60,131)(77,131)(77,129)(68,129)(68,123)(60,123) 3 | Polygon: 4 | (60,72)(60,84)(69,84)(69,72) 5 | Polygon: 6 | (68,116)(68,111)(66,111)(66,106)(60,106)(60,123)(65,123)(65,116) 7 | Polygon: 8 | (5,131)(5,123)(0,123)(0,131) 9 | Polygon: 10 | (3,140)(3,146)(0,146)(0,140) 11 | Polygon: 12 | (86,63)(80,63)(80,55)(86,55) 13 | Polygon: 14 | (47,99)(49,99)(49,89)(40,89)(40,91)(47,91) 15 | Polygon: 16 | (20,64)(20,55)(23,55)(23,61)(29,61)(29,64) 17 | Polygon: 18 | (40,148)(47,148)(47,140)(40,140) 19 | Polygon: 20 | (105,100)(103,100)(103,95)(100,95)(100,89)(109,89)(109,95)(105,95) 21 | Polygon: 22 | (85,95)(80,95)(80,89)(85,89) 23 | Polygon: 24 | (80,128)(82,128)(82,123)(80,123) 25 | Polygon: 26 | (7,72)(0,72)(0,77)(7,77) 27 | Polygon: 28 | (27,115)(29,115)(29,106)(20,106)(20,109)(27,109) 29 | Polygon: 30 | (0,111)(0,106)(3,106)(3,111) 31 | Polygon: 32 | (28,150)(20,150)(20,140)(39,140)(39,145)(28,145) 33 | Polygon: 34 | (0,63)(0,58)(4,58)(4,55)(9,55)(9,71)(6,71)(6,63) 35 | Polygon: 36 | (29,95)(20,95)(20,89)(29,89) 37 | Polygon: 38 | (60,58)(65,58)(65,55)(60,55) 39 | Polygon: 40 | (68,89)(68,97)(66,97)(66,91)(60,91)(60,89) 41 | Polygon: 42 | (108,63)(100,63)(100,55)(108,55) 43 | Polygon: 44 | (108,129)(108,123)(100,123)(100,129)(102,129)(102,139)(104,139)(104,129) 45 | Polygon: 46 | (30,128)(20,128)(20,123)(30,123) 47 | Polygon: 48 | (90,107)(80,107)(80,106)(90,106) 49 | Polygon: 50 | (108,86)(100,86)(100,81)(106,81)(106,72)(108,72) 51 | Polygon: 52 | (12,89)(12,97)(0,97)(0,89) 53 | Polygon: 54 | (104,119)(106,119)(106,113)(109,113)(109,106)(100,106)(100,113)(104,113) 55 | Polygon: 56 | (65,140)(60,140)(60,148)(65,148) 57 | Polygon: 58 | (80,72)(82,72)(82,79)(80,79) 59 | Polygon: 60 | (55,72)(55,81)(50,81)(50,75)(40,75)(40,72) 61 | Polygon: 62 | (40,55)(47,55)(47,67)(40,67) 63 | Polygon: 64 | (20,79)(20,72)(29,72)(29,77)(36,77)(36,79) 65 | Polygon: 66 | (48,131)(40,131)(40,123)(48,123) 67 | Polygon: 68 | (40,111)(45,111)(45,106)(40,106) 69 | Polygon: 70 | (86,156)(89,156)(89,140)(80,140)(80,146)(86,146) 71 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_13.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (60,131)(77,131)(77,129)(68,129)(68,123)(60,123) 3 | Polygon: 4 | (60,72)(60,84)(69,84)(69,72) 5 | Polygon: 6 | (68,116)(68,111)(66,111)(66,106)(60,106)(60,123)(65,123)(65,116) 7 | Polygon: 8 | (5,131)(5,123)(0,123)(0,131) 9 | Polygon: 10 | (3,140)(3,146)(0,146)(0,140) 11 | Polygon: 12 | (86,63)(80,63)(80,55)(86,55) 13 | Polygon: 14 | (47,99)(49,99)(49,89)(40,89)(40,91)(47,91) 15 | Polygon: 16 | (20,64)(20,55)(23,55)(23,61)(29,61)(29,64) 17 | Polygon: 18 | (40,148)(47,148)(47,140)(40,140) 19 | Polygon: 20 | (105,100)(103,100)(103,95)(100,95)(100,89)(109,89)(109,95)(105,95) 21 | Polygon: 22 | (85,95)(80,95)(80,89)(85,89) 23 | Polygon: 24 | (80,128)(82,128)(82,123)(80,123) 25 | Polygon: 26 | (7,72)(0,72)(0,77)(7,77) 27 | Polygon: 28 | (27,115)(29,115)(29,106)(20,106)(20,109)(27,109) 29 | Polygon: 30 | (0,111)(0,106)(3,106)(3,111) 31 | Polygon: 32 | (28,150)(20,150)(20,140)(39,140)(39,145)(28,145) 33 | Polygon: 34 | (0,63)(0,58)(4,58)(4,55)(9,55)(9,71)(6,71)(6,63) 35 | Polygon: 36 | (29,95)(20,95)(20,89)(29,89) 37 | Polygon: 38 | (60,58)(65,58)(65,55)(60,55) 39 | Polygon: 40 | (68,89)(68,97)(66,97)(66,91)(60,91)(60,89) 41 | Polygon: 42 | (108,63)(100,63)(100,55)(108,55) 43 | Polygon: 44 | (108,129)(108,123)(100,123)(100,129)(102,129)(102,139)(104,139)(104,129) 45 | Polygon: 46 | (30,128)(20,128)(20,123)(30,123) 47 | Polygon: 48 | (90,107)(80,107)(80,106)(90,106) 49 | Polygon: 50 | (108,86)(100,86)(100,81)(106,81)(106,72)(108,72) 51 | Polygon: 52 | (12,89)(12,97)(0,97)(0,89) 53 | Polygon: 54 | (104,119)(106,119)(106,113)(109,113)(109,106)(100,106)(100,113)(104,113) 55 | Polygon: 56 | (65,140)(60,140)(60,148)(65,148) 57 | Polygon: 58 | (80,72)(82,72)(82,79)(80,79) 59 | Polygon: 60 | (55,72)(55,81)(50,81)(50,75)(40,75)(40,72) 61 | Polygon: 62 | (40,55)(47,55)(47,67)(40,67) 63 | Polygon: 64 | (20,79)(20,72)(29,72)(29,77)(36,77)(36,79) 65 | Polygon: 66 | (48,131)(40,131)(40,123)(48,123) 67 | Polygon: 68 | (40,111)(45,111)(45,106)(40,106) 69 | Polygon: 70 | (86,156)(89,156)(89,140)(80,140)(80,146)(86,146) 71 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_2.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (30,74)(30,83)(23,83)(23,77)(15,77)(15,74) 3 | Polygon: 4 | (30,84)(37,84)(37,74)(30,74) 5 | Polygon: 6 | (0,131)(0,145)(5,145)(5,135)(16,135)(16,131) 7 | Polygon: 8 | (15,104)(15,93)(27,93)(27,104) 9 | Polygon: 10 | (60,78)(60,80)(66,80)(66,83)(73,83)(73,74)(70,74)(70,78) 11 | Polygon: 12 | (15,150)(15,155)(26,155)(26,150) 13 | Polygon: 14 | (45,115)(45,112)(51,112)(51,115) 15 | Polygon: 16 | (60,101)(65,101)(65,93)(60,93) 17 | Polygon: 18 | (91,114)(91,112)(75,112)(75,120)(80,120)(80,114) 19 | Polygon: 20 | (58,136)(58,143)(45,143)(45,137)(48,137)(48,131)(53,131)(53,136) 21 | Polygon: 22 | (51,80)(45,80)(45,74)(51,74) 23 | Polygon: 24 | (30,116)(37,116)(37,112)(30,112) 25 | Polygon: 26 | (20,131)(15,131)(15,146)(19,146)(19,142)(26,142)(26,137)(20,137) 27 | Polygon: 28 | (96,74)(96,80)(90,80)(90,74) 29 | Polygon: 30 | (81,100)(81,93)(75,93)(75,100) 31 | Polygon: 32 | (60,63)(60,55)(72,55)(72,63) 33 | Polygon: 34 | (90,95)(90,93)(108,93)(108,105)(105,105)(105,95) 35 | Polygon: 36 | (5,129)(8,129)(8,124)(11,124)(11,112)(0,112)(0,117)(5,117) 37 | Polygon: 38 | (0,87)(7,87)(7,74)(0,74) 39 | Polygon: 40 | (75,55)(75,58)(80,58)(80,55) 41 | Polygon: 42 | (0,59)(0,55)(13,55)(13,59) 43 | Polygon: 44 | (94,112)(97,112)(97,130)(90,130)(90,127)(94,127) 45 | Polygon: 46 | (90,131)(90,139)(96,139)(96,133)(106,133)(106,131) 47 | Polygon: 48 | (15,68)(24,68)(24,55)(15,55) 49 | Polygon: 50 | (68,131)(68,134)(60,134)(60,131) 51 | Polygon: 52 | (13,156)(13,161)(0,161)(0,150)(2,150)(2,156) 53 | Polygon: 54 | (45,98)(45,93)(55,93)(55,98) 55 | Polygon: 56 | (30,62)(30,64)(43,64)(43,55)(41,55)(41,62) 57 | Polygon: 58 | (38,101)(30,101)(30,93)(38,93) 59 | Polygon: 60 | (77,131)(75,131)(75,144)(86,144)(86,142)(77,142) 61 | Polygon: 62 | (19,123)(21,123)(21,120)(24,120)(24,112)(15,112)(15,116)(19,116) 63 | Polygon: 64 | (64,120)(60,120)(60,112)(64,112) 65 | Polygon: 66 | (0,95)(0,93)(3,93)(3,95) 67 | Polygon: 68 | (86,79)(86,74)(75,74)(75,79)(79,79)(79,82)(82,82)(82,79) 69 | Polygon: 70 | (45,55)(45,57)(50,57)(50,55) 71 | Polygon: 72 | (94,55)(94,57)(90,57)(90,55) 73 | Polygon: 74 | (30,131)(35,131)(35,141)(30,141) 75 | Polygon: 76 | (32,150)(30,150)(30,163)(37,163)(37,161)(32,161) 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rectilinear Packing Problem Solver 2 | 3 | ![](https://img.shields.io/github/languages/top/Mrlution/RectilinearPackingProblemSolver?color=brightgreen) 4 | ![](https://img.shields.io/github/languages/code-size/Mrlution/RectilinearPackingProblemSolver?color=brightgreen) 5 | ![](https://img.shields.io/github/languages/count/Mrlution/RectilinearPackingProblemSolver?logoColor=brightgreen?color=brightgreen) 6 | 7 | 8 | Packing and layout problems are common in both engineering and non-engineering applications. In the Very Large Scale Integrated Circuit design, we often pack different IP Cores into a rectangular container. Usually, the IP Core is a rectilinear shape. To cut down the cost, we need to minimize the container. So the EDA software needs a fast and robust and high performance algorithm to solve the packing problem. Apart from EDA Software, many other industrial applications such as cloth cutting and newspaper layout are involved with this algorithm. 9 | 10 | The term rectilinear means the interior angles of the packed blocks are either 90 degrees or 270 degrees. The container is usually a rectangle with a fixed width and unrestricted height. The algorithm will pack all the polygonal blocks into the container without overlapping, and generate a height as small as possible. 11 | 12 | 13 | ![](images/problem_description.png) 14 | 15 | 16 | # Requirements 17 | ![](https://img.shields.io/badge/python-v3.7.0%20tested-brightgreen) 18 | 19 | [mpi4py==3.0.3](https://pypi.org/project/mpi4py/) Before you install mpi4py, you need to install a mpi software such as OpenMpi or Microsoft MPI. 20 | 21 | [pyclipper==1.2.0](https://pypi.org/project/pyclipper/) 22 | 23 | [Polygon3==3.0.8](https://pypi.org/project/Polygon3/) When you install Polygon3, you must begin with a capital "P" 24 | 25 | # How to run 26 | ```python main.py -d data_file.txt``` 27 | 28 | look at data/polygon_area_etc_input_id.txt for data format 29 | 30 | # Result 31 | This is an packing example. For our dataset, the average occupation rate is 85%. 32 | 33 | ![](images/beforePacking.png) 34 | 35 | ![](images/afterPacking.png) 36 | 37 | # How this work 38 | 39 | ## NFP 40 | Outter NFP is used to avoid overlap between objects. Inner NFP is used to ensure the objects in the bin. 41 | 42 | ![](images/nfp.png) 43 | 44 | ## Below left stratage 45 | All Object is packed at the below left position. 46 | 47 | ![](images/belowleft.png) 48 | 49 | ## Complex and big first stratage 50 | 51 | ![](images/bigfirst.png) 52 | 53 | ## Parallel computation 54 | The computation of NFPs can be parallelized, we use MPI as the parallel computation tool. 55 | 56 | ![](images/parallel.png) 57 | 58 | ## More about this project 59 | the "doc" folder contains [docx](doc/software_description.docx) and [pptx](doc/software_description.pptx) files, they described this software in detail. 60 | -------------------------------------------------------------------------------- /tools/input_utls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | #import dxfgrabber 3 | 4 | 5 | # def find_shape_from_dxf(file_name): 6 | # """ 7 | # 读取DXF文档,从LINE里面找出多边形 8 | # :param file_name: 文档路径 9 | # :return: 10 | # """ 11 | # dxf = dxfgrabber.readfile(file_name) 12 | # all_shapes = list() 13 | # new_polygon = dict() 14 | # for e in dxf.entities: 15 | # if e.dxftype == 'LINE': 16 | # # print (e.start, e.end) 17 | # # 找封闭的多边形 18 | # # 线条不按顺序画 19 | # end_key = '{}x{}'.format(e.end[0], e.end[1]) 20 | # star_key = '{}x{}'.format(e.start[0], e.start[1]) 21 | # if end_key in new_polygon: 22 | # # 找到闭合的多边形 23 | # all_shapes.append(new_polygon[end_key]) 24 | # new_polygon.pop(end_key) 25 | # continue 26 | 27 | # # 开始和结束点转换 28 | # if star_key in new_polygon: 29 | # # 找到闭合的多边形 30 | # all_shapes.append(new_polygon[star_key]) 31 | # new_polygon.pop(star_key) 32 | # continue 33 | 34 | # # 找连接的点 35 | # has_find = False 36 | # for key, points in new_polygon.items(): 37 | # if points[-1][0] == e.start[0] and points[-1][1] == e.start[1]: 38 | # new_polygon[key].append([e.end[0], e.end[1]]) 39 | # has_find = True 40 | # break 41 | # if points[-1][0] == e.end[0] and points[-1][1] == e.end[1]: 42 | # new_polygon[key].append([e.start[0], e.start[1]]) 43 | # has_find = True 44 | # break 45 | 46 | # if not has_find: 47 | # new_polygon['{}x{}'.format( 48 | # e.start[0], e.start[1])] = [[e.start[0], e.start[1]], [e.end[0], e.end[1]]] 49 | # return all_shapes 50 | 51 | 52 | # def input_polygon(dxf_file): 53 | # """ 54 | # :param dxf_file: 文件地址 55 | # :param is_class: 返回Polygon 类,或者通用的 list 56 | # :return: 57 | # """ 58 | # # 从dxf文件中提取数据 59 | # datas = find_shape_from_dxf(dxf_file) 60 | # shapes = list() 61 | 62 | # for i in range(0, len(datas)): 63 | # shapes.append(datas[i]) 64 | 65 | # #print (shapes) 66 | # return shapes 67 | 68 | import re 69 | 70 | 71 | def vertices_str_to_list(vertices_str): 72 | 73 | pattern = re.compile(r'\((.+?)\)') 74 | vertices_temp=pattern.findall(vertices_str) 75 | vertices_list=[] 76 | for item in vertices_temp: 77 | x,y=item.split(",", 1) 78 | vertices_list.append([float(x)*10,float(y)*10]) #记得删除10 79 | return vertices_list 80 | 81 | def load_input_file(filename): 82 | polygons=[] 83 | polygons_str=[] 84 | with open(filename,'r',encoding='utf-8') as f: 85 | lines=f.readlines() 86 | # TODO:check file format 87 | for i in range(len(lines)): 88 | if i % 2 == 1: 89 | polygon_str=lines[i] 90 | polygons_str.append(polygon_str.strip('\n')) 91 | polygon_vertices_list=vertices_str_to_list(polygon_str) 92 | polygons.append(polygon_vertices_list) 93 | #print(polygons) 94 | return polygons,polygons_str 95 | 96 | # def polygonArea(polygon): 97 | # #计算多边形面积,负数说明点的顺序是逆时针 98 | # area=0 99 | # i=0 100 | # j=len(polygon)-1 101 | # while i sarea: 35 | clipper_nfp = p 36 | largest_area = sarea 37 | 38 | clipper_nfp = [{ 39 | 'x': clipper_nfp[i]['x'] + Bc[0][0] * -1, 40 | 'y':clipper_nfp[i]['y'] + Bc[0][1] * -1 41 | } for i in range(0, len(clipper_nfp))] 42 | #print("结果",clipper_nfp) 43 | return [clipper_nfp] 44 | 45 | 46 | 47 | 48 | 49 | class NFP_Calculater(): 50 | """NFP计算类 51 | """ 52 | 53 | # def __init__(self,config=None): 54 | # if config: 55 | # self.config=config 56 | # else: 57 | # config={ 58 | # 'useHoles': False, # 是否有洞,暂时都是没有洞 59 | # 'exploreConcave': False # 寻找凹面,暂时是否 60 | # } 61 | 62 | @staticmethod 63 | def process_nfp(pair): 64 | """ 65 | 计算所有图形两两组合的相切多边形(NFP) 66 | :param pair: 两个组合图形的参数 67 | :return: 68 | """ 69 | if pair is None or len(pair) == 0: 70 | return None 71 | 72 | # 考虑有没有洞和凹面 73 | # search_edges = self.config['exploreConcave'] 74 | # use_holes = self.config['useHoles'] 75 | search_edges=False 76 | use_holes=False 77 | 78 | # 图形参数 79 | #print("beforerotation",pair['A']['points'],pair['B']['points']) 80 | A = copy.deepcopy(pair['A']) 81 | A['points'] = nfp_utls.rotate_polygon(A['points'], pair['key']['A_rotation'])['points'] 82 | B = copy.deepcopy(pair['B']) 83 | B['points'] = nfp_utls.rotate_polygon(B['points'], pair['key']['B_rotation'])['points'] 84 | #print("afterrotation",A['points'],B['points']) 85 | 86 | 87 | if pair['key']['inside']: 88 | # 内切或者外切 89 | if nfp_utls.is_rectangle(A['points']): 90 | #print("points1",A['points'], B['points']) 91 | nfp = nfp_utls.nfp_rectangle(A['points'], B['points']) 92 | #print("nfp1",nfp) 93 | 94 | else: 95 | nfp = nfp_utls.nfp_polygon(A, B, True, search_edges) 96 | 97 | # ensure all interior NFPs have the same winding direction 98 | if nfp and len(nfp) > 0: 99 | for i in range(0, len(nfp)): 100 | if nfp_utls.polygon_area(nfp[i]) > 0: 101 | nfp[i].reverse() 102 | else: 103 | pass 104 | # print('NFP Warning:', pair['key']) 105 | 106 | else: 107 | if search_edges: 108 | #print(A['points'], B['points']) 109 | nfp = nfp_utls.nfp_polygon(A, B, False, search_edges) 110 | else: 111 | #print("points2",A['points'], B['points']) 112 | 113 | nfp = minkowski_difference(A, B) 114 | #print("nfp2",nfp) 115 | 116 | # 检查NFP多边形是否合理 117 | if nfp is None or len(nfp) == 0: 118 | pass 119 | # print('error in NFP 260') 120 | # print('NFP Error:', pair['key']) 121 | # print('A;', A) 122 | # print('B:', B) 123 | return None 124 | 125 | for i in range(0, len(nfp)): 126 | # if search edges is active, only the first NFP is guaranteed to pass sanity check 127 | if not search_edges or i == 0: 128 | if abs(nfp_utls.polygon_area(nfp[i])) < abs(nfp_utls.polygon_area(A['points'])): 129 | pass 130 | # print('error in NFP area 269') 131 | # print('NFP Area Error: ', abs(nfp_utls.polygon_area(nfp[i])), pair['key']) 132 | # print('NFP:', json.dumps(nfp[i])) 133 | # print('A: ', A) 134 | # print('B: ', B) 135 | nfp.pop(i) 136 | return None 137 | 138 | if len(nfp) == 0: 139 | return None 140 | # for outer NFPs, the first is guaranteed to be the largest. 141 | # Any subsequent NFPs that lie inside the first are hole 142 | for i in range(0, len(nfp)): 143 | if nfp_utls.polygon_area(nfp[i]) > 0: 144 | nfp[i].reverse() 145 | 146 | if i > 0: 147 | if nfp_utls.point_in_polygon(nfp[i][0], nfp[0]): 148 | if nfp_utls.polygon_area(nfp[i]) < 0: 149 | nfp[i].reverse() 150 | 151 | # generate nfps for children (holes of parts) if any exist 152 | # 有洞的暂时不管 153 | if use_holes and len(A) > 0: 154 | pass 155 | 156 | return {'key': pair['key'], 'value': nfp} 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /GAlgo.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | ''' 3 | @File : GAlgo.py 4 | @Time : 2020/11/19 19:15:51 5 | @Author : KingofCode 6 | @Version : 1.0 7 | @Contact : mrlution@qq.com 8 | @Desc : 遗传算法 9 | ''' 10 | 11 | # here put the import lib 12 | import copy 13 | from tools import nfp_utls 14 | import random 15 | 16 | 17 | class genetic_algorithm(): 18 | """ 19 | 遗传算法类 20 | """ 21 | 22 | def __init__(self, adam, bin_polygon, config): 23 | """ 24 | 初始化参数,根据参数生成基因群 25 | :param adam: 亚当,初代种群中的图形 26 | :param bin_polygon: 盒子 27 | :param config: 算法参数 28 | """ 29 | self.bin_bounds = bin_polygon['points'] 30 | self.bin_bounds = { 31 | 'width': bin_polygon['width'], 32 | 'height': bin_polygon['height'], 33 | } 34 | self.config = config 35 | self.bin_polygon = bin_polygon 36 | angles = list() 37 | shapes = copy.deepcopy(adam) 38 | for shape in shapes: 39 | #angles.append(0) 40 | angles.append(self.random_angle(shape))#随机得到个体的旋转角度 41 | 42 | # 基因群,图形顺序和图形旋转的角度作为基因编码 43 | #print("-----------------first population-----------------------") 44 | self.population = [{'placement': shapes, 'rotation': angles}] 45 | #print(self.population) 46 | #print("-----------------end of first population-----------------------") 47 | 48 | for i in range(1, self.config['populationSize']): 49 | mutant = self.mutate(self.population[0]) 50 | self.population.append(mutant) 51 | 52 | def random_angle(self, shape): 53 | """ 54 | 随机旋转角度的选取 55 | :param shape: 56 | :return: 57 | """ 58 | angle_list = list() 59 | for i in range(0, self.config['rotations']): 60 | angle_list.append(i * (360/self.config['rotations'])) 61 | 62 | # 打乱顺序 63 | def shuffle_array(data): 64 | for i in range(len(data)-1, 0, -1): 65 | j = random.randint(0, i) 66 | data[i], data[j] = data[j], data[i] 67 | return data 68 | 69 | 70 | angle_list = shuffle_array(angle_list) 71 | 72 | # 查看选择后图形是否能放置在里面 73 | for angle in angle_list: 74 | rotate_part = nfp_utls.rotate_polygon(shape[1]['points'], angle) 75 | # 是否判断旋转出界,没有出界可以返回旋转角度,rotate 只是尝试去转,没有真正改变图形坐标 76 | if rotate_part['width'] < self.bin_bounds['width'] and rotate_part['height'] < self.bin_bounds['height']: 77 | return angle_list[i] 78 | #return 0 79 | 80 | return 0 81 | 82 | def mutate(self, individual): 83 | clone = { 84 | 'placement': individual['placement'][:], 85 | 'rotation': individual['rotation'][:] 86 | } 87 | for i in range(0, len(clone['placement'])): 88 | if random.random() < 0.01 * self.config['mutationRate']: 89 | if i+1 < len(clone['placement']): 90 | clone['placement'][i],clone['placement'][i+1] = clone['placement'][i+1], clone['placement'][i] 91 | if random.random() < 0.01 * self.config['mutationRate']: 92 | clone['rotation'][i] = self.random_angle(clone['placement'][i]) 93 | #TODO:后面的使劲变 94 | 95 | # for i in range(int(len(clone['placement'])*0.9), len(clone['placement'])): 96 | # if 1: 97 | # if i+1 < len(clone['placement']): 98 | # clone['placement'][i],clone['placement'][i+1] = clone['placement'][i+1], clone['placement'][i] 99 | # if 1: 100 | # clone['rotation'][i] = self.random_angle(clone['placement'][i]) 101 | 102 | 103 | return clone 104 | 105 | def generation(self): 106 | # 适应度 从小到大排列 fitness越小越好 107 | self.population = sorted(self.population, key=lambda a: a['fitness']) 108 | new_population = [self.population[0]] 109 | while len(new_population) < self.config['populationSize']: 110 | male = self.random_weighted_individual() 111 | female = self.random_weighted_individual(male) 112 | # 交配得到下一代 113 | children = self.mate(male, female) 114 | 115 | # 轻微突变 116 | new_population.append(self.mutate(children[0])) 117 | 118 | if len(new_population) < self.config['populationSize']: 119 | new_population.append(self.mutate(children[1])) 120 | # print("------------------new population----------------------") 121 | # print ('new :', new_population) 122 | # print("------------------end new population----------------------") 123 | self.population = new_population 124 | 125 | def random_weighted_individual(self, exclude=None): 126 | #排名越靠前选中几率越大 127 | pop = self.population 128 | if exclude and pop.index(exclude) >= 0: 129 | pop.remove(exclude) 130 | rand = random.random() 131 | lower = 0 132 | weight = 1.0 / len(pop) 133 | upper = weight 134 | pop_len = len(pop) 135 | for i in range(0, pop_len): 136 | if (rand > lower) and (rand < upper): 137 | return pop[i] 138 | lower = upper 139 | upper += 2 * weight * float(pop_len-i)/pop_len 140 | return pop[0] 141 | 142 | def mate(self, male, female): 143 | cutpoint = random.randint(0, len(male['placement'])-1) 144 | gene1 = male['placement'][:cutpoint] 145 | rot1 = male['rotation'][:cutpoint] 146 | 147 | gene2 = female['placement'][:cutpoint] 148 | rot2 = female['rotation'][:cutpoint] 149 | 150 | def contains(gene, shape_id): 151 | for i in range(0, len(gene)): 152 | if gene[i][0] == shape_id: 153 | return True 154 | return False 155 | 156 | for i in range(len(female['placement'])-1, -1, -1): 157 | if not contains(gene1, female['placement'][i][0]): 158 | gene1.append(female['placement'][i]) 159 | rot1.append(female['rotation'][i]) 160 | 161 | for i in range(len(male['placement'])-1, -1, -1): 162 | if not contains(gene2, male['placement'][i][0]): 163 | gene2.append(male['placement'][i]) 164 | rot2.append(male['rotation'][i]) 165 | 166 | return [{'placement': gene1, 'rotation': rot1}, {'placement': gene2, 'rotation': rot2}] 167 | 168 | 169 | def minkowski_difference(A, B): 170 | """ 171 | 两个多边形的相切空间 172 | http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Functions/MinkowskiDiff.htm 173 | :param A: 174 | :param B: 175 | :return: 176 | """ 177 | Ac = [[p['x'], p['y']] for p in A['points']] 178 | Bc = [[p['x'] * -1, p['y'] * -1] for p in B['points']] 179 | solution = pyclipper.MinkowskiSum(Ac, Bc, True) 180 | largest_area = None 181 | clipper_nfp = None 182 | for p in solution: 183 | p = [{'x': i[0], 'y':i[1]} for i in p] 184 | sarea = nfp_utls.polygon_area(p) 185 | if largest_area is None or largest_area > sarea: 186 | clipper_nfp = p 187 | largest_area = sarea 188 | 189 | clipper_nfp = [{ 190 | 'x': clipper_nfp[i]['x'] + Bc[0][0] * -1, 191 | 'y':clipper_nfp[i]['y'] + Bc[0][1] * -1 192 | } for i in range(0, len(clipper_nfp))] 193 | return [clipper_nfp] 194 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_9.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (190,386)(190,389)(191,389)(191,393)(192,393)(192,378)(191,378)(191,386) 3 | Polygon: 4 | (152,134)(152,125)(159,125)(159,134) 5 | Polygon: 6 | (209,125)(209,127)(215,127)(215,125) 7 | Polygon: 8 | (0,125)(0,136)(3,136)(3,126)(14,126)(14,125) 9 | Polygon: 10 | (76,286)(91,286)(91,298)(76,298) 11 | Polygon: 12 | (57,217)(61,217)(61,225)(57,225) 13 | Polygon: 14 | (136,290)(136,286)(133,286)(133,290) 15 | Polygon: 16 | (191,367)(198,367)(198,355)(191,355)(191,359)(190,359)(190,361)(191,361) 17 | Polygon: 18 | (139,309)(133,309)(133,317)(139,317) 19 | Polygon: 20 | (174,378)(171,378)(171,392)(183,392)(183,388)(174,388) 21 | Polygon: 22 | (38,240)(47,240)(47,247)(38,247) 23 | Polygon: 24 | (216,346)(209,346)(209,332)(225,332)(225,339)(216,339) 25 | Polygon: 26 | (31,159)(31,148)(29,148)(29,158)(19,158)(19,159) 27 | Polygon: 28 | (222,230)(222,217)(209,217)(209,230) 29 | Polygon: 30 | (8,407)(8,401)(0,401)(0,407) 31 | Polygon: 32 | (8,286)(12,286)(12,300)(0,300)(0,297)(8,297) 33 | Polygon: 34 | (159,384)(159,378)(152,378)(152,384) 35 | Polygon: 36 | (44,335)(38,335)(38,332)(44,332) 37 | Polygon: 38 | (0,177)(0,171)(7,171)(7,177) 39 | Polygon: 40 | (23,177)(23,171)(19,171)(19,177) 41 | Polygon: 42 | (47,194)(47,204)(46,204)(46,195)(38,195)(38,194) 43 | Polygon: 44 | (125,205)(114,205)(114,194)(125,194) 45 | Polygon: 46 | (228,178)(233,178)(233,171)(228,171) 47 | Polygon: 48 | (76,217)(81,217)(81,220)(76,220) 49 | Polygon: 50 | (14,263)(14,269)(0,269)(0,263)(5,263)(5,265)(7,265)(7,263) 51 | Polygon: 52 | (152,178)(154,178)(154,171)(152,171) 53 | Polygon: 54 | (209,171)(211,171)(211,173)(209,173) 55 | Polygon: 56 | (178,217)(176,217)(176,218)(171,218)(171,225)(184,225)(184,218)(178,218) 57 | Polygon: 58 | (38,222)(50,222)(50,217)(38,217) 59 | Polygon: 60 | (114,240)(117,240)(117,244)(114,244) 61 | Polygon: 62 | (209,249)(220,249)(220,248)(211,248)(211,240)(209,240) 63 | Polygon: 64 | (125,378)(125,394)(114,394)(114,378) 65 | Polygon: 66 | (234,292)(228,292)(228,286)(234,286) 67 | Polygon: 68 | (29,413)(31,413)(31,401)(19,401)(19,404)(29,404) 69 | Polygon: 70 | (171,247)(177,247)(177,240)(171,240) 71 | Polygon: 72 | (155,263)(152,263)(152,276)(164,276)(164,272)(155,272) 73 | Polygon: 74 | (95,286)(95,292)(101,292)(101,286) 75 | Polygon: 76 | (183,295)(183,298)(171,298)(171,286)(175,286)(175,295) 77 | Polygon: 78 | (190,293)(190,286)(196,286)(196,293) 79 | Polygon: 80 | (178,309)(184,309)(184,321)(171,321)(171,318)(178,318) 81 | Polygon: 82 | (19,194)(29,194)(29,197)(20,197)(20,207)(19,207) 83 | Polygon: 84 | (76,194)(76,204)(87,204)(87,194) 85 | Polygon: 86 | (180,138)(171,138)(171,135)(179,135)(179,125)(180,125) 87 | Polygon: 88 | (38,286)(53,286)(53,297)(38,297) 89 | Polygon: 90 | (80,343)(76,343)(76,332)(80,332) 91 | Polygon: 92 | (95,221)(95,217)(96,217)(96,221) 93 | Polygon: 94 | (29,274)(29,263)(28,263)(28,272)(19,272)(19,274) 95 | Polygon: 96 | (106,355)(95,355)(95,366)(106,366) 97 | Polygon: 98 | (171,194)(182,194)(182,195)(172,195)(172,205)(171,205) 99 | Polygon: 100 | (184,171)(171,171)(171,182)(184,182) 101 | Polygon: 102 | (133,208)(143,208)(143,205)(134,205)(134,194)(133,194) 103 | Polygon: 104 | (0,230)(0,217)(12,217)(12,230) 105 | Polygon: 106 | (233,361)(233,362)(232,362)(232,367)(228,367)(228,355)(232,355)(232,361) 107 | Polygon: 108 | (19,381)(28,381)(28,378)(19,378) 109 | Polygon: 110 | (76,311)(78,311)(78,309)(76,309) 111 | Polygon: 112 | (102,171)(102,177)(95,177)(95,171) 113 | Polygon: 114 | (171,357)(171,355)(184,355)(184,367)(178,367)(178,357) 115 | Polygon: 116 | (6,359)(4,359)(4,358)(0,358)(0,355)(11,355)(11,358)(6,358) 117 | Polygon: 118 | (114,336)(125,336)(125,332)(114,332) 119 | Polygon: 120 | (229,240)(228,240)(228,243)(229,243) 121 | Polygon: 122 | (212,263)(219,263)(219,273)(212,273)(212,269)(209,269)(209,268)(212,268) 123 | Polygon: 124 | (190,125)(193,125)(193,134)(190,134) 125 | Polygon: 126 | (1,240)(1,243)(0,243)(0,240) 127 | Polygon: 128 | (61,240)(57,240)(57,253)(61,253)(61,249)(65,249)(65,248)(61,248) 129 | Polygon: 130 | (95,246)(95,240)(103,240)(103,246) 131 | Polygon: 132 | (153,194)(153,200)(152,200)(152,194) 133 | Polygon: 134 | (144,140)(144,125)(142,125)(142,137)(133,137)(133,140) 135 | Polygon: 136 | (243,263)(228,263)(228,275)(243,275) 137 | Polygon: 138 | (38,125)(38,131)(45,131)(45,125) 139 | Polygon: 140 | (10,378)(12,378)(12,391)(0,391)(0,389)(10,389) 141 | Polygon: 142 | (45,312)(43,312)(43,312)(38,312)(38,309)(52,309)(52,312)(45,312) 143 | Polygon: 144 | (95,125)(104,125)(104,131)(95,131) 145 | Polygon: 146 | (62,263)(62,265)(57,265)(57,263) 147 | Polygon: 148 | (45,378)(45,386)(38,386)(38,378) 149 | Polygon: 150 | (27,355)(19,355)(19,368)(37,368)(37,362)(27,362) 151 | Polygon: 152 | (125,273)(114,273)(114,272)(124,272)(124,263)(125,263) 153 | Polygon: 154 | (15,205)(0,205)(0,194)(15,194) 155 | Polygon: 156 | (233,131)(228,131)(228,125)(233,125) 157 | Polygon: 158 | (152,286)(152,289)(158,289)(158,286) 159 | Polygon: 160 | (171,341)(187,341)(187,340)(175,340)(175,332)(171,332) 161 | Polygon: 162 | (228,231)(228,217)(239,217)(239,231) 163 | Polygon: 164 | (153,355)(160,355)(160,365)(153,365)(153,362)(152,362)(152,361)(153,361) 165 | Polygon: 166 | (133,240)(133,242)(143,242)(143,240) 167 | Polygon: 168 | (57,332)(63,332)(63,338)(57,338) 169 | Polygon: 170 | (95,154)(95,148)(107,148)(107,160)(104,160)(104,154) 171 | Polygon: 172 | (228,390)(228,378)(229,378)(229,388)(238,388)(238,390) 173 | Polygon: 174 | (183,263)(183,275)(171,275)(171,263) 175 | Polygon: 176 | (152,148)(152,158)(153,158)(153,149)(163,149)(163,148) 177 | Polygon: 178 | (0,309)(0,320)(12,320)(12,309) 179 | Polygon: 180 | (236,148)(238,148)(238,149)(243,149)(243,152)(228,152)(228,149)(236,149) 181 | Polygon: 182 | (152,222)(162,222)(162,217)(152,217) 183 | Polygon: 184 | (57,357)(57,355)(61,355)(61,357) 185 | Polygon: 186 | (122,223)(114,223)(114,217)(122,217) 187 | Polygon: 188 | (95,200)(98,200)(98,194)(95,194) 189 | Polygon: 190 | (106,263)(106,273)(104,273)(104,264)(95,264)(95,263) 191 | Polygon: 192 | (133,367)(133,355)(143,355)(143,367) 193 | Polygon: 194 | (38,364)(53,364)(53,363)(41,363)(41,355)(38,355) 195 | Polygon: 196 | (190,209)(190,194)(201,194)(201,209) 197 | Polygon: 198 | (158,240)(158,245)(152,245)(152,240) 199 | Polygon: 200 | (201,227)(201,217)(199,217)(199,226)(190,226)(190,227) 201 | Polygon: 202 | (143,332)(133,332)(133,342)(143,342) 203 | Polygon: 204 | (63,171)(63,178)(57,178)(57,171) 205 | Polygon: 206 | (133,263)(137,263)(137,269)(133,269) 207 | Polygon: 208 | (171,148)(171,152)(179,152)(179,148) 209 | Polygon: 210 | (115,290)(115,286)(114,286)(114,290) 211 | Polygon: 212 | (190,154)(196,154)(196,148)(190,148) 213 | Polygon: 214 | (133,378)(133,387)(135,387)(135,379)(144,379)(144,378) 215 | Polygon: 216 | (114,125)(128,125)(128,135)(114,135) 217 | Polygon: 218 | (86,158)(86,148)(85,148)(85,157)(76,157)(76,158) 219 | Polygon: 220 | (143,171)(133,171)(133,182)(143,182) 221 | Polygon: 222 | (214,378)(209,378)(209,391)(214,391)(214,386)(216,386)(216,385)(214,385) 223 | Polygon: 224 | (57,136)(60,136)(60,125)(57,125) 225 | Polygon: 226 | (193,309)(190,309)(190,311)(193,311) 227 | Polygon: 228 | (19,309)(26,309)(26,315)(19,315) 229 | Polygon: 230 | (209,148)(209,151)(215,151)(215,148) 231 | Polygon: 232 | (159,309)(152,309)(152,315)(159,315) 233 | Polygon: 234 | (57,378)(57,381)(63,381)(63,378) 235 | Polygon: 236 | (157,337)(158,337)(158,335)(161,335)(161,332)(152,332)(152,335)(157,335) 237 | Polygon: 238 | (133,228)(133,217)(140,217)(140,228) 239 | Polygon: 240 | (154,160)(154,148)(147,148)(147,158)(133,158)(133,160) 241 | Polygon: 242 | (11,164)(0,164)(0,148)(11,148) 243 | Polygon: 244 | (31,343)(19,343)(19,341)(29,341)(29,332)(31,332) 245 | Polygon: 246 | (228,348)(239,348)(239,332)(228,332) 247 | Polygon: 248 | (18,334)(18,340)(0,340)(0,334)(6,334)(6,332)(10,332)(10,334) 249 | Polygon: 250 | (76,125)(77,125)(77,137)(76,137) 251 | Polygon: 252 | (210,286)(209,286)(209,290)(210,290) 253 | Polygon: 254 | (209,194)(220,194)(220,197)(211,197)(211,207)(209,207) 255 | Polygon: 256 | (203,342)(203,332)(190,332)(190,342) 257 | Polygon: 258 | (85,263)(76,263)(76,265)(84,265)(84,274)(85,274) 259 | Polygon: 260 | (19,125)(19,135)(33,135)(33,125) 261 | Polygon: 262 | (104,342)(104,332)(103,332)(103,341)(95,341)(95,342) 263 | Polygon: 264 | (125,181)(125,171)(114,171)(114,181) 265 | Polygon: 266 | (114,153)(114,154)(114,154)(114,157)(121,157)(121,148)(114,148)(114,153) 267 | Polygon: 268 | (60,309)(60,319)(57,319)(57,309) 269 | Polygon: 270 | (81,356)(80,356)(80,356)(76,356)(76,355)(89,355)(89,356)(81,356) 271 | Polygon: 272 | (38,171)(47,171)(47,175)(38,175) 273 | Polygon: 274 | (190,172)(190,171)(193,171)(193,172) 275 | Polygon: 276 | (57,194)(62,194)(62,200)(57,200) 277 | Polygon: 278 | (210,240)(210,251)(204,251)(204,241)(190,241)(190,240) 279 | Polygon: 280 | (52,278)(38,278)(38,263)(52,263) 281 | Polygon: 282 | (38,240)(38,249)(32,249)(32,241)(19,241)(19,240) 283 | Polygon: 284 | (86,255)(76,255)(76,240)(86,240) 285 | Polygon: 286 | (94,181)(94,171)(89,171)(89,180)(76,180)(76,181) 287 | Polygon: 288 | (209,355)(222,355)(222,369)(209,369) 289 | Polygon: 290 | (214,309)(209,309)(209,320)(214,320) 291 | Polygon: 292 | (113,314)(113,309)(95,309)(95,320)(98,320)(98,314) 293 | Polygon: 294 | (117,392)(117,378)(110,378)(110,389)(95,389)(95,392) 295 | Polygon: 296 | (127,325)(114,325)(114,309)(127,309) 297 | Polygon: 298 | (120,355)(114,355)(114,368)(120,368)(120,363)(122,363)(122,361)(120,361) 299 | Polygon: 300 | (19,286)(24,286)(24,296)(19,296) 301 | Polygon: 302 | (60,286)(60,291)(57,291)(57,286) 303 | Polygon: 304 | (76,378)(81,378)(81,385)(76,385) 305 | Polygon: 306 | (192,263)(192,268)(190,268)(190,263) 307 | Polygon: 308 | (19,223)(19,224)(20,224)(20,228)(26,228)(26,217)(20,217)(20,223) 309 | Polygon: 310 | (57,148)(57,160)(60,160)(60,148) 311 | Polygon: 312 | (228,310)(228,309)(230,309)(230,310) 313 | Polygon: 314 | (228,197)(228,202)(242,202)(242,197)(237,197)(237,194)(235,194)(235,197) 315 | Polygon: 316 | (41,148)(38,148)(38,157)(41,157) 317 | Polygon: 318 | (38,404)(38,401)(40,401)(40,404) 319 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | ''' 3 | @File : main.py 4 | @Time : 2020/11/19 18:30:11 5 | @Author : KingofCode 6 | @Version : 1.0 7 | @Contact : mrlution@qq.com 8 | @Desc : 文件完成MPI的启动,配置初始化,数据集加载,启动打包过程 9 | ''' 10 | 11 | # here put the import lib 12 | from setting import settings 13 | from nest import Nester 14 | from nest import find_fitness 15 | from tools.calculate_npf import NFP_Calculater 16 | from tools import input_utls 17 | import os 18 | import sys 19 | import time 20 | import math 21 | import argparse 22 | import subprocess 23 | import re 24 | 25 | # MPI 26 | from mpi4py import MPI 27 | comm = MPI.COMM_WORLD 28 | rank = comm.Get_rank() 29 | 30 | def master(data): 31 | """主程序 32 | 33 | 34 | Args: 35 | data (str): 数据集路径 36 | """ 37 | if settings.DEBUG: 38 | import time 39 | start_time = time.time() 40 | from nest import content_loop_rate 41 | 42 | n = Nester() 43 | global nWorker 44 | n.nWorker=nWorker 45 | 46 | file_path,file_name=os.path.split(data) 47 | if settings.LINUXOS: 48 | file_path="/home/eda20303/project/verify_results" 49 | file_id=re.findall("\d+",file_name)[0] 50 | 51 | #s = input_utls.input_polygon('tools/f6.dxf') 52 | shapes,shapes_str=input_utls.load_input_file(data) 53 | n.add_objects(shapes,shapes_str) 54 | nshapes=len(shapes) 55 | if settings.USE_FORMULA: 56 | if nshapes<10: 57 | settings.SQRT_LENTH_SCALE=1.1102 58 | elif nshapes>900: 59 | settings.SQRT_LENTH_SCALE=1.0645 60 | else: 61 | settings.SQRT_LENTH_SCALE=(-8.2175e-11)*(nshapes**3)+(1.9941e-07)*(nshapes**2)-(1.6552e-04)*nshapes+1.1118 62 | #settings.SQRT_LENTH_SCALE=(nshapes^3)*(-6.6730e-11)+(nshapes^2)*(2.0656e-07)+nshapes*(-2.0632e-04)+1.1292; 63 | if nshapes<=90: 64 | settings.STOP_GENERATION=10 65 | else: 66 | settings.STOP_GENERATION=1 67 | 68 | 69 | sqrt_lenth=math.sqrt(n.shapes_total_area) 70 | 71 | bin_width=sqrt_lenth*settings.SQRT_LENTH_SCALE 72 | 73 | if bin_width>300*settings.SCALE: 74 | bin_width=300*settings.SCALE 75 | 76 | settings.BIN_NORMAL[1][1] = bin_width #y轴方向的BIN_HEIGHT #TODO:优化 重力方向为x轴负方向,所以要确定一个BIN_HEIGHT,使得打包后更像正方形 77 | settings.BIN_NORMAL[2][1] = bin_width #TODO:优化 确定系数,我随便设置的0.8 78 | 79 | settings.BIN_NORMAL[2][0] = int(sqrt_lenth*settings.SQRT_LENTH_SCALE2) #x轴方向的BIN_WIDTH 乘以2是为了保证所有的块都打包 80 | settings.BIN_NORMAL[3][0] = int(sqrt_lenth*settings.SQRT_LENTH_SCALE2) 81 | 82 | print(settings.BIN_NORMAL) 83 | # 选择面布 84 | n.add_container(settings.BIN_NORMAL) 85 | 86 | # 运行计算 87 | n.run() 88 | 89 | best = n.best 90 | 91 | # 循环特定次数 92 | content_loop_rate(best, n,file_path=file_path,file_id=file_id, loop_time=settings.STOP_GENERATION,height=settings.BIN_NORMAL[1][1]) # T7 , T4 93 | 94 | stopAllWorkers() 95 | 96 | if settings.DEBUG: 97 | end_time = time.time() 98 | print("run time:",end_time-start_time) 99 | 100 | def batchMpiEval(nWorker,pop): 101 | """批量评估个体 102 | 103 | Args: 104 | nWorker (int): 工人数量 105 | pop (type):种群 106 | 107 | Returns: 108 | [int]: fitness 109 | """ 110 | 111 | nSlave = nWorker-1 112 | nJobs = len(pop) 113 | nBatch= math.ceil(nJobs/nSlave) #将pop分成多少批 114 | 115 | reward =[] 116 | i = 0 117 | for iBatch in range(nBatch): #对于每一批 118 | for iWork in range(nSlave): #对于每一个slave 119 | if i < nJobs: 120 | signal_type = i #个体的编号 121 | message = pop[i] #个体 122 | comm.send(signal_type, dest=(iWork)+1, tag=1) #发送个体编号 123 | comm.send( message, dest=(iWork)+1, tag=2) #发送个体 124 | else: 125 | signal_type = -1 126 | comm.send(signal_type, dest=(iWork)+1) #发送中止信号 127 | i = i+1 128 | i -= nSlave 129 | for iWork in range(1,nSlave+1): 130 | if i < nJobs: 131 | workResult =comm.recv(source=iWork,tag=0) #TODO:complete 接收不到数据 132 | reward.append(workResult) 133 | i+=1 134 | return reward 135 | 136 | def batchNFPCalculate(nWorker,nfp_pairs): 137 | """批量计算NFP 138 | 139 | Args: 140 | nWorker (int): 工人数量 141 | nfp_pairs (dict): 待计算nfp对 142 | 143 | Returns: 144 | list: NFP结果 145 | """ 146 | nSlave = nWorker-1 147 | nJobs = len(nfp_pairs) 148 | nBatch= math.ceil(nJobs/nSlave) 149 | 150 | pair_list =[] 151 | i = 0 152 | for iBatch in range(nBatch): # 对于每一批 153 | for iWork in range(nSlave): # 对于每一个slave 154 | if i < nJobs: 155 | signal_type = -3 #信号类型 156 | message = nfp_pairs[i] #待计算量 157 | comm.send(signal_type, dest=(iWork)+1, tag=1) #发送信号类型 158 | comm.send( message, dest=(iWork)+1, tag=2) #发送待计算量 159 | #后续还要用worker,不终止 160 | i = i+1 161 | i -= nSlave 162 | for iWork in range(1,nSlave+1): 163 | if i < nJobs: 164 | workResult =comm.recv(source=iWork,tag=0) #TODO:complete 接收不到数据 165 | pair_list.append(workResult) 166 | i+=1 167 | return pair_list 168 | 169 | def batchSendContainerAndNFPCache(nWorker,origin_container,nfp_cache): 170 | """批量发送容器和NFP缓存 171 | 172 | Args: 173 | nWorker (int): 工人数目 174 | origin_container (dict): 初始容器 175 | nfp_cache (dict): nfp缓存 176 | """ 177 | nSlave = nWorker-1 178 | nJobs = nSlave 179 | nBatch= math.ceil(nJobs/nSlave) 180 | 181 | pair_list =[] 182 | i = 0 183 | for iBatch in range(nBatch): 184 | for iWork in range(nSlave): 185 | if i < nJobs: 186 | signal_type = -4 #信号类型 187 | message1 = origin_container 188 | message2 = nfp_cache 189 | comm.send(signal_type, dest=(iWork)+1, tag=1) #发送信号类型 190 | comm.send( message1, dest=(iWork)+1, tag=2) #发送待计算量 191 | comm.send( message2, dest=(iWork)+1, tag=3) #发送待计算量 192 | #后续还要用worker,不终止 193 | i = i+1 194 | 195 | def slave(): 196 | origin_container=None 197 | nfp_cache=None 198 | while True: 199 | signal_type = comm.recv(source=0, 200 | tag=1) #接收个体编号 201 | if signal_type >= 0: #不是中止信号 202 | message =comm.recv(source=0, tag=2) # 接收个体 203 | result = find_fitness(message,origin_container,nfp_cache) 204 | #print("rank:",rank,len(nfp_cache)) 205 | comm.send(result, dest=0,tag=0) # send it back 发送fitness结果 TODO:检查 个体的fitness和个体是不是一一对应 206 | elif signal_type==-3:#计算NFP 207 | pair =comm.recv(source=0, tag=2) 208 | result=NFP_Calculater.process_nfp(pair) 209 | comm.send(result, dest=0,tag=0) 210 | 211 | elif signal_type==-4: 212 | origin_container=comm.recv(source=0, tag=2) 213 | nfp_cache=comm.recv(source=0,tag=3) 214 | if signal_type ==-1: # End signal recieved 215 | # if settings.DEBUG: 216 | # print('Worker # ', rank, ' shutting down.') 217 | break 218 | 219 | def stopAllWorkers(): 220 | """给所有工人发送停止信号 221 | """ 222 | global nWorker 223 | nSlave = nWorker - 1 224 | #print('stopping workers') 225 | for iWork in range(nSlave): 226 | comm.send(-1, dest=(iWork) + 1, tag=1) 227 | 228 | def mpi_fork(n): 229 | """重启进程 230 | 231 | Args: 232 | n (int): 核数 233 | 234 | Returns: 235 | str: 主为parent,子为children 236 | """ 237 | if n <= 1: #如果只有一个核,就直接跑任务 238 | return "child" 239 | if os.getenv("IN_MPI") is None: #如果不止一个核,主进程启动mpi去并发执行,mpi中的儿子跑完后再回到这里 240 | env = os.environ.copy() 241 | env.update(MKL_NUM_THREADS="1", OMP_NUM_THREADS="1", IN_MPI="1") #MKL intel数学核心库MKL_NUM_THREADS,MKL_NUM_THREADS OpenMP是用于共享内存并行系统的预编译处理方案,OMP_NUM_THREADS是控制OpenMP并行线程数的标准环境变量 242 | # if settings.DEBUG: 243 | # print("执行:", 244 | # ["mpiexec", "-np", str(n), sys.executable] + sys.argv 245 | # ) #['mpiexec', '-np', '9', 'C:\\Users\\Lution\\AppData\\Local\\Programs\\Python\\Python37\\python.exe', 'wann_train.py'] sys.executable Python解释程序路径 sys.argv 命令行参数List,第一个元素是程序本身路径 246 | if settings.LINUXOS: 247 | mpicmd="mpirun" 248 | shellcmd=False 249 | else: 250 | mpicmd="mpiexec" 251 | shellcmd=True 252 | subprocess.check_call( 253 | [mpicmd, "-np", str(n), sys.executable] + ['-u'] + sys.argv, 254 | env=env, 255 | shell=shellcmd 256 | ) #shell=True 解决FileNotFoundError: [WinError 2] 系统找不到指定的文件。 257 | #主程序跑到上面这里,用mpi启动了好几个儿子去跑本程序,儿子看到父亲已经设好了环境变量IN_MPI标志,就都去跑下面的else,儿子全部跑完后才会执行下面的return "parent",至此也就结束了 258 | return "parent" 259 | else: #儿子们跑任务 260 | global nWorker, rank 261 | nWorker = comm.Get_size() 262 | rank = comm.Get_rank() 263 | #print(nWorker,rank) 264 | return "child" 265 | 266 | def main(argv): 267 | """根据mpi rank执行对应的函数 268 | 269 | Args: 270 | argv (dict): 输入参数 271 | """ 272 | if (rank == 0): 273 | master(argv.data) 274 | else: 275 | slave() 276 | 277 | def run(): 278 | """解析输入参数并启动 279 | """ 280 | parser = argparse.ArgumentParser(description=('Evolve')) 281 | 282 | parser.add_argument('-d', '--data', type=str,\ 283 | help='data file', default='data/polygon_area_etc_input_0.txt') #polygon_area_etc_input 284 | 285 | parser.add_argument('-n', '--num_worker', type=int,\ 286 | help='number of cores to use', default=settings.NWORKER) 287 | 288 | args = parser.parse_args() 289 | 290 | if "parent" == mpi_fork(args.num_worker+1): os._exit(0) 291 | 292 | main(args) 293 | 294 | if __name__ == "__main__": 295 | run() 296 | 297 | -------------------------------------------------------------------------------- /tools/placement_worker.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | ''' 3 | @File : placement_worker.py 4 | @Time : 2020/11/19 19:17:57 5 | @Author : KingofCode 6 | @Version : 1.0 7 | @Contact : mrlution@qq.com 8 | @Desc : 放置过程 9 | ''' 10 | 11 | # here put the import lib 12 | import json 13 | from .nfp_utls import almost_equal, rotate_polygon, get_polygon_bounds, polygon_area 14 | import copy 15 | import pyclipper 16 | 17 | FITNESSSCALE=10 18 | 19 | 20 | class PlacementWorker(): 21 | """放置图形并得到结果 22 | """ 23 | def __init__(self, bin_polygon, paths, ids, rotations, config, nfp_cache): 24 | self.bin_polygon = bin_polygon 25 | self.paths = copy.deepcopy(paths) 26 | self.ids = ids # 图形原来的ID顺序 27 | self.rotations = rotations 28 | self.config = config 29 | self.nfpCache = nfp_cache or {} 30 | 31 | 32 | def place_paths(self): 33 | # 排列图形 34 | if self.bin_polygon is None: 35 | return None 36 | 37 | # rotate paths by given rotation 38 | rotated = list() 39 | for i in range(0, len(self.paths)): 40 | r = rotate_polygon(self.paths[i][1]['points'], self.paths[i][2]) 41 | r['rotation'] = self.paths[i][2] 42 | r['source'] = self.paths[i][1]['p_id'] 43 | r['p_id'] = self.paths[i][0] 44 | rotated.append(r) 45 | 46 | paths = rotated 47 | # 保存所有布局后的布局数据 48 | all_placements = list() 49 | # 基因组的适应值 50 | fitness = 0 51 | bin_area = abs(polygon_area(self.bin_polygon['points'])) 52 | min_width = None 53 | while len(paths) > 0:#当还有形状没安排上 54 | placed = list() 55 | placements = list() 56 | # add 1 for each new bin opened (lower fitness is better) 57 | fitness += 1 58 | for i in range(0, len(paths)):#对于每个剩余形状 59 | path = paths[i] #当前剩余图形 60 | # 图形的坐标 61 | key = json.dumps({ 62 | 'A': '-1', 63 | 'B': path['p_id'],#当前剩余图形的id 64 | 'inside': True, 65 | 'A_rotation': 0, 66 | 'B_rotation': path['rotation'] 67 | }) 68 | 69 | binNfp = self.nfpCache.get(key) #{"pair['key']":nfp}#取出当前图形和容器的内切多边形列表 70 | if binNfp is None or len(binNfp) == 0: 71 | print("error:binNfp缺失:"+key) 72 | continue #没有就忽略当前图形不放了 73 | 74 | # 无法放下,跳过 75 | error = False 76 | 77 | # 确保所有必要的 NFPs 存在 78 | for p in placed:#对于每个已经放下的图形 79 | key = json.dumps({ 80 | 'A': p['p_id'], 81 | 'B': path['p_id'], 82 | 'inside': False, 83 | 'A_rotation': p['rotation'], 84 | 'B_rotation': path['rotation'] 85 | }) 86 | nfp = self.nfpCache.get(key) #每个已经放下的图形和当前图形的外切多边形列表 87 | if nfp is None: 88 | error = True 89 | print("error:图形之间的nfp缺失:"+key) 90 | break #没有就结束,没法搞 91 | 92 | # 无法放下,跳过 93 | if error: 94 | print("error:无法放下") 95 | continue 96 | 97 | position = None 98 | if len(placed) == 0: #如果一个图形都还没放进去 99 | for j in range(0, len(binNfp)):#对于每个当前图形和容器外接多边形 100 | for k in range(0, len(binNfp[j])):#对于每个nfp的坐标 101 | if position is None or (binNfp[j][k]['x']-path['points'][0]['x'] < position['x']): 102 | position = { 103 | 'x': binNfp[j][k]['x'] - path['points'][0]['x'], #NFP中最小x与图形参考点x的距离,将图形平移到那一点要将每个x减去这个距离 104 | 'y': binNfp[j][k]['y'] - path['points'][0]['y'], #y要减去这个距离 105 | 'p_id': path['p_id'], 106 | 'rotation': path['rotation'] 107 | } 108 | 109 | placements.append(position) #存储着第一个图像应该做什么移动到目标布局 110 | placed.append(path) #第一个图像摆完 111 | continue #结束这个循环,放置下一个图形 112 | 113 | clipper_bin_nfp = list() 114 | for j in range(0, len(binNfp)): #对于每一个与Bin的NFP 115 | clipper_bin_nfp.append([[p['x'], p['y']] for p in binNfp[j]])#将NFP的每个坐标都压入clipper_bin_nfp 116 | 117 | clipper = pyclipper.Pyclipper() 118 | 119 | for j in range(0, len(placed)):#对于每一个放好的图形 120 | p = placed[j] 121 | key = json.dumps({ 122 | 'A': p['p_id'], 123 | 'B': path['p_id'], 124 | 'inside': False, 125 | 'A_rotation': p['rotation'], 126 | 'B_rotation': path['rotation'] 127 | }) 128 | nfp = self.nfpCache.get(key) #得到当前要摆放的图形和观察放好的图形之间的nfp 129 | 130 | if nfp is None: 131 | print("error:nfp缺失:"+key) 132 | continue 133 | for k in range(0, len(nfp)):#对于每一个nfp 134 | clone = [[np['x'] + placements[j]['x'], np['y'] + placements[j]['y']] for np in nfp[k]] #每个nfp移动到已放好块的周围 135 | clone = pyclipper.CleanPolygon(clone)#移除以下类型的点集 距离过近的相邻点 等等 136 | if len(clone) > 2: 137 | clipper.AddPath(clone, pyclipper.PT_SUBJECT, True)#NFP交给clipper 138 | #所有放置好的图形的NFP并集 139 | combine_nfp = clipper.Execute(pyclipper.CT_UNION, pyclipper.PFT_NONZERO, pyclipper.PFT_NONZERO) 140 | if len(combine_nfp) == 0: 141 | print("error:nfp错误:nfp并集长度为0") 142 | continue 143 | 144 | clipper = pyclipper.Pyclipper() 145 | clipper.AddPaths(combine_nfp, pyclipper.PT_CLIP, True)#将合并好的NFP交给clipper 146 | try: 147 | clipper.AddPaths(clipper_bin_nfp, pyclipper.PT_SUBJECT, True)#将要放置的图形与盒子的NFP交给clipper 148 | except: 149 | print( u'图形坐标出错', clipper_bin_nfp) 150 | 151 | # choose placement that results in the smallest bounding box 152 | #与盒子NFP(可行)-放好图形的NFP(不可行) 153 | finalNfp = clipper.Execute(pyclipper.CT_DIFFERENCE, pyclipper.PFT_NONZERO, pyclipper.PFT_NONZERO) 154 | if len(finalNfp) == 0: 155 | continue 156 | finalNfp = pyclipper.CleanPolygons(finalNfp) 157 | 158 | for j in range(len(finalNfp)-1, -1, -1): 159 | if len(finalNfp[j]) < 3: 160 | finalNfp.pop(j) 161 | if len(finalNfp) == 0: 162 | continue 163 | 164 | finalNfp = [[{'x': p[0], 'y': p[1]}for p in polygon] for polygon in finalNfp]#将所有finalNFP的点取出 165 | 166 | min_width = None 167 | min_area = None 168 | min_x = None 169 | 170 | for nf in finalNfp:#对于每个NFP 171 | 172 | if abs(polygon_area(nf)) < 2: 173 | continue 174 | 175 | for p_nf in nf:#对于每个NFP的点 176 | # 生成nfp多边形 177 | all_points = list() 178 | for m in range(0, len(placed)):#对于每个已放置图形 179 | for p in placed[m]['points']:#对于每个点 180 | all_points.append({ 181 | 'x': p['x']+placements[m]['x'],#每个点都移动到布局 182 | 'y': p['y']+placements[m]['y'] 183 | }) 184 | # path 坐标 185 | shift_vector = { 186 | 'x': p_nf['x'] - path['points'][0]['x'], 187 | 'y': p_nf['y'] - path['points'][0]['y'], 188 | 'p_id': path['p_id'], 189 | 'rotation': path['rotation'], 190 | } 191 | 192 | # 找新坐标后的最小矩形 193 | for m in range(0, len(path['points'])): 194 | all_points.append({ 195 | 'x': path['points'][m]['x'] + shift_vector['x'], 196 | 'y': path['points'][m]['y'] + shift_vector['y'] 197 | }) 198 | 199 | rect_bounds = get_polygon_bounds(all_points) 200 | # weigh width more, to help compress in direction of gravity 201 | area = rect_bounds['width'] * 2 + rect_bounds['height'] 202 | 203 | if (min_area is None or area < min_area or almost_equal(min_area, area)) and ( 204 | min_x is None or shift_vector['x'] <= min_x): 205 | min_area = area 206 | min_width = rect_bounds['width'] 207 | position = shift_vector 208 | min_x = shift_vector['x'] 209 | 210 | if position: 211 | placed.append(path) 212 | placements.append(position) 213 | 214 | if min_width: 215 | fitness += FITNESSSCALE*min_width / bin_area 216 | 217 | for p in placed:#将安排上的形状从剩余形状中剔除 218 | p_id = paths.index(p) 219 | if p_id >= 0: 220 | paths.pop(p_id) 221 | 222 | if placements and len(placements) > 0: 223 | all_placements.append(placements) 224 | 225 | else: 226 | # something wrong 227 | break 228 | 229 | fitness += 2 * len(paths) 230 | 231 | 232 | return {'placements': all_placements, 'fitness': fitness,'min_width':min_width, 'paths': paths, 'area': bin_area} 233 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_6.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (320,504)(320,485)(321,485)(321,499)(330,499)(330,504) 3 | Polygon: 4 | (56,425)(40,425)(40,439)(56,439) 5 | Polygon: 6 | (360,226)(370,226)(370,215)(360,215) 7 | Polygon: 8 | (360,520)(360,515)(379,515)(379,535)(374,535)(374,520) 9 | Polygon: 10 | (400,365)(400,377)(412,377)(412,365) 11 | Polygon: 12 | (400,191)(400,185)(429,185)(429,205)(419,205)(419,191) 13 | Polygon: 14 | (40,263)(40,245)(41,245)(41,259)(51,259)(51,263) 15 | Polygon: 16 | (298,335)(298,352)(280,352)(280,335) 17 | Polygon: 18 | (120,223)(120,215)(129,215)(129,223) 19 | Polygon: 20 | (12,533)(20,533)(20,515)(0,515)(0,521)(12,521) 21 | Polygon: 22 | (371,395)(360,395)(360,413)(371,413) 23 | Polygon: 24 | (400,293)(400,295)(426,295)(426,275)(422,275)(422,293) 25 | Polygon: 26 | (320,365)(320,399)(326,399)(326,378)(340,378)(340,365) 27 | Polygon: 28 | (307,205)(280,205)(280,185)(307,185) 29 | Polygon: 30 | (409,455)(409,480)(400,480)(400,455) 31 | Polygon: 32 | (120,253)(120,245)(137,245)(137,284)(133,284)(133,253) 33 | Polygon: 34 | (0,387)(0,376)(3,376)(3,365)(9,365)(9,402)(3,402)(3,387) 35 | Polygon: 36 | (120,305)(120,322)(128,322)(128,305) 37 | Polygon: 38 | (40,185)(40,196)(47,196)(47,185) 39 | Polygon: 40 | (240,234)(254,234)(254,229)(243,229)(243,215)(240,215) 41 | Polygon: 42 | (200,395)(200,413)(219,413)(219,395) 43 | Polygon: 44 | (43,380)(48,380)(48,365)(43,365)(43,370)(40,370)(40,372)(43,372) 45 | Polygon: 46 | (287,545)(280,545)(280,555)(287,555) 47 | Polygon: 48 | (7,215)(0,215)(0,217)(7,217) 49 | Polygon: 50 | (40,395)(51,395)(51,409)(40,409) 51 | Polygon: 52 | (297,425)(300,425)(300,449)(280,449)(280,443)(297,443) 53 | Polygon: 54 | (16,567)(16,545)(12,545)(12,561)(0,561)(0,567) 55 | Polygon: 56 | (502,439)(480,439)(480,425)(502,425) 57 | Polygon: 58 | (66,485)(40,485)(40,490)(58,490)(58,504)(66,504) 59 | Polygon: 60 | (120,335)(120,355)(140,355)(140,335) 61 | Polygon: 62 | (280,524)(289,524)(289,515)(280,515) 63 | Polygon: 64 | (301,405)(301,395)(280,395)(280,422)(287,422)(287,405) 65 | Polygon: 66 | (160,305)(181,305)(181,309)(166,309)(166,321)(160,321) 67 | Polygon: 68 | (400,305)(400,321)(415,321)(415,305) 69 | Polygon: 70 | (160,365)(160,385)(162,385)(162,370)(174,370)(174,365) 71 | Polygon: 72 | (0,472)(0,455)(13,455)(13,472) 73 | Polygon: 74 | (328,305)(328,317)(320,317)(320,305) 75 | Polygon: 76 | (453,470)(461,470)(461,455)(440,455)(440,462)(453,462) 77 | Polygon: 78 | (127,527)(127,522)(125,522)(125,515)(120,515)(120,537)(125,537)(125,527) 79 | Polygon: 80 | (167,515)(167,527)(160,527)(160,515) 81 | Polygon: 82 | (246,335)(246,341)(240,341)(240,335) 83 | Polygon: 84 | (447,305)(447,315)(440,315)(440,305) 85 | Polygon: 86 | (455,350)(463,350)(463,335)(440,335)(440,341)(455,341) 87 | Polygon: 88 | (120,411)(120,395)(122,395)(122,408)(134,408)(134,411) 89 | Polygon: 90 | (240,185)(261,185)(261,198)(240,198) 91 | Polygon: 92 | (327,438)(327,425)(320,425)(320,438) 93 | Polygon: 94 | (480,193)(480,185)(494,185)(494,209)(489,209)(489,193) 95 | Polygon: 96 | (200,466)(213,466)(213,465)(202,465)(202,455)(200,455) 97 | Polygon: 98 | (480,485)(499,485)(499,499)(480,499) 99 | Polygon: 100 | (368,260)(360,260)(360,245)(368,245)(368,250)(375,250)(375,252)(368,252) 101 | Polygon: 102 | (80,215)(80,221)(92,221)(92,215) 103 | Polygon: 104 | (40,215)(40,221)(43,221)(43,215) 105 | Polygon: 106 | (86,275)(95,275)(95,291)(86,291)(86,286)(80,286)(80,284)(86,284) 107 | Polygon: 108 | (320,185)(328,185)(328,196)(320,196) 109 | Polygon: 110 | (0,185)(0,193)(3,193)(3,185) 111 | Polygon: 112 | (90,362)(80,362)(80,335)(90,335)(90,343)(97,343)(97,350)(90,350) 113 | Polygon: 114 | (331,341)(331,335)(320,335)(320,341) 115 | Polygon: 116 | (160,191)(160,185)(168,185)(168,191) 117 | Polygon: 118 | (211,275)(206,275)(206,285)(200,285)(200,295)(220,295)(220,283)(211,283) 119 | Polygon: 120 | (212,254)(200,254)(200,245)(212,245) 121 | Polygon: 122 | (490,309)(490,305)(480,305)(480,309) 123 | Polygon: 124 | (105,365)(105,387)(97,387)(97,372)(80,372)(80,365) 125 | Polygon: 126 | (320,395)(336,395)(336,416)(320,416) 127 | Polygon: 128 | (240,515)(253,515)(253,531)(240,531) 129 | Polygon: 130 | (16,363)(20,363)(20,335)(0,335)(0,344)(16,344) 131 | Polygon: 132 | (440,433)(455,433)(455,425)(440,425) 133 | Polygon: 134 | (320,254)(320,245)(335,245)(335,269)(328,269)(328,254) 135 | Polygon: 136 | (170,455)(160,455)(160,464)(170,464) 137 | Polygon: 138 | (169,441)(160,441)(160,425)(184,425)(184,429)(169,429) 139 | Polygon: 140 | (170,215)(170,225)(160,225)(160,215) 141 | Polygon: 142 | (377,431)(377,425)(360,425)(360,445)(362,445)(362,431) 143 | Polygon: 144 | (120,556)(133,556)(133,555)(122,555)(122,545)(120,545) 145 | Polygon: 146 | (379,379)(360,379)(360,365)(379,365) 147 | Polygon: 148 | (280,379)(280,365)(283,365)(283,376)(295,376)(295,379) 149 | Polygon: 150 | (480,232)(480,215)(494,215)(494,232) 151 | Polygon: 152 | (440,493)(440,485)(447,485)(447,493) 153 | Polygon: 154 | (124,425)(120,425)(120,440)(139,440)(139,434)(124,434) 155 | Polygon: 156 | (474,245)(440,245)(440,247)(463,247)(463,259)(474,259) 157 | Polygon: 158 | (296,275)(296,301)(280,301)(280,275) 159 | Polygon: 160 | (0,440)(0,425)(8,425)(8,440) 161 | Polygon: 162 | (258,449)(258,461)(240,461)(240,425)(242,425)(242,449) 163 | Polygon: 164 | (400,215)(435,215)(435,216)(414,216)(414,225)(400,225) 165 | Polygon: 166 | (240,320)(263,320)(263,305)(240,305) 167 | Polygon: 168 | (240,245)(261,245)(261,250)(246,250)(246,264)(240,264) 169 | Polygon: 170 | (200,365)(200,388)(219,388)(219,365) 171 | Polygon: 172 | (400,515)(400,540)(407,540)(407,524)(424,524)(424,515) 173 | Polygon: 174 | (20,245)(0,245)(0,267)(20,267) 175 | Polygon: 176 | (88,545)(80,545)(80,552)(88,552) 177 | Polygon: 178 | (494,287)(494,295)(480,295)(480,275)(487,275)(487,287) 179 | Polygon: 180 | (89,185)(86,185)(86,189)(80,189)(80,194)(98,194)(98,189)(89,189) 181 | Polygon: 182 | (324,515)(324,528)(320,528)(320,515) 183 | Polygon: 184 | (120,189)(120,185)(123,185)(123,189) 185 | Polygon: 186 | (303,503)(303,485)(296,485)(296,498)(280,498)(280,503) 187 | Polygon: 188 | (136,504)(120,504)(120,485)(136,485) 189 | Polygon: 190 | (485,478)(498,478)(498,455)(485,455)(485,462)(480,462)(480,467)(485,467) 191 | Polygon: 192 | (80,527)(85,527)(85,515)(80,515) 193 | Polygon: 194 | (160,335)(160,340)(165,340)(165,335) 195 | Polygon: 196 | (0,308)(0,315)(14,315)(14,308)(9,308)(9,305)(8,305)(8,308) 197 | Polygon: 198 | (367,185)(360,185)(360,195)(367,195) 199 | Polygon: 200 | (360,342)(360,335)(362,335)(362,342) 201 | Polygon: 202 | (360,305)(379,305)(379,308)(365,308)(365,321)(360,321) 203 | Polygon: 204 | (160,485)(160,501)(176,501)(176,485) 205 | Polygon: 206 | (80,315)(80,311)(81,311)(81,305)(84,305)(84,324)(81,324)(81,315) 207 | Polygon: 208 | (120,282)(136,282)(136,275)(120,275) 209 | Polygon: 210 | (366,459)(366,455)(360,455)(360,459) 211 | Polygon: 212 | (51,455)(56,455)(56,459)(63,459)(63,470)(40,470)(40,459)(51,459) 213 | Polygon: 214 | (93,485)(80,485)(80,489)(93,489) 215 | Polygon: 216 | (480,245)(480,251)(483,251)(483,245) 217 | Polygon: 218 | (440,215)(440,223)(449,223)(449,215) 219 | Polygon: 220 | (440,403)(440,395)(456,395)(456,419)(449,419)(449,403) 221 | Polygon: 222 | (200,425)(200,458)(202,458)(202,439)(214,439)(214,425) 223 | Polygon: 224 | (160,410)(184,410)(184,395)(160,395) 225 | Polygon: 226 | (14,308)(14,275)(11,275)(11,295)(0,295)(0,308) 227 | Polygon: 228 | (120,455)(120,480)(133,480)(133,455) 229 | Polygon: 230 | (172,545)(160,545)(160,553)(172,553) 231 | Polygon: 232 | (80,469)(80,455)(95,455)(95,493)(90,493)(90,469) 233 | Polygon: 234 | (413,253)(400,253)(400,245)(413,245) 235 | Polygon: 236 | (172,290)(160,290)(160,275)(195,275)(195,282)(172,282) 237 | Polygon: 238 | (63,519)(63,525)(40,525)(40,519)(47,519)(47,515)(53,515)(53,519) 239 | Polygon: 240 | (327,289)(320,289)(320,275)(327,275) 241 | Polygon: 242 | (400,395)(407,395)(407,401)(400,401) 243 | Polygon: 244 | (451,284)(440,284)(440,275)(451,275) 245 | Polygon: 246 | (338,232)(340,232)(340,215)(320,215)(320,220)(338,220) 247 | Polygon: 248 | (80,399)(80,409)(95,409)(95,399)(90,399)(90,395)(87,395)(87,399) 249 | Polygon: 250 | (11,395)(11,404)(0,404)(0,395) 251 | Polygon: 252 | (49,277)(40,277)(40,275)(49,275) 253 | Polygon: 254 | (132,386)(137,386)(137,377)(143,377)(143,365)(120,365)(120,377)(132,377) 255 | Polygon: 256 | (372,286)(360,286)(360,275)(372,275) 257 | Polygon: 258 | (200,515)(205,515)(205,525)(200,525) 259 | Polygon: 260 | (280,245)(288,245)(288,253)(280,253) 261 | Polygon: 262 | (44,305)(40,305)(40,322)(60,322)(60,313)(44,313) 263 | Polygon: 264 | (215,335)(200,335)(200,336)(212,336)(212,345)(215,345) 265 | Polygon: 266 | (17,505)(17,485)(0,485)(0,505) 267 | Polygon: 268 | (40,545)(40,556)(49,556)(49,545) 269 | Polygon: 270 | (377,493)(377,485)(360,485)(360,506)(367,506)(367,493) 271 | Polygon: 272 | (400,485)(400,499)(409,499)(409,485) 273 | Polygon: 274 | (204,215)(200,215)(200,232)(221,232)(221,229)(204,229) 275 | Polygon: 276 | (240,545)(240,565)(242,565)(242,550)(252,550)(252,545) 277 | Polygon: 278 | (337,477)(337,455)(320,455)(320,477) 279 | Polygon: 280 | (200,485)(200,499)(210,499)(210,485) 281 | Polygon: 282 | (206,204)(200,204)(200,185)(226,185)(226,192)(206,192) 283 | Polygon: 284 | (440,196)(440,202)(440,202)(440,209)(446,209)(446,185)(440,185)(440,196) 285 | Polygon: 286 | (80,245)(80,259)(86,259)(86,245) 287 | Polygon: 288 | (485,335)(485,341)(480,341)(480,335) 289 | Polygon: 290 | (265,275)(240,275)(240,281)(256,281)(256,295)(265,295) 291 | Polygon: 292 | (480,533)(480,515)(502,515)(502,533) 293 | Polygon: 294 | (420,344)(420,335)(400,335)(400,344)(406,344)(406,351)(410,351)(410,344) 295 | Polygon: 296 | (200,551)(200,545)(211,545)(211,551) 297 | Polygon: 298 | (280,221)(280,215)(283,215)(283,221) 299 | Polygon: 300 | (218,305)(200,305)(200,307)(213,307)(213,318)(218,318) 301 | Polygon: 302 | (58,350)(58,335)(40,335)(40,350) 303 | Polygon: 304 | (240,365)(240,376)(248,376)(248,365) 305 | Polygon: 306 | (283,473)(280,473)(280,455)(300,455)(300,462)(283,462) 307 | Polygon: 308 | (480,369)(480,375)(497,375)(497,369)(492,369)(492,365)(489,365)(489,369) 309 | Polygon: 310 | (160,256)(168,256)(168,245)(160,245) 311 | Polygon: 312 | (288,308)(280,308)(280,305)(288,305) 313 | Polygon: 314 | (450,383)(440,383)(440,365)(450,365) 315 | Polygon: 316 | (265,403)(265,395)(240,395)(240,416)(246,416)(246,403) 317 | Polygon: 318 | (240,496)(240,500)(245,500)(245,506)(258,506)(258,485)(245,485)(245,496) 319 | Polygon: 320 | (400,437)(411,437)(411,425)(400,425) 321 | Polygon: 322 | (484,406)(480,406)(480,395)(484,395) 323 | Polygon: 324 | (453,529)(440,529)(440,527)(451,527)(451,515)(453,515) 325 | Polygon: 326 | (259,455)(240,455)(240,470)(259,470) 327 | Polygon: 328 | (80,435)(80,425)(89,425)(89,435) 329 | Polygon: 330 | (336,551)(336,545)(320,545)(320,565)(322,565)(322,551) 331 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_4.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (123,324)(123,315)(121,315)(121,322)(114,322)(114,324) 3 | Polygon: 4 | (171,125)(181,125)(181,134)(171,134) 5 | Polygon: 6 | (152,315)(160,315)(160,317)(153,317)(153,325)(152,325) 7 | Polygon: 8 | (181,296)(171,296)(171,305)(181,305) 9 | Polygon: 10 | (141,145)(141,148)(133,148)(133,145)(136,145)(136,144)(137,144)(137,145) 11 | Polygon: 12 | (99,258)(95,258)(95,265)(99,265) 13 | Polygon: 14 | (191,277)(191,281)(190,281)(190,277) 15 | Polygon: 16 | (76,324)(76,315)(84,315)(84,324) 17 | Polygon: 18 | (12,277)(16,277)(16,294)(0,294)(0,290)(12,290) 19 | Polygon: 20 | (220,163)(220,168)(209,168)(209,163) 21 | Polygon: 22 | (159,161)(152,161)(152,144)(169,144)(169,148)(159,148) 23 | Polygon: 24 | (38,334)(43,334)(43,340)(38,340) 25 | Polygon: 26 | (99,125)(95,125)(95,135)(105,135)(105,133)(99,133) 27 | Polygon: 28 | (95,361)(95,353)(105,353)(105,361)(101,361)(101,364)(100,364)(100,361) 29 | Polygon: 30 | (118,283)(114,283)(114,277)(118,277) 31 | Polygon: 32 | (171,317)(175,317)(175,315)(171,315) 33 | Polygon: 34 | (230,174)(233,174)(233,163)(230,163)(230,167)(228,167)(228,169)(230,169) 35 | Polygon: 36 | (57,301)(59,301)(59,296)(57,296) 37 | Polygon: 38 | (171,355)(171,353)(173,353)(173,355) 39 | Polygon: 40 | (28,315)(19,315)(19,316)(26,316)(26,322)(28,322) 41 | Polygon: 42 | (240,258)(228,258)(228,267)(240,267) 43 | Polygon: 44 | (158,283)(158,277)(152,277)(152,283) 45 | Polygon: 46 | (6,363)(0,363)(0,353)(13,353)(13,355)(6,355) 47 | Polygon: 48 | (66,182)(57,182)(57,185)(64,185)(64,194)(66,194) 49 | Polygon: 50 | (114,230)(126,230)(126,220)(114,220) 51 | Polygon: 52 | (57,129)(57,125)(69,125)(69,129)(65,129)(65,131)(63,131)(63,129) 53 | Polygon: 54 | (83,145)(83,144)(76,144)(76,145) 55 | Polygon: 56 | (174,182)(174,183)(171,183)(171,182) 57 | Polygon: 58 | (72,220)(72,229)(67,229)(67,222)(57,222)(57,220) 59 | Polygon: 60 | (205,266)(205,258)(190,258)(190,266) 61 | Polygon: 62 | (251,239)(250,239)(250,243)(247,243)(247,249)(256,249)(256,243)(251,243) 63 | Polygon: 64 | (76,353)(84,353)(84,357)(76,357) 65 | Polygon: 66 | (1,261)(0,261)(0,258)(1,258) 67 | Polygon: 68 | (18,224)(18,220)(0,220)(0,224)(5,224)(5,227)(10,227)(10,224) 69 | Polygon: 70 | (190,315)(192,315)(192,323)(190,323) 71 | Polygon: 72 | (40,296)(38,296)(38,302)(40,302) 73 | Polygon: 74 | (82,169)(82,170)(80,170)(80,173)(76,173)(76,163)(80,163)(80,169) 75 | Polygon: 76 | (0,125)(7,125)(7,131)(0,131) 77 | Polygon: 78 | (0,144)(1,144)(1,149)(0,149) 79 | Polygon: 80 | (76,341)(76,334)(82,334)(82,341) 81 | Polygon: 82 | (107,299)(107,296)(95,296)(95,307)(101,307)(101,299) 83 | Polygon: 84 | (107,277)(107,287)(104,287)(104,279)(95,279)(95,277) 85 | Polygon: 86 | (0,334)(11,334)(11,344)(0,344) 87 | Polygon: 88 | (219,301)(219,296)(209,296)(209,301)(212,301)(212,304)(214,304)(214,301) 89 | Polygon: 90 | (171,339)(176,339)(176,334)(171,334) 91 | Polygon: 92 | (195,145)(190,145)(190,144)(195,144) 93 | Polygon: 94 | (24,301)(19,301)(19,296)(24,296) 95 | Polygon: 96 | (162,334)(166,334)(166,344)(152,344)(152,341)(162,341) 97 | Polygon: 98 | (57,277)(65,277)(65,282)(57,282) 99 | Polygon: 100 | (247,324)(247,329)(258,329)(258,315)(256,315)(256,324) 101 | Polygon: 102 | (209,334)(209,339)(215,339)(215,334) 103 | Polygon: 104 | (38,130)(38,134)(49,134)(49,125)(46,125)(46,130) 105 | Polygon: 106 | (57,206)(57,201)(62,201)(62,206) 107 | Polygon: 108 | (231,334)(228,334)(228,345)(237,345)(237,339)(231,339) 109 | Polygon: 110 | (0,239)(0,248)(1,248)(1,240)(8,240)(8,239) 111 | Polygon: 112 | (199,172)(199,163)(190,163)(190,172) 113 | Polygon: 114 | (158,163)(152,163)(152,170)(158,170)(158,168)(159,168)(159,167)(158,167) 115 | Polygon: 116 | (209,246)(211,246)(211,239)(209,239) 117 | Polygon: 118 | (19,258)(24,258)(24,263)(19,263) 119 | Polygon: 120 | (190,130)(190,134)(200,134)(200,125)(195,125)(195,130) 121 | Polygon: 122 | (247,220)(256,220)(256,221)(248,221)(248,228)(247,228) 123 | Polygon: 124 | (143,163)(143,172)(133,172)(133,163) 125 | Polygon: 126 | (216,229)(216,220)(215,220)(215,228)(209,228)(209,229) 127 | Polygon: 128 | (171,239)(181,239)(181,250)(171,250) 129 | Polygon: 130 | (190,203)(190,201)(196,201)(196,203) 131 | Polygon: 132 | (114,182)(116,182)(116,184)(114,184) 133 | Polygon: 134 | (38,243)(38,244)(38,244)(38,247)(43,247)(43,239)(38,239)(38,243) 135 | Polygon: 136 | (254,337)(247,337)(247,334)(254,334) 137 | Polygon: 138 | (95,182)(96,182)(96,184)(95,184) 139 | Polygon: 140 | (42,150)(38,150)(38,144)(42,144) 141 | Polygon: 142 | (140,135)(142,135)(142,125)(133,125)(133,127)(140,127) 143 | Polygon: 144 | (114,211)(114,201)(116,201)(116,209)(123,209)(123,211) 145 | Polygon: 146 | (133,248)(133,239)(141,239)(141,248) 147 | Polygon: 148 | (122,150)(122,148)(120,148)(120,144)(114,144)(114,156)(120,156)(120,150) 149 | Polygon: 150 | (196,182)(190,182)(190,185)(196,185) 151 | Polygon: 152 | (97,165)(95,165)(95,163)(97,163) 153 | Polygon: 154 | (157,358)(152,358)(152,353)(157,353) 155 | Polygon: 156 | (193,248)(190,248)(190,239)(200,239)(200,241)(193,241) 157 | Polygon: 158 | (44,315)(38,315)(38,321)(44,321) 159 | Polygon: 160 | (139,353)(143,353)(143,364)(133,364)(133,359)(139,359) 161 | Polygon: 162 | (60,338)(60,339)(59,339)(59,342)(57,342)(57,334)(59,334)(59,338) 163 | Polygon: 164 | (65,357)(57,357)(57,353)(65,353) 165 | Polygon: 166 | (247,144)(247,145)(250,145)(250,144) 167 | Polygon: 168 | (76,189)(80,189)(80,182)(76,182) 169 | Polygon: 170 | (156,136)(152,136)(152,125)(161,125)(161,128)(156,128) 171 | Polygon: 172 | (233,239)(233,244)(228,244)(228,239) 173 | Polygon: 174 | (137,191)(133,191)(133,182)(142,182)(142,185)(137,185) 175 | Polygon: 176 | (209,191)(209,182)(211,182)(211,190)(219,190)(219,191) 177 | Polygon: 178 | (0,201)(0,210)(9,210)(9,201) 179 | Polygon: 180 | (76,201)(76,212)(78,212)(78,203)(86,203)(86,201) 181 | Polygon: 182 | (171,277)(171,287)(183,287)(183,277) 183 | Polygon: 184 | (106,149)(106,144)(95,144)(95,149) 185 | Polygon: 186 | (0,188)(0,182)(18,182)(18,193)(12,193)(12,188) 187 | Polygon: 188 | (247,277)(255,277)(255,280)(248,280)(248,288)(247,288) 189 | Polygon: 190 | (152,211)(152,201)(165,201)(165,211) 191 | Polygon: 192 | (133,315)(133,320)(140,320)(140,315) 193 | Polygon: 194 | (25,239)(29,239)(29,255)(19,255)(19,251)(25,251) 195 | Polygon: 196 | (133,205)(133,204)(136,204)(136,201)(142,201)(142,209)(136,209)(136,205) 197 | Polygon: 198 | (232,303)(232,296)(228,296)(228,303) 199 | Polygon: 200 | (57,144)(57,145)(60,145)(60,144) 201 | Polygon: 202 | (254,206)(254,201)(247,201)(247,206) 203 | Polygon: 204 | (211,269)(209,269)(209,258)(218,258)(218,261)(211,261) 205 | Polygon: 206 | (76,277)(76,283)(83,283)(83,277) 207 | Polygon: 208 | (190,303)(190,306)(201,306)(201,296)(199,296)(199,303) 209 | Polygon: 210 | (114,170)(120,170)(120,163)(114,163) 211 | Polygon: 212 | (6,174)(0,174)(0,163)(17,163)(17,167)(6,167) 213 | Polygon: 214 | (101,239)(104,239)(104,240)(108,240)(108,246)(95,246)(95,240)(101,240) 215 | Polygon: 216 | (66,258)(57,258)(57,263)(66,263) 217 | Polygon: 218 | (114,337)(114,334)(118,334)(118,337) 219 | Polygon: 220 | (88,243)(88,242)(85,242)(85,239)(76,239)(76,247)(85,247)(85,243) 221 | Polygon: 222 | (122,296)(114,296)(114,301)(122,301) 223 | Polygon: 224 | (152,296)(153,296)(153,300)(152,300) 225 | Polygon: 226 | (24,131)(19,131)(19,125)(24,125) 227 | Polygon: 228 | (261,127)(261,125)(247,125)(247,135)(251,135)(251,127) 229 | Polygon: 230 | (152,264)(152,267)(154,267)(154,272)(159,272)(159,258)(154,258)(154,264) 231 | Polygon: 232 | (235,353)(228,353)(228,359)(235,359) 233 | Polygon: 234 | (57,163)(61,163)(61,168)(57,168) 235 | Polygon: 236 | (19,334)(29,334)(29,336)(21,336)(21,345)(19,345) 237 | Polygon: 238 | (152,233)(165,233)(165,220)(152,220) 239 | Polygon: 240 | (52,224)(52,220)(38,220)(38,224)(43,224)(43,226)(46,226)(46,224) 241 | Polygon: 242 | (120,353)(120,356)(114,356)(114,353) 243 | Polygon: 244 | (99,223)(99,220)(95,220)(95,223) 245 | Polygon: 246 | (228,149)(228,147)(233,147)(233,144)(239,144)(239,155)(233,155)(233,149) 247 | Polygon: 248 | (0,322)(8,322)(8,315)(0,315) 249 | Polygon: 250 | (190,353)(190,354)(196,354)(196,353) 251 | Polygon: 252 | (247,296)(257,296)(257,300)(249,300)(249,310)(247,310) 253 | Polygon: 254 | (190,343)(190,334)(203,334)(203,343) 255 | Polygon: 256 | (232,225)(232,223)(231,223)(231,220)(228,220)(228,232)(231,232)(231,225) 257 | Polygon: 258 | (171,163)(178,163)(178,167)(171,167) 259 | Polygon: 260 | (78,128)(76,128)(76,125)(78,125) 261 | Polygon: 262 | (200,228)(190,228)(190,227)(198,227)(198,220)(200,220) 263 | Polygon: 264 | (143,277)(133,277)(133,287)(143,287) 265 | Polygon: 266 | (101,315)(103,315)(103,317)(106,317)(106,324)(95,324)(95,317)(101,317) 267 | Polygon: 268 | (228,317)(235,317)(235,315)(228,315) 269 | Polygon: 270 | (40,354)(38,354)(38,353)(40,353) 271 | Polygon: 272 | (228,187)(233,187)(233,182)(228,182) 273 | Polygon: 274 | (176,211)(181,211)(181,201)(171,201)(171,203)(176,203) 275 | Polygon: 276 | (38,277)(46,277)(46,278)(39,278)(39,284)(38,284) 277 | Polygon: 278 | (104,334)(104,344)(95,344)(95,334) 279 | Polygon: 280 | (27,144)(27,154)(26,154)(26,146)(19,146)(19,144) 281 | Polygon: 282 | (209,325)(218,325)(218,315)(209,315) 283 | Polygon: 284 | (180,144)(171,144)(171,146)(179,146)(179,154)(180,154) 285 | Polygon: 286 | (256,267)(256,258)(247,258)(247,267) 287 | Polygon: 288 | (161,239)(161,247)(160,247)(160,240)(152,240)(152,239) 289 | Polygon: 290 | (29,353)(29,365)(19,365)(19,353) 291 | Polygon: 292 | (139,302)(133,302)(133,296)(139,296) 293 | Polygon: 294 | (95,206)(95,201)(105,201)(105,212)(102,212)(102,206) 295 | Polygon: 296 | (214,285)(209,285)(209,277)(214,277) 297 | Polygon: 298 | (234,201)(228,201)(228,213)(239,213)(239,211)(234,211) 299 | Polygon: 300 | (255,170)(260,170)(260,168)(265,168)(265,163)(247,163)(247,168)(255,168) 301 | Polygon: 302 | (133,266)(133,258)(135,258)(135,266) 303 | Polygon: 304 | (20,282)(20,277)(19,277)(19,282) 305 | Polygon: 306 | (76,296)(76,314)(78,314)(78,303)(85,303)(85,296) 307 | Polygon: 308 | (50,201)(38,201)(38,213)(50,213) 309 | Polygon: 310 | (232,288)(238,288)(238,277)(232,277)(232,280)(228,280)(228,282)(232,282) 311 | Polygon: 312 | (117,130)(114,130)(114,125)(117,125) 313 | Polygon: 314 | (114,241)(117,241)(117,239)(114,239) 315 | Polygon: 316 | (217,136)(209,136)(209,125)(217,125)(217,129)(219,129)(219,131)(217,131) 317 | Polygon: 318 | (61,239)(57,239)(57,244)(61,244) 319 | Polygon: 320 | (173,258)(173,262)(171,262)(171,258) 321 | Polygon: 322 | (122,258)(118,258)(118,260)(114,260)(114,267)(128,267)(128,260)(122,260) 323 | Polygon: 324 | (133,229)(133,220)(135,220)(135,229) 325 | Polygon: 326 | (212,202)(209,202)(209,201)(212,201) 327 | Polygon: 328 | (247,190)(247,182)(257,182)(257,189)(253,189)(253,195)(252,195)(252,190) 329 | Polygon: 330 | (209,353)(214,353)(214,360)(209,360) 331 | Polygon: 332 | (6,298)(0,298)(0,296)(6,296) 333 | Polygon: 334 | (152,188)(152,192)(156,192)(156,196)(164,196)(164,182)(156,182)(156,188) 335 | Polygon: 336 | (38,258)(38,267)(42,267)(42,258) 337 | Polygon: 338 | (38,182)(38,185)(41,185)(41,182) 339 | Polygon: 340 | (29,189)(29,192)(26,192)(26,196)(19,196)(19,182)(26,182)(26,189) 341 | Polygon: 342 | (19,201)(19,208)(24,208)(24,201) 343 | Polygon: 344 | (137,334)(137,337)(133,337)(133,334) 345 | Polygon: 346 | (76,263)(81,263)(81,258)(76,258) 347 | Polygon: 348 | (215,153)(219,153)(219,144)(209,144)(209,146)(215,146) 349 | Polygon: 350 | (38,168)(38,163)(47,163)(47,168) 351 | Polygon: 352 | (63,315)(67,315)(67,331)(57,331)(57,328)(63,328) 353 | Polygon: 354 | (19,163)(28,163)(28,165)(20,165)(20,173)(19,173) 355 | Polygon: 356 | (86,220)(76,220)(76,231)(86,231) 357 | Polygon: 358 | (28,220)(19,220)(19,221)(27,221)(27,227)(28,227) 359 | Polygon: 360 | (180,230)(180,220)(171,220)(171,230) 361 | Polygon: 362 | (233,125)(233,130)(228,130)(228,125) 363 | Polygon: 364 | (254,362)(257,362)(257,353)(247,353)(247,356)(254,356) 365 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_12.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (80,312)(80,307)(72,307)(72,312) 3 | Polygon: 4 | (9,402)(13,402)(13,414)(0,414)(0,411)(9,411) 5 | Polygon: 6 | (126,307)(134,307)(134,314)(126,314) 7 | Polygon: 8 | (16,312)(16,307)(0,307)(0,320)(6,320)(6,312) 9 | Polygon: 10 | (162,193)(162,204)(164,204)(164,196)(171,196)(171,193) 11 | Polygon: 12 | (162,459)(162,470)(172,470)(172,459) 13 | Polygon: 14 | (90,196)(90,200)(99,200)(99,196)(95,196)(95,193)(94,193)(94,196) 15 | Polygon: 16 | (270,390)(274,390)(274,383)(270,383) 17 | Polygon: 18 | (54,271)(58,271)(58,269)(54,269) 19 | Polygon: 20 | (144,421)(152,421)(152,428)(144,428) 21 | Polygon: 22 | (224,224)(229,224)(229,212)(216,212)(216,215)(224,215) 23 | Polygon: 24 | (236,288)(242,288)(242,298)(236,298)(236,294)(234,294)(234,293)(236,293) 25 | Polygon: 26 | (206,231)(206,236)(198,236)(198,231) 27 | Polygon: 28 | (236,364)(236,369)(234,369)(234,364) 29 | Polygon: 30 | (101,391)(101,383)(90,383)(90,391) 31 | Polygon: 32 | (63,436)(67,436)(67,421)(54,421)(54,425)(63,425) 33 | Polygon: 34 | (222,231)(222,240)(216,240)(216,231) 35 | Polygon: 36 | (261,337)(265,337)(265,326)(252,326)(252,331)(261,331) 37 | Polygon: 38 | (258,391)(258,383)(252,383)(252,391) 39 | Polygon: 40 | (144,216)(144,212)(158,212)(158,225)(152,225)(152,216) 41 | Polygon: 42 | (72,421)(79,421)(79,427)(72,427) 43 | Polygon: 44 | (154,181)(154,187)(144,187)(144,174)(147,174)(147,181) 45 | Polygon: 46 | (115,259)(115,250)(108,250)(108,259) 47 | Polygon: 48 | (58,189)(54,189)(54,174)(67,174)(67,177)(58,177) 49 | Polygon: 50 | (16,273)(16,274)(10,274)(10,277)(0,277)(0,269)(10,269)(10,273) 51 | Polygon: 52 | (144,239)(144,231)(151,231)(151,239) 53 | Polygon: 54 | (18,345)(19,345)(19,351)(18,351) 55 | Polygon: 56 | (270,365)(270,371)(280,371)(280,365)(276,365)(276,364)(275,364)(275,365) 57 | Polygon: 58 | (54,329)(54,326)(61,326)(61,329) 59 | Polygon: 60 | (288,174)(288,177)(290,177)(290,174) 61 | Polygon: 62 | (188,318)(188,307)(187,307)(187,316)(180,316)(180,318) 63 | Polygon: 64 | (84,459)(72,459)(72,468)(84,468) 65 | Polygon: 66 | (275,198)(270,198)(270,193)(275,193) 67 | Polygon: 68 | (21,164)(18,164)(18,155)(31,155)(31,159)(21,159) 69 | Polygon: 70 | (252,236)(258,236)(258,231)(252,231) 71 | Polygon: 72 | (234,313)(234,307)(243,307)(243,320)(240,320)(240,313) 73 | Polygon: 74 | (28,440)(18,440)(18,455)(28,455)(28,450)(33,450)(33,446)(28,446) 75 | Polygon: 76 | (180,212)(184,212)(184,219)(180,219) 77 | Polygon: 78 | (94,250)(94,254)(90,254)(90,250) 79 | Polygon: 80 | (270,299)(286,299)(286,297)(275,297)(275,288)(270,288) 81 | Polygon: 82 | (270,451)(284,451)(284,440)(270,440) 83 | Polygon: 84 | (288,421)(301,421)(301,423)(292,423)(292,430)(288,430) 85 | Polygon: 86 | (298,269)(298,281)(288,281)(288,269) 87 | Polygon: 88 | (132,408)(132,409)(131,409)(131,413)(126,413)(126,402)(131,402)(131,408) 89 | Polygon: 90 | (310,313)(310,307)(306,307)(306,313) 91 | Polygon: 92 | (129,383)(129,385)(126,385)(126,383) 93 | Polygon: 94 | (169,364)(162,364)(162,369)(169,369) 95 | Polygon: 96 | (44,250)(47,250)(47,261)(36,261)(36,256)(44,256) 97 | Polygon: 98 | (72,174)(72,184)(74,184)(74,176)(81,176)(81,174) 99 | Polygon: 100 | (190,297)(190,288)(180,288)(180,297) 101 | Polygon: 102 | (0,212)(12,212)(12,219)(3,219)(3,229)(0,229) 103 | Polygon: 104 | (198,413)(198,402)(209,402)(209,413) 105 | Polygon: 106 | (25,174)(18,174)(18,179)(24,179)(24,189)(25,189) 107 | Polygon: 108 | (306,288)(306,299)(319,299)(319,288) 109 | Polygon: 110 | (18,383)(18,394)(22,394)(22,386)(32,386)(32,383) 111 | Polygon: 112 | (180,435)(189,435)(189,421)(180,421) 113 | Polygon: 114 | (110,307)(108,307)(108,323)(110,323)(110,318)(112,318)(112,314)(110,314) 115 | Polygon: 116 | (170,272)(170,269)(162,269)(162,272) 117 | Polygon: 118 | (180,158)(180,155)(184,155)(184,158) 119 | Polygon: 120 | (306,257)(311,257)(311,250)(306,250) 121 | Polygon: 122 | (241,358)(243,358)(243,345)(234,345)(234,348)(241,348) 123 | Polygon: 124 | (144,471)(153,471)(153,468)(146,468)(146,459)(144,459) 125 | Polygon: 126 | (281,242)(270,242)(270,231)(281,231) 127 | Polygon: 128 | (310,383)(316,383)(316,396)(310,396)(310,392)(306,392)(306,390)(310,390) 129 | Polygon: 130 | (258,155)(252,155)(252,162)(258,162) 131 | Polygon: 132 | (204,383)(198,383)(198,386)(204,386) 133 | Polygon: 134 | (72,199)(72,193)(79,193)(79,199) 135 | Polygon: 136 | (242,421)(244,421)(244,434)(234,434)(234,430)(242,430) 137 | Polygon: 138 | (72,345)(72,352)(78,352)(78,345) 139 | Polygon: 140 | (13,177)(13,174)(0,174)(0,185)(4,185)(4,177) 141 | Polygon: 142 | (78,407)(78,402)(72,402)(72,407) 143 | Polygon: 144 | (270,329)(270,326)(283,326)(283,335)(278,335)(278,329) 145 | Polygon: 146 | (18,204)(26,204)(26,201)(19,201)(19,193)(18,193) 147 | Polygon: 148 | (162,307)(162,316)(173,316)(173,307) 149 | Polygon: 150 | (180,459)(180,464)(188,464)(188,459) 151 | Polygon: 152 | (148,453)(144,453)(144,440)(154,440)(154,444)(148,444) 153 | Polygon: 154 | (252,207)(252,193)(253,193)(253,203)(259,203)(259,207) 155 | Polygon: 156 | (270,174)(282,174)(282,183)(270,183) 157 | Polygon: 158 | (185,277)(185,269)(180,269)(180,277) 159 | Polygon: 160 | (46,337)(46,341)(36,341)(36,326)(41,326)(41,337) 161 | Polygon: 162 | (306,421)(316,421)(316,427)(306,427) 163 | Polygon: 164 | (82,223)(82,227)(72,227)(72,212)(76,212)(76,223) 165 | Polygon: 166 | (258,278)(258,269)(252,269)(252,278) 167 | Polygon: 168 | (298,207)(302,207)(302,193)(288,193)(288,199)(298,199) 169 | Polygon: 170 | (23,212)(23,219)(18,219)(18,212) 171 | Polygon: 172 | (97,174)(101,174)(101,188)(90,188)(90,184)(97,184) 173 | Polygon: 174 | (81,155)(72,155)(72,161)(80,161)(80,171)(81,171) 175 | Polygon: 176 | (173,260)(173,250)(162,250)(162,260) 177 | Polygon: 178 | (5,305)(0,305)(0,288)(6,288)(6,293)(11,293)(11,297)(5,297) 179 | Polygon: 180 | (252,255)(252,250)(259,250)(259,255) 181 | Polygon: 182 | (126,292)(130,292)(130,288)(126,288) 183 | Polygon: 184 | (0,236)(6,236)(6,231)(0,231) 185 | Polygon: 186 | (152,193)(156,193)(156,204)(144,204)(144,199)(152,199) 187 | Polygon: 188 | (306,326)(306,333)(312,333)(312,326) 189 | Polygon: 190 | (100,288)(104,288)(104,299)(90,299)(90,296)(100,296) 191 | Polygon: 192 | (43,193)(36,193)(36,205)(43,205)(43,201)(46,201)(46,199)(43,199) 193 | Polygon: 194 | (184,332)(180,332)(180,326)(184,326) 195 | Polygon: 196 | (164,326)(164,330)(162,330)(162,326) 197 | Polygon: 198 | (288,326)(293,326)(293,334)(288,334) 199 | Polygon: 200 | (288,408)(288,414)(303,414)(303,402)(301,402)(301,408) 201 | Polygon: 202 | (22,256)(24,256)(24,255)(27,255)(27,250)(18,250)(18,255)(22,255) 203 | Polygon: 204 | (0,258)(0,250)(2,250)(2,258) 205 | Polygon: 206 | (126,212)(126,214)(127,214)(127,212) 207 | Polygon: 208 | (282,273)(282,269)(270,269)(270,273)(274,273)(274,277)(276,277)(276,273) 209 | Polygon: 210 | (90,345)(90,348)(96,348)(96,345) 211 | Polygon: 212 | (144,385)(147,385)(147,383)(144,383) 213 | Polygon: 214 | (18,367)(18,373)(31,373)(31,367)(27,367)(27,364)(24,364)(24,367) 215 | Polygon: 216 | (21,466)(18,466)(18,459)(21,459) 217 | Polygon: 218 | (288,234)(288,231)(291,231)(291,234) 219 | Polygon: 220 | (61,390)(54,390)(54,383)(61,383) 221 | Polygon: 222 | (187,185)(192,185)(192,174)(180,174)(180,178)(187,178) 223 | Polygon: 224 | (0,364)(0,372)(1,372)(1,365)(9,365)(9,364) 225 | Polygon: 226 | (234,449)(246,449)(246,440)(234,440) 227 | Polygon: 228 | (43,348)(43,345)(36,345)(36,348) 229 | Polygon: 230 | (144,345)(147,345)(147,348)(144,348) 231 | Polygon: 232 | (113,427)(113,421)(108,421)(108,427) 233 | Polygon: 234 | (8,193)(10,193)(10,202)(0,202)(0,200)(8,200) 235 | Polygon: 236 | (126,277)(126,269)(127,269)(127,276)(134,276)(134,277) 237 | Polygon: 238 | (252,174)(252,184)(261,184)(261,174) 239 | Polygon: 240 | (298,212)(288,212)(288,213)(296,213)(296,221)(298,221) 241 | Polygon: 242 | (315,269)(315,278)(306,278)(306,269) 243 | Polygon: 244 | (216,406)(222,406)(222,402)(216,402) 245 | Polygon: 246 | (153,276)(153,279)(144,279)(144,269)(146,269)(146,276) 247 | Polygon: 248 | (204,344)(206,344)(206,339)(210,339)(210,326)(198,326)(198,336)(204,336) 249 | Polygon: 250 | (78,372)(72,372)(72,364)(78,364) 251 | Polygon: 252 | (126,178)(128,178)(128,174)(126,174) 253 | Polygon: 254 | (12,167)(0,167)(0,164)(9,164)(9,155)(12,155) 255 | Polygon: 256 | (126,459)(126,469)(138,469)(138,459) 257 | Polygon: 258 | (162,402)(167,402)(167,410)(162,410) 259 | Polygon: 260 | (141,369)(141,364)(126,364)(126,376)(130,376)(130,369) 261 | Polygon: 262 | (242,330)(242,334)(234,334)(234,330)(237,330)(237,326)(238,326)(238,330) 263 | Polygon: 264 | (183,199)(180,199)(180,193)(183,193) 265 | Polygon: 266 | (57,250)(54,250)(54,251)(57,251) 267 | Polygon: 268 | (72,262)(72,250)(73,250)(73,259)(80,259)(80,262) 269 | Polygon: 270 | (126,345)(126,355)(136,355)(136,345) 271 | Polygon: 272 | (23,236)(25,236)(25,234)(28,234)(28,231)(18,231)(18,234)(23,234) 273 | Polygon: 274 | (56,201)(56,193)(54,193)(54,201) 275 | Polygon: 276 | (216,271)(216,269)(217,269)(217,271) 277 | Polygon: 278 | (90,444)(90,440)(100,440)(100,444)(97,444)(97,447)(95,447)(95,444) 279 | Polygon: 280 | (76,269)(72,269)(72,276)(76,276) 281 | Polygon: 282 | (274,307)(270,307)(270,309)(274,309) 283 | Polygon: 284 | (216,202)(221,202)(221,193)(216,193) 285 | Polygon: 286 | (60,173)(65,173)(65,155)(54,155)(54,159)(60,159) 287 | Polygon: 288 | (221,174)(221,179)(216,179)(216,174) 289 | Polygon: 290 | (288,217)(288,222)(270,222)(270,212)(278,212)(278,217) 291 | Polygon: 292 | (293,155)(288,155)(288,159)(293,159) 293 | Polygon: 294 | (234,386)(234,383)(243,383)(243,392)(240,392)(240,386) 295 | Polygon: 296 | (42,307)(40,307)(40,309)(36,309)(36,313)(47,313)(47,309)(42,309) 297 | Polygon: 298 | (116,212)(108,212)(108,215)(116,215) 299 | Polygon: 300 | (54,366)(54,364)(56,364)(56,366) 301 | Polygon: 302 | (204,371)(206,371)(206,368)(210,368)(210,364)(198,364)(198,368)(204,368) 303 | Polygon: 304 | (108,326)(115,326)(115,333)(108,333) 305 | Polygon: 306 | (92,161)(90,161)(90,155)(92,155) 307 | Polygon: 308 | (306,181)(306,174)(311,174)(311,181) 309 | Polygon: 310 | (252,425)(252,421)(264,421)(264,432)(261,432)(261,425) 311 | Polygon: 312 | (168,174)(162,174)(162,183)(168,183)(168,179)(171,179)(171,178)(168,178) 313 | Polygon: 314 | (313,155)(313,159)(306,159)(306,155) 315 | Polygon: 316 | (306,345)(306,349)(308,349)(308,345) 317 | Polygon: 318 | (306,193)(318,193)(318,197)(309,197)(309,207)(306,207) 319 | Polygon: 320 | (270,250)(280,250)(280,263)(270,263) 321 | Polygon: 322 | (180,231)(180,240)(182,240)(182,232)(190,232)(190,231) 323 | Polygon: 324 | (9,459)(9,468)(0,468)(0,459) 325 | Polygon: 326 | (185,383)(180,383)(180,389)(185,389) 327 | Polygon: 328 | (205,250)(207,250)(207,260)(198,260)(198,256)(205,256) 329 | Polygon: 330 | (198,350)(198,345)(203,345)(203,350) 331 | Polygon: 332 | (113,167)(117,167)(117,155)(108,155)(108,157)(113,157) 333 | Polygon: 334 | (54,307)(54,312)(62,312)(62,307) 335 | Polygon: 336 | (57,212)(54,212)(54,224)(63,224)(63,221)(57,221) 337 | Polygon: 338 | (258,295)(260,295)(260,293)(263,293)(263,288)(252,288)(252,293)(258,293) 339 | Polygon: 340 | (276,155)(270,155)(270,157)(276,157) 341 | Polygon: 342 | (108,383)(109,383)(109,384)(108,384) 343 | Polygon: 344 | (42,421)(44,421)(44,422)(47,422)(47,426)(36,426)(36,422)(42,422) 345 | Polygon: 346 | (18,406)(24,406)(24,402)(18,402) 347 | Polygon: 348 | (37,443)(36,443)(36,440)(37,440) 349 | Polygon: 350 | (81,297)(72,297)(72,296)(80,296)(80,288)(81,288) 351 | Polygon: 352 | (234,231)(234,240)(243,240)(243,231) 353 | Polygon: 354 | (225,307)(225,315)(224,315)(224,308)(216,308)(216,307) 355 | Polygon: 356 | (153,364)(144,364)(144,375)(153,375) 357 | Polygon: 358 | (208,459)(208,464)(198,464)(198,459) 359 | Polygon: 360 | (198,427)(198,433)(214,433)(214,421)(209,421)(209,427) 361 | Polygon: 362 | (90,307)(90,317)(95,317)(95,309)(105,309)(105,307) 363 | Polygon: 364 | (155,416)(144,416)(144,402)(155,402) 365 | Polygon: 366 | (90,468)(101,468)(101,467)(92,467)(92,459)(90,459) 367 | Polygon: 368 | (126,440)(137,440)(137,449)(126,449) 369 | Polygon: 370 | (108,278)(121,278)(121,277)(112,277)(112,269)(108,269) 371 | Polygon: 372 | (306,231)(306,242)(319,242)(319,231) 373 | Polygon: 374 | (137,242)(126,242)(126,240)(134,240)(134,231)(137,231) 375 | Polygon: 376 | (120,204)(108,204)(108,193)(120,193) 377 | Polygon: 378 | (288,268)(302,268)(302,261)(292,261)(292,250)(288,250) 379 | Polygon: 380 | (47,471)(36,471)(36,459)(47,459) 381 | Polygon: 382 | (317,374)(317,364)(315,364)(315,372)(306,372)(306,374) 383 | Polygon: 384 | (208,222)(208,212)(198,212)(198,222) 385 | Polygon: 386 | (252,212)(252,227)(253,227)(253,217)(260,217)(260,212) 387 | Polygon: 388 | (0,383)(11,383)(11,394)(0,394) 389 | Polygon: 390 | (170,155)(170,162)(169,162)(169,156)(162,156)(162,155) 391 | Polygon: 392 | (47,231)(36,231)(36,242)(47,242) 393 | Polygon: 394 | (216,257)(221,257)(221,250)(216,250) 395 | Polygon: 396 | (146,166)(144,166)(144,155)(154,155)(154,157)(146,157) 397 | Polygon: 398 | (216,288)(216,301)(218,301)(218,291)(227,291)(227,288) 399 | Polygon: 400 | (105,269)(90,269)(90,279)(105,279) 401 | Polygon: 402 | (0,335)(15,335)(15,334)(5,334)(5,326)(0,326) 403 | Polygon: 404 | (317,451)(306,451)(306,440)(317,440) 405 | Polygon: 406 | (293,307)(291,307)(291,309)(288,309)(288,312)(299,312)(299,309)(293,309) 407 | Polygon: 408 | (54,237)(54,231)(56,231)(56,237) 409 | Polygon: 410 | (181,402)(181,403)(180,403)(180,402) 411 | Polygon: 412 | (0,445)(0,440)(5,440)(5,445) 413 | Polygon: 414 | (219,440)(216,440)(216,449)(225,449)(225,445)(219,445) 415 | Polygon: 416 | (258,402)(260,402)(260,404)(263,404)(263,408)(252,408)(252,404)(258,404) 417 | Polygon: 418 | (113,465)(113,459)(108,459)(108,465) 419 | Polygon: 420 | (37,212)(36,212)(36,216)(37,216) 421 | Polygon: 422 | (222,358)(216,358)(216,345)(222,345)(222,349)(224,349)(224,351)(222,351) 423 | Polygon: 424 | (288,346)(288,345)(295,345)(295,346) 425 | Polygon: 426 | (288,367)(289,367)(289,364)(288,364) 427 | Polygon: 428 | (234,217)(234,219)(235,219)(235,222)(237,222)(237,212)(235,212)(235,217) 429 | Polygon: 430 | (222,329)(216,329)(216,326)(222,326) 431 | Polygon: 432 | (162,421)(163,421)(163,423)(162,423) 433 | Polygon: 434 | (148,293)(144,293)(144,288)(148,288) 435 | Polygon: 436 | (162,234)(162,231)(171,231)(171,240)(169,240)(169,234) 437 | Polygon: 438 | (207,193)(207,202)(205,202)(205,194)(198,194)(198,193) 439 | Polygon: 440 | (162,392)(162,383)(174,383)(174,392) 441 | Polygon: 442 | (101,327)(101,326)(90,326)(90,327)(94,327)(94,328)(96,328)(96,327) 443 | Polygon: 444 | (93,231)(90,231)(90,239)(93,239) 445 | Polygon: 446 | (36,288)(36,291)(38,291)(38,288) 447 | Polygon: 448 | (252,345)(252,350)(257,350)(257,345) 449 | Polygon: 450 | (119,366)(119,364)(108,364)(108,373)(110,373)(110,366) 451 | Polygon: 452 | (207,307)(198,307)(198,308)(206,308)(206,315)(207,315) 453 | Polygon: 454 | (54,468)(54,459)(65,459)(65,468) 455 | Polygon: 456 | (18,274)(23,274)(23,269)(18,269) 457 | Polygon: 458 | (36,370)(36,373)(45,373)(45,364)(43,364)(43,370) 459 | Polygon: 460 | (297,288)(297,296)(295,296)(295,289)(288,289)(288,288) 461 | Polygon: 462 | (134,335)(134,326)(126,326)(126,335) 463 | Polygon: 464 | (180,373)(180,364)(184,364)(184,372)(193,372)(193,373) 465 | Polygon: 466 | (234,164)(234,155)(247,155)(247,164) 467 | Polygon: 468 | (185,345)(180,345)(180,350)(185,350) 469 | Polygon: 470 | (54,291)(54,288)(70,288)(70,297)(63,297)(63,291) 471 | Polygon: 472 | (256,376)(255,376)(255,372)(252,372)(252,364)(260,364)(260,372)(256,372) 473 | Polygon: 474 | (170,440)(170,447)(162,447)(162,440) 475 | Polygon: 476 | (306,402)(306,403)(313,403)(313,402) 477 | Polygon: 478 | (22,329)(23,329)(23,328)(25,328)(25,326)(18,326)(18,328)(22,328) 479 | Polygon: 480 | (257,448)(257,440)(252,440)(252,448) 481 | Polygon: 482 | (239,276)(237,276)(237,274)(234,274)(234,269)(244,269)(244,274)(239,274) 483 | Polygon: 484 | (204,176)(198,176)(198,174)(204,174) 485 | Polygon: 486 | (36,269)(36,270)(37,270)(37,269) 487 | Polygon: 488 | (219,155)(216,155)(216,163)(219,163) 489 | Polygon: 490 | (216,422)(219,422)(219,421)(216,421) 491 | Polygon: 492 | (90,374)(99,374)(99,372)(91,372)(91,364)(90,364) 493 | Polygon: 494 | (90,411)(90,402)(99,402)(99,411) 495 | Polygon: 496 | (315,212)(306,212)(306,213)(314,213)(314,219)(315,219) 497 | Polygon: 498 | (108,183)(108,174)(117,174)(117,183) 499 | Polygon: 500 | (90,421)(94,421)(94,426)(90,426) 501 | Polygon: 502 | (216,369)(216,364)(225,364)(225,373)(223,373)(223,369) 503 | Polygon: 504 | (181,250)(184,250)(184,262)(181,262)(181,258)(180,258)(180,256)(181,256) 505 | Polygon: 506 | (0,421)(2,421)(2,427)(0,427) 507 | Polygon: 508 | (126,252)(126,250)(128,250)(128,252) 509 | Polygon: 510 | (126,155)(131,155)(131,160)(126,160) 511 | Polygon: 512 | (119,445)(119,440)(108,440)(108,450)(110,450)(110,445) 513 | Polygon: 514 | (36,407)(36,402)(41,402)(41,407) 515 | Polygon: 516 | (270,426)(270,431)(279,431)(279,421)(275,421)(275,426) 517 | Polygon: 518 | (252,307)(257,307)(257,312)(252,312) 519 | Polygon: 520 | (113,345)(118,345)(118,355)(108,355)(108,351)(113,351) 521 | Polygon: 522 | (0,353)(9,353)(9,352)(2,352)(2,345)(0,345) 523 | Polygon: 524 | (82,334)(82,326)(72,326)(72,334) 525 | Polygon: 526 | (242,203)(234,203)(234,201)(241,201)(241,193)(242,193) 527 | Polygon: 528 | (82,451)(72,451)(72,440)(82,440) 529 | Polygon: 530 | (203,295)(198,295)(198,288)(203,288) 531 | Polygon: 532 | (114,288)(117,288)(117,300)(108,300)(108,296)(114,296) 533 | Polygon: 534 | (27,288)(18,288)(18,290)(26,290)(26,297)(27,297) 535 | Polygon: 536 | (198,165)(198,155)(210,155)(210,165) 537 | Polygon: 538 | (18,307)(23,307)(23,315)(18,315) 539 | Polygon: 540 | (234,257)(234,259)(247,259)(247,250)(245,250)(245,257) 541 | Polygon: 542 | (236,412)(240,412)(240,402)(236,402)(236,406)(234,406)(234,407)(236,407) 543 | Polygon: 544 | (37,181)(36,181)(36,174)(37,174) 545 | Polygon: 546 | (164,213)(164,212)(162,212)(162,213) 547 | Polygon: 548 | (72,231)(81,231)(81,232)(73,232)(73,238)(72,238) 549 | Polygon: 550 | (18,421)(18,431)(29,431)(29,421) 551 | Polygon: 552 | (198,453)(198,440)(202,440)(202,450)(211,450)(211,453) 553 | Polygon: 554 | (173,288)(173,300)(162,300)(162,288) 555 | Polygon: 556 | (64,451)(64,440)(54,440)(54,451) 557 | Polygon: 558 | (111,245)(108,245)(108,231)(123,231)(123,234)(111,234) 559 | Polygon: 560 | (126,421)(140,421)(140,425)(130,425)(130,436)(126,436) 561 | Polygon: 562 | (47,398)(36,398)(36,383)(47,383) 563 | Polygon: 564 | (144,259)(144,250)(150,250)(150,258)(161,258)(161,259) 565 | Polygon: 566 | (229,383)(229,396)(216,396)(216,383) 567 | Polygon: 568 | (197,440)(197,449)(191,449)(191,441)(180,441)(180,440) 569 | Polygon: 570 | (63,358)(54,358)(54,345)(63,345) 571 | Polygon: 572 | (90,212)(90,217)(102,217)(102,212) 573 | Polygon: 574 | (216,272)(216,269)(198,269)(198,278)(200,278)(200,272) 575 | Polygon: 576 | (144,332)(144,330)(151,330)(151,326)(161,326)(161,337)(153,337)(153,332) 577 | Polygon: 578 | (278,354)(270,354)(270,345)(278,345) 579 | Polygon: 580 | (144,307)(144,309)(150,309)(150,307) 581 | Polygon: 582 | (116,402)(108,402)(108,415)(116,415) 583 | Polygon: 584 | (180,358)(180,362)(162,362)(162,345)(167,345)(167,358) 585 | Polygon: 586 | (288,392)(288,383)(294,383)(294,390)(306,390)(306,392) 587 | Polygon: 588 | (247,182)(247,174)(234,174)(234,182) 589 | Polygon: 590 | (54,402)(59,402)(59,408)(54,408) 591 | Polygon: 592 | (90,388)(90,393)(72,393)(72,383)(79,383)(79,388) 593 | Polygon: 594 | (49,161)(49,164)(43,164)(43,169)(36,169)(36,155)(43,155)(43,161) 595 | Polygon: 596 | (270,402)(270,411)(279,411)(279,402) 597 | Polygon: 598 | (288,440)(292,440)(292,448)(288,448) 599 | Polygon: 600 | (126,206)(135,206)(135,193)(126,193) 601 | Polygon: 602 | (216,462)(216,459)(234,459)(234,476)(232,476)(232,462) 603 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_5.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (80,312)(80,307)(72,307)(72,312) 3 | Polygon: 4 | (9,402)(13,402)(13,414)(0,414)(0,411)(9,411) 5 | Polygon: 6 | (126,307)(134,307)(134,314)(126,314) 7 | Polygon: 8 | (16,312)(16,307)(0,307)(0,320)(6,320)(6,312) 9 | Polygon: 10 | (162,193)(162,204)(164,204)(164,196)(171,196)(171,193) 11 | Polygon: 12 | (162,459)(162,470)(172,470)(172,459) 13 | Polygon: 14 | (90,196)(90,200)(99,200)(99,196)(95,196)(95,193)(94,193)(94,196) 15 | Polygon: 16 | (270,390)(274,390)(274,383)(270,383) 17 | Polygon: 18 | (54,271)(58,271)(58,269)(54,269) 19 | Polygon: 20 | (144,421)(152,421)(152,428)(144,428) 21 | Polygon: 22 | (224,224)(229,224)(229,212)(216,212)(216,215)(224,215) 23 | Polygon: 24 | (236,288)(242,288)(242,298)(236,298)(236,294)(234,294)(234,293)(236,293) 25 | Polygon: 26 | (206,231)(206,236)(198,236)(198,231) 27 | Polygon: 28 | (236,364)(236,369)(234,369)(234,364) 29 | Polygon: 30 | (101,391)(101,383)(90,383)(90,391) 31 | Polygon: 32 | (63,436)(67,436)(67,421)(54,421)(54,425)(63,425) 33 | Polygon: 34 | (222,231)(222,240)(216,240)(216,231) 35 | Polygon: 36 | (261,337)(265,337)(265,326)(252,326)(252,331)(261,331) 37 | Polygon: 38 | (258,391)(258,383)(252,383)(252,391) 39 | Polygon: 40 | (144,216)(144,212)(158,212)(158,225)(152,225)(152,216) 41 | Polygon: 42 | (72,421)(79,421)(79,427)(72,427) 43 | Polygon: 44 | (154,181)(154,187)(144,187)(144,174)(147,174)(147,181) 45 | Polygon: 46 | (115,259)(115,250)(108,250)(108,259) 47 | Polygon: 48 | (58,189)(54,189)(54,174)(67,174)(67,177)(58,177) 49 | Polygon: 50 | (16,273)(16,274)(10,274)(10,277)(0,277)(0,269)(10,269)(10,273) 51 | Polygon: 52 | (144,239)(144,231)(151,231)(151,239) 53 | Polygon: 54 | (18,345)(19,345)(19,351)(18,351) 55 | Polygon: 56 | (270,365)(270,371)(280,371)(280,365)(276,365)(276,364)(275,364)(275,365) 57 | Polygon: 58 | (54,329)(54,326)(61,326)(61,329) 59 | Polygon: 60 | (288,174)(288,177)(290,177)(290,174) 61 | Polygon: 62 | (188,318)(188,307)(187,307)(187,316)(180,316)(180,318) 63 | Polygon: 64 | (84,459)(72,459)(72,468)(84,468) 65 | Polygon: 66 | (275,198)(270,198)(270,193)(275,193) 67 | Polygon: 68 | (21,164)(18,164)(18,155)(31,155)(31,159)(21,159) 69 | Polygon: 70 | (252,236)(258,236)(258,231)(252,231) 71 | Polygon: 72 | (234,313)(234,307)(243,307)(243,320)(240,320)(240,313) 73 | Polygon: 74 | (28,440)(18,440)(18,455)(28,455)(28,450)(33,450)(33,446)(28,446) 75 | Polygon: 76 | (180,212)(184,212)(184,219)(180,219) 77 | Polygon: 78 | (94,250)(94,254)(90,254)(90,250) 79 | Polygon: 80 | (270,299)(286,299)(286,297)(275,297)(275,288)(270,288) 81 | Polygon: 82 | (270,451)(284,451)(284,440)(270,440) 83 | Polygon: 84 | (288,421)(301,421)(301,423)(292,423)(292,430)(288,430) 85 | Polygon: 86 | (298,269)(298,281)(288,281)(288,269) 87 | Polygon: 88 | (132,408)(132,409)(131,409)(131,413)(126,413)(126,402)(131,402)(131,408) 89 | Polygon: 90 | (310,313)(310,307)(306,307)(306,313) 91 | Polygon: 92 | (129,383)(129,385)(126,385)(126,383) 93 | Polygon: 94 | (169,364)(162,364)(162,369)(169,369) 95 | Polygon: 96 | (44,250)(47,250)(47,261)(36,261)(36,256)(44,256) 97 | Polygon: 98 | (72,174)(72,184)(74,184)(74,176)(81,176)(81,174) 99 | Polygon: 100 | (190,297)(190,288)(180,288)(180,297) 101 | Polygon: 102 | (0,212)(12,212)(12,219)(3,219)(3,229)(0,229) 103 | Polygon: 104 | (198,413)(198,402)(209,402)(209,413) 105 | Polygon: 106 | (25,174)(18,174)(18,179)(24,179)(24,189)(25,189) 107 | Polygon: 108 | (306,288)(306,299)(319,299)(319,288) 109 | Polygon: 110 | (18,383)(18,394)(22,394)(22,386)(32,386)(32,383) 111 | Polygon: 112 | (180,435)(189,435)(189,421)(180,421) 113 | Polygon: 114 | (110,307)(108,307)(108,323)(110,323)(110,318)(112,318)(112,314)(110,314) 115 | Polygon: 116 | (170,272)(170,269)(162,269)(162,272) 117 | Polygon: 118 | (180,158)(180,155)(184,155)(184,158) 119 | Polygon: 120 | (306,257)(311,257)(311,250)(306,250) 121 | Polygon: 122 | (241,358)(243,358)(243,345)(234,345)(234,348)(241,348) 123 | Polygon: 124 | (144,471)(153,471)(153,468)(146,468)(146,459)(144,459) 125 | Polygon: 126 | (281,242)(270,242)(270,231)(281,231) 127 | Polygon: 128 | (310,383)(316,383)(316,396)(310,396)(310,392)(306,392)(306,390)(310,390) 129 | Polygon: 130 | (258,155)(252,155)(252,162)(258,162) 131 | Polygon: 132 | (204,383)(198,383)(198,386)(204,386) 133 | Polygon: 134 | (72,199)(72,193)(79,193)(79,199) 135 | Polygon: 136 | (242,421)(244,421)(244,434)(234,434)(234,430)(242,430) 137 | Polygon: 138 | (72,345)(72,352)(78,352)(78,345) 139 | Polygon: 140 | (13,177)(13,174)(0,174)(0,185)(4,185)(4,177) 141 | Polygon: 142 | (78,407)(78,402)(72,402)(72,407) 143 | Polygon: 144 | (270,329)(270,326)(283,326)(283,335)(278,335)(278,329) 145 | Polygon: 146 | (18,204)(26,204)(26,201)(19,201)(19,193)(18,193) 147 | Polygon: 148 | (162,307)(162,316)(173,316)(173,307) 149 | Polygon: 150 | (180,459)(180,464)(188,464)(188,459) 151 | Polygon: 152 | (148,453)(144,453)(144,440)(154,440)(154,444)(148,444) 153 | Polygon: 154 | (252,207)(252,193)(253,193)(253,203)(259,203)(259,207) 155 | Polygon: 156 | (270,174)(282,174)(282,183)(270,183) 157 | Polygon: 158 | (185,277)(185,269)(180,269)(180,277) 159 | Polygon: 160 | (46,337)(46,341)(36,341)(36,326)(41,326)(41,337) 161 | Polygon: 162 | (306,421)(316,421)(316,427)(306,427) 163 | Polygon: 164 | (82,223)(82,227)(72,227)(72,212)(76,212)(76,223) 165 | Polygon: 166 | (258,278)(258,269)(252,269)(252,278) 167 | Polygon: 168 | (298,207)(302,207)(302,193)(288,193)(288,199)(298,199) 169 | Polygon: 170 | (23,212)(23,219)(18,219)(18,212) 171 | Polygon: 172 | (97,174)(101,174)(101,188)(90,188)(90,184)(97,184) 173 | Polygon: 174 | (81,155)(72,155)(72,161)(80,161)(80,171)(81,171) 175 | Polygon: 176 | (173,260)(173,250)(162,250)(162,260) 177 | Polygon: 178 | (5,305)(0,305)(0,288)(6,288)(6,293)(11,293)(11,297)(5,297) 179 | Polygon: 180 | (252,255)(252,250)(259,250)(259,255) 181 | Polygon: 182 | (126,292)(130,292)(130,288)(126,288) 183 | Polygon: 184 | (0,236)(6,236)(6,231)(0,231) 185 | Polygon: 186 | (152,193)(156,193)(156,204)(144,204)(144,199)(152,199) 187 | Polygon: 188 | (306,326)(306,333)(312,333)(312,326) 189 | Polygon: 190 | (100,288)(104,288)(104,299)(90,299)(90,296)(100,296) 191 | Polygon: 192 | (43,193)(36,193)(36,205)(43,205)(43,201)(46,201)(46,199)(43,199) 193 | Polygon: 194 | (184,332)(180,332)(180,326)(184,326) 195 | Polygon: 196 | (164,326)(164,330)(162,330)(162,326) 197 | Polygon: 198 | (288,326)(293,326)(293,334)(288,334) 199 | Polygon: 200 | (288,408)(288,414)(303,414)(303,402)(301,402)(301,408) 201 | Polygon: 202 | (22,256)(24,256)(24,255)(27,255)(27,250)(18,250)(18,255)(22,255) 203 | Polygon: 204 | (0,258)(0,250)(2,250)(2,258) 205 | Polygon: 206 | (126,212)(126,214)(127,214)(127,212) 207 | Polygon: 208 | (282,273)(282,269)(270,269)(270,273)(274,273)(274,277)(276,277)(276,273) 209 | Polygon: 210 | (90,345)(90,348)(96,348)(96,345) 211 | Polygon: 212 | (144,385)(147,385)(147,383)(144,383) 213 | Polygon: 214 | (18,367)(18,373)(31,373)(31,367)(27,367)(27,364)(24,364)(24,367) 215 | Polygon: 216 | (21,466)(18,466)(18,459)(21,459) 217 | Polygon: 218 | (288,234)(288,231)(291,231)(291,234) 219 | Polygon: 220 | (61,390)(54,390)(54,383)(61,383) 221 | Polygon: 222 | (187,185)(192,185)(192,174)(180,174)(180,178)(187,178) 223 | Polygon: 224 | (0,364)(0,372)(1,372)(1,365)(9,365)(9,364) 225 | Polygon: 226 | (234,449)(246,449)(246,440)(234,440) 227 | Polygon: 228 | (43,348)(43,345)(36,345)(36,348) 229 | Polygon: 230 | (144,345)(147,345)(147,348)(144,348) 231 | Polygon: 232 | (113,427)(113,421)(108,421)(108,427) 233 | Polygon: 234 | (8,193)(10,193)(10,202)(0,202)(0,200)(8,200) 235 | Polygon: 236 | (126,277)(126,269)(127,269)(127,276)(134,276)(134,277) 237 | Polygon: 238 | (252,174)(252,184)(261,184)(261,174) 239 | Polygon: 240 | (298,212)(288,212)(288,213)(296,213)(296,221)(298,221) 241 | Polygon: 242 | (315,269)(315,278)(306,278)(306,269) 243 | Polygon: 244 | (216,406)(222,406)(222,402)(216,402) 245 | Polygon: 246 | (153,276)(153,279)(144,279)(144,269)(146,269)(146,276) 247 | Polygon: 248 | (204,344)(206,344)(206,339)(210,339)(210,326)(198,326)(198,336)(204,336) 249 | Polygon: 250 | (78,372)(72,372)(72,364)(78,364) 251 | Polygon: 252 | (126,178)(128,178)(128,174)(126,174) 253 | Polygon: 254 | (12,167)(0,167)(0,164)(9,164)(9,155)(12,155) 255 | Polygon: 256 | (126,459)(126,469)(138,469)(138,459) 257 | Polygon: 258 | (162,402)(167,402)(167,410)(162,410) 259 | Polygon: 260 | (141,369)(141,364)(126,364)(126,376)(130,376)(130,369) 261 | Polygon: 262 | (242,330)(242,334)(234,334)(234,330)(237,330)(237,326)(238,326)(238,330) 263 | Polygon: 264 | (183,199)(180,199)(180,193)(183,193) 265 | Polygon: 266 | (57,250)(54,250)(54,251)(57,251) 267 | Polygon: 268 | (72,262)(72,250)(73,250)(73,259)(80,259)(80,262) 269 | Polygon: 270 | (126,345)(126,355)(136,355)(136,345) 271 | Polygon: 272 | (23,236)(25,236)(25,234)(28,234)(28,231)(18,231)(18,234)(23,234) 273 | Polygon: 274 | (56,201)(56,193)(54,193)(54,201) 275 | Polygon: 276 | (216,271)(216,269)(217,269)(217,271) 277 | Polygon: 278 | (90,444)(90,440)(100,440)(100,444)(97,444)(97,447)(95,447)(95,444) 279 | Polygon: 280 | (76,269)(72,269)(72,276)(76,276) 281 | Polygon: 282 | (274,307)(270,307)(270,309)(274,309) 283 | Polygon: 284 | (216,202)(221,202)(221,193)(216,193) 285 | Polygon: 286 | (60,173)(65,173)(65,155)(54,155)(54,159)(60,159) 287 | Polygon: 288 | (221,174)(221,179)(216,179)(216,174) 289 | Polygon: 290 | (288,217)(288,222)(270,222)(270,212)(278,212)(278,217) 291 | Polygon: 292 | (293,155)(288,155)(288,159)(293,159) 293 | Polygon: 294 | (234,386)(234,383)(243,383)(243,392)(240,392)(240,386) 295 | Polygon: 296 | (42,307)(40,307)(40,309)(36,309)(36,313)(47,313)(47,309)(42,309) 297 | Polygon: 298 | (116,212)(108,212)(108,215)(116,215) 299 | Polygon: 300 | (54,366)(54,364)(56,364)(56,366) 301 | Polygon: 302 | (204,371)(206,371)(206,368)(210,368)(210,364)(198,364)(198,368)(204,368) 303 | Polygon: 304 | (108,326)(115,326)(115,333)(108,333) 305 | Polygon: 306 | (92,161)(90,161)(90,155)(92,155) 307 | Polygon: 308 | (306,181)(306,174)(311,174)(311,181) 309 | Polygon: 310 | (252,425)(252,421)(264,421)(264,432)(261,432)(261,425) 311 | Polygon: 312 | (168,174)(162,174)(162,183)(168,183)(168,179)(171,179)(171,178)(168,178) 313 | Polygon: 314 | (313,155)(313,159)(306,159)(306,155) 315 | Polygon: 316 | (306,345)(306,349)(308,349)(308,345) 317 | Polygon: 318 | (306,193)(318,193)(318,197)(309,197)(309,207)(306,207) 319 | Polygon: 320 | (270,250)(280,250)(280,263)(270,263) 321 | Polygon: 322 | (180,231)(180,240)(182,240)(182,232)(190,232)(190,231) 323 | Polygon: 324 | (9,459)(9,468)(0,468)(0,459) 325 | Polygon: 326 | (185,383)(180,383)(180,389)(185,389) 327 | Polygon: 328 | (205,250)(207,250)(207,260)(198,260)(198,256)(205,256) 329 | Polygon: 330 | (198,350)(198,345)(203,345)(203,350) 331 | Polygon: 332 | (113,167)(117,167)(117,155)(108,155)(108,157)(113,157) 333 | Polygon: 334 | (54,307)(54,312)(62,312)(62,307) 335 | Polygon: 336 | (57,212)(54,212)(54,224)(63,224)(63,221)(57,221) 337 | Polygon: 338 | (258,295)(260,295)(260,293)(263,293)(263,288)(252,288)(252,293)(258,293) 339 | Polygon: 340 | (276,155)(270,155)(270,157)(276,157) 341 | Polygon: 342 | (108,383)(109,383)(109,384)(108,384) 343 | Polygon: 344 | (42,421)(44,421)(44,422)(47,422)(47,426)(36,426)(36,422)(42,422) 345 | Polygon: 346 | (18,406)(24,406)(24,402)(18,402) 347 | Polygon: 348 | (37,443)(36,443)(36,440)(37,440) 349 | Polygon: 350 | (81,297)(72,297)(72,296)(80,296)(80,288)(81,288) 351 | Polygon: 352 | (234,231)(234,240)(243,240)(243,231) 353 | Polygon: 354 | (225,307)(225,315)(224,315)(224,308)(216,308)(216,307) 355 | Polygon: 356 | (153,364)(144,364)(144,375)(153,375) 357 | Polygon: 358 | (208,459)(208,464)(198,464)(198,459) 359 | Polygon: 360 | (198,427)(198,433)(214,433)(214,421)(209,421)(209,427) 361 | Polygon: 362 | (90,307)(90,317)(95,317)(95,309)(105,309)(105,307) 363 | Polygon: 364 | (155,416)(144,416)(144,402)(155,402) 365 | Polygon: 366 | (90,468)(101,468)(101,467)(92,467)(92,459)(90,459) 367 | Polygon: 368 | (126,440)(137,440)(137,449)(126,449) 369 | Polygon: 370 | (108,278)(121,278)(121,277)(112,277)(112,269)(108,269) 371 | Polygon: 372 | (306,231)(306,242)(319,242)(319,231) 373 | Polygon: 374 | (137,242)(126,242)(126,240)(134,240)(134,231)(137,231) 375 | Polygon: 376 | (120,204)(108,204)(108,193)(120,193) 377 | Polygon: 378 | (288,268)(302,268)(302,261)(292,261)(292,250)(288,250) 379 | Polygon: 380 | (47,471)(36,471)(36,459)(47,459) 381 | Polygon: 382 | (317,374)(317,364)(315,364)(315,372)(306,372)(306,374) 383 | Polygon: 384 | (208,222)(208,212)(198,212)(198,222) 385 | Polygon: 386 | (252,212)(252,227)(253,227)(253,217)(260,217)(260,212) 387 | Polygon: 388 | (0,383)(11,383)(11,394)(0,394) 389 | Polygon: 390 | (170,155)(170,162)(169,162)(169,156)(162,156)(162,155) 391 | Polygon: 392 | (47,231)(36,231)(36,242)(47,242) 393 | Polygon: 394 | (216,257)(221,257)(221,250)(216,250) 395 | Polygon: 396 | (146,166)(144,166)(144,155)(154,155)(154,157)(146,157) 397 | Polygon: 398 | (216,288)(216,301)(218,301)(218,291)(227,291)(227,288) 399 | Polygon: 400 | (105,269)(90,269)(90,279)(105,279) 401 | Polygon: 402 | (0,335)(15,335)(15,334)(5,334)(5,326)(0,326) 403 | Polygon: 404 | (317,451)(306,451)(306,440)(317,440) 405 | Polygon: 406 | (293,307)(291,307)(291,309)(288,309)(288,312)(299,312)(299,309)(293,309) 407 | Polygon: 408 | (54,237)(54,231)(56,231)(56,237) 409 | Polygon: 410 | (181,402)(181,403)(180,403)(180,402) 411 | Polygon: 412 | (0,445)(0,440)(5,440)(5,445) 413 | Polygon: 414 | (219,440)(216,440)(216,449)(225,449)(225,445)(219,445) 415 | Polygon: 416 | (258,402)(260,402)(260,404)(263,404)(263,408)(252,408)(252,404)(258,404) 417 | Polygon: 418 | (113,465)(113,459)(108,459)(108,465) 419 | Polygon: 420 | (37,212)(36,212)(36,216)(37,216) 421 | Polygon: 422 | (222,358)(216,358)(216,345)(222,345)(222,349)(224,349)(224,351)(222,351) 423 | Polygon: 424 | (288,346)(288,345)(295,345)(295,346) 425 | Polygon: 426 | (288,367)(289,367)(289,364)(288,364) 427 | Polygon: 428 | (234,217)(234,219)(235,219)(235,222)(237,222)(237,212)(235,212)(235,217) 429 | Polygon: 430 | (222,329)(216,329)(216,326)(222,326) 431 | Polygon: 432 | (162,421)(163,421)(163,423)(162,423) 433 | Polygon: 434 | (148,293)(144,293)(144,288)(148,288) 435 | Polygon: 436 | (162,234)(162,231)(171,231)(171,240)(169,240)(169,234) 437 | Polygon: 438 | (207,193)(207,202)(205,202)(205,194)(198,194)(198,193) 439 | Polygon: 440 | (162,392)(162,383)(174,383)(174,392) 441 | Polygon: 442 | (101,327)(101,326)(90,326)(90,327)(94,327)(94,328)(96,328)(96,327) 443 | Polygon: 444 | (93,231)(90,231)(90,239)(93,239) 445 | Polygon: 446 | (36,288)(36,291)(38,291)(38,288) 447 | Polygon: 448 | (252,345)(252,350)(257,350)(257,345) 449 | Polygon: 450 | (119,366)(119,364)(108,364)(108,373)(110,373)(110,366) 451 | Polygon: 452 | (207,307)(198,307)(198,308)(206,308)(206,315)(207,315) 453 | Polygon: 454 | (54,468)(54,459)(65,459)(65,468) 455 | Polygon: 456 | (18,274)(23,274)(23,269)(18,269) 457 | Polygon: 458 | (36,370)(36,373)(45,373)(45,364)(43,364)(43,370) 459 | Polygon: 460 | (297,288)(297,296)(295,296)(295,289)(288,289)(288,288) 461 | Polygon: 462 | (134,335)(134,326)(126,326)(126,335) 463 | Polygon: 464 | (180,373)(180,364)(184,364)(184,372)(193,372)(193,373) 465 | Polygon: 466 | (234,164)(234,155)(247,155)(247,164) 467 | Polygon: 468 | (185,345)(180,345)(180,350)(185,350) 469 | Polygon: 470 | (54,291)(54,288)(70,288)(70,297)(63,297)(63,291) 471 | Polygon: 472 | (256,376)(255,376)(255,372)(252,372)(252,364)(260,364)(260,372)(256,372) 473 | Polygon: 474 | (170,440)(170,447)(162,447)(162,440) 475 | Polygon: 476 | (306,402)(306,403)(313,403)(313,402) 477 | Polygon: 478 | (22,329)(23,329)(23,328)(25,328)(25,326)(18,326)(18,328)(22,328) 479 | Polygon: 480 | (257,448)(257,440)(252,440)(252,448) 481 | Polygon: 482 | (239,276)(237,276)(237,274)(234,274)(234,269)(244,269)(244,274)(239,274) 483 | Polygon: 484 | (204,176)(198,176)(198,174)(204,174) 485 | Polygon: 486 | (36,269)(36,270)(37,270)(37,269) 487 | Polygon: 488 | (219,155)(216,155)(216,163)(219,163) 489 | Polygon: 490 | (216,422)(219,422)(219,421)(216,421) 491 | Polygon: 492 | (90,374)(99,374)(99,372)(91,372)(91,364)(90,364) 493 | Polygon: 494 | (90,411)(90,402)(99,402)(99,411) 495 | Polygon: 496 | (315,212)(306,212)(306,213)(314,213)(314,219)(315,219) 497 | Polygon: 498 | (108,183)(108,174)(117,174)(117,183) 499 | Polygon: 500 | (90,421)(94,421)(94,426)(90,426) 501 | Polygon: 502 | (216,369)(216,364)(225,364)(225,373)(223,373)(223,369) 503 | Polygon: 504 | (181,250)(184,250)(184,262)(181,262)(181,258)(180,258)(180,256)(181,256) 505 | Polygon: 506 | (0,421)(2,421)(2,427)(0,427) 507 | Polygon: 508 | (126,252)(126,250)(128,250)(128,252) 509 | Polygon: 510 | (126,155)(131,155)(131,160)(126,160) 511 | Polygon: 512 | (119,445)(119,440)(108,440)(108,450)(110,450)(110,445) 513 | Polygon: 514 | (36,407)(36,402)(41,402)(41,407) 515 | Polygon: 516 | (270,426)(270,431)(279,431)(279,421)(275,421)(275,426) 517 | Polygon: 518 | (252,307)(257,307)(257,312)(252,312) 519 | Polygon: 520 | (113,345)(118,345)(118,355)(108,355)(108,351)(113,351) 521 | Polygon: 522 | (0,353)(9,353)(9,352)(2,352)(2,345)(0,345) 523 | Polygon: 524 | (82,334)(82,326)(72,326)(72,334) 525 | Polygon: 526 | (242,203)(234,203)(234,201)(241,201)(241,193)(242,193) 527 | Polygon: 528 | (82,451)(72,451)(72,440)(82,440) 529 | Polygon: 530 | (203,295)(198,295)(198,288)(203,288) 531 | Polygon: 532 | (114,288)(117,288)(117,300)(108,300)(108,296)(114,296) 533 | Polygon: 534 | (27,288)(18,288)(18,290)(26,290)(26,297)(27,297) 535 | Polygon: 536 | (198,165)(198,155)(210,155)(210,165) 537 | Polygon: 538 | (18,307)(23,307)(23,315)(18,315) 539 | Polygon: 540 | (234,257)(234,259)(247,259)(247,250)(245,250)(245,257) 541 | Polygon: 542 | (236,412)(240,412)(240,402)(236,402)(236,406)(234,406)(234,407)(236,407) 543 | Polygon: 544 | (37,181)(36,181)(36,174)(37,174) 545 | Polygon: 546 | (164,213)(164,212)(162,212)(162,213) 547 | Polygon: 548 | (72,231)(81,231)(81,232)(73,232)(73,238)(72,238) 549 | Polygon: 550 | (18,421)(18,431)(29,431)(29,421) 551 | Polygon: 552 | (198,453)(198,440)(202,440)(202,450)(211,450)(211,453) 553 | Polygon: 554 | (173,288)(173,300)(162,300)(162,288) 555 | Polygon: 556 | (64,451)(64,440)(54,440)(54,451) 557 | Polygon: 558 | (111,245)(108,245)(108,231)(123,231)(123,234)(111,234) 559 | Polygon: 560 | (126,421)(140,421)(140,425)(130,425)(130,436)(126,436) 561 | Polygon: 562 | (47,398)(36,398)(36,383)(47,383) 563 | Polygon: 564 | (144,259)(144,250)(150,250)(150,258)(161,258)(161,259) 565 | Polygon: 566 | (229,383)(229,396)(216,396)(216,383) 567 | Polygon: 568 | (197,440)(197,449)(191,449)(191,441)(180,441)(180,440) 569 | Polygon: 570 | (63,358)(54,358)(54,345)(63,345) 571 | Polygon: 572 | (90,212)(90,217)(102,217)(102,212) 573 | Polygon: 574 | (216,272)(216,269)(198,269)(198,278)(200,278)(200,272) 575 | Polygon: 576 | (144,332)(144,330)(151,330)(151,326)(161,326)(161,337)(153,337)(153,332) 577 | Polygon: 578 | (278,354)(270,354)(270,345)(278,345) 579 | Polygon: 580 | (144,307)(144,309)(150,309)(150,307) 581 | Polygon: 582 | (116,402)(108,402)(108,415)(116,415) 583 | Polygon: 584 | (180,358)(180,362)(162,362)(162,345)(167,345)(167,358) 585 | Polygon: 586 | (288,392)(288,383)(294,383)(294,390)(306,390)(306,392) 587 | Polygon: 588 | (247,182)(247,174)(234,174)(234,182) 589 | Polygon: 590 | (54,402)(59,402)(59,408)(54,408) 591 | Polygon: 592 | (90,388)(90,393)(72,393)(72,383)(79,383)(79,388) 593 | Polygon: 594 | (49,161)(49,164)(43,164)(43,169)(36,169)(36,155)(43,155)(43,161) 595 | Polygon: 596 | (270,402)(270,411)(279,411)(279,402) 597 | Polygon: 598 | (288,440)(292,440)(292,448)(288,448) 599 | Polygon: 600 | (126,206)(135,206)(135,193)(126,193) 601 | Polygon: 602 | (216,462)(216,459)(234,459)(234,476)(232,476)(232,462) 603 | -------------------------------------------------------------------------------- /nest.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | ''' 3 | @File : nest.py 4 | @Time : 2020/11/19 18:52:28 5 | @Author : KingofCode 6 | @Version : 1.0 7 | @Contact : mrlution@qq.com 8 | @Desc : 主要的打包类 9 | ''' 10 | 11 | # here put the import lib 12 | from tools import placement_worker, nfp_utls 13 | import math 14 | import json 15 | import random 16 | import copy 17 | from Polygon import Polygon 18 | import pyclipper 19 | #from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas 20 | #from matplotlib.figure import Figure 21 | #from settings import SPACING, ROTATIONS, POPULATION_SIZE, MUTA_RATE,DEBUG,DRAWPIC,SCALE,COMPLEX_FIRST_STRATEGY,COMPLEX_FIRST_AREA_SECOND_STRATEGY,MIXED_COMPLEX_STRATEGY,STOP_GENERATION 22 | from setting import settings 23 | from GAlgo import genetic_algorithm 24 | 25 | 26 | 27 | class ThisClass(): 28 | """仅仅用作初始参数的存储 29 | """ 30 | config = { 31 | 'curveTolerance': 0, # 允许的最大误差.更小的将需要更长的时间来计算 32 | 'spacing': settings.SPACING, # 积木块间的间隔 33 | 'rotations': settings.ROTATIONS, # 旋转的颗粒度,360°的n份,如:4 = [0, 90 ,180, 270] 34 | 'populationSize': settings.POPULATION_SIZE, # 基因群数量 35 | 'mutationRate': settings.MUTA_RATE, # 变异概率 36 | 'useHoles': False, # 是否有洞,暂时都是没有洞 37 | 'exploreConcave': False # 寻找凹面,暂时是否 38 | } 39 | container = None 40 | container_bounds=None 41 | nfp_cache = {} 42 | 43 | 44 | 45 | 46 | class Nester: 47 | """主要的打包模块,控制着打包过程 48 | """ 49 | def __init__(self, container=None, shapes=None): 50 | 51 | self.originalshapes=[] 52 | self.container = container # 打包容器 53 | self.shapes = shapes # 积木块形状信息 54 | self.shapes_total_area=None 55 | #self.shapes_max_length = 0 # 在无限长的布 56 | self.results = list() # storage for the different results 57 | self.nfp_cache = {} # 缓存中间计算结果 58 | 59 | # 遗传算法的参数 60 | self.config = ThisClass.config 61 | self.GA = None # 遗传算法 62 | self.best = None # 记录最佳结果 63 | self.worker = None # 根据NFP结果,计算每个图形的转移数据 64 | self.container_bounds = None # 容器的最小包络矩形作为输出图的坐标 65 | 66 | def add_objects(self, objects,objects_str): 67 | """加载形状 68 | 69 | Args: 70 | objects (list): 形状信息 71 | objects_str (str): 因为打分程序要求输入点的顺序不能改变,使用它来存储这一信息 72 | """ 73 | if not isinstance(objects, list): 74 | objects = [objects] 75 | if not self.shapes: 76 | self.shapes = [] 77 | 78 | self.originalshapes=objects_str 79 | p_id = 0 80 | total_area = 0 81 | for obj in objects: 82 | points = self.clean_polygon(obj) 83 | shape = { 84 | 'area': 0, 85 | 'p_id': str(p_id), 86 | 'points': [{'x': p[0], 'y': p[1]} for p in points] 87 | } 88 | # 确定多边形的线段方向 89 | area = nfp_utls.polygon_area(shape['points']) 90 | if area > 0: 91 | shape['points'].reverse() 92 | 93 | shape['area'] = abs(area) 94 | total_area += shape['area'] 95 | self.shapes.append(shape) 96 | 97 | #积木形状总面积 98 | self.shapes_total_area=total_area 99 | 100 | # 如果是一般布,需要这个尺寸 101 | #self.shapes_max_length = math.sqrt(total_area) 102 | 103 | def add_container(self, container): 104 | """加载容器 105 | 106 | Args: 107 | container (dict): 容器 108 | """ 109 | if not self.container: 110 | self.container = {} 111 | 112 | self.origin_container=container 113 | 114 | container = self.clean_polygon(container) 115 | 116 | self.container['points'] = [{'x': p[0], 'y':p[1]} for p in container] 117 | self.container['p_id'] = '-1' 118 | xbinmax = self.container['points'][0]['x'] 119 | xbinmin = self.container['points'][0]['x'] 120 | ybinmax = self.container['points'][0]['y'] 121 | ybinmin = self.container['points'][0]['y'] 122 | 123 | for point in self.container['points']: 124 | if point['x'] > xbinmax: 125 | xbinmax = point['x'] 126 | elif point['x'] < xbinmin: 127 | xbinmin = point['x'] 128 | if point['y'] > ybinmax: 129 | ybinmax = point['y'] 130 | elif point['y'] < ybinmin: 131 | ybinmin = point['y'] 132 | 133 | self.container['width'] = xbinmax - xbinmin 134 | self.container['height'] = ybinmax - ybinmin 135 | 136 | # 最小包络多边形 137 | self.container_bounds = nfp_utls.get_polygon_bounds(self.container['points']) 138 | 139 | #添加完容器后计算积木块与容器之间,积木块之间的NFP 140 | self.calculateNFP() 141 | 142 | 143 | def calculateNFP(self): 144 | """计算NFP 145 | """ 146 | #self.nfp_cache #Nest的NFP缓存 147 | nfp_pairs = [] #待计算列表 148 | new_cache = {} #NFP缓存 149 | place_list=copy.deepcopy(self.shapes) 150 | #print(place_list) 151 | 152 | for i in range(0, len(place_list)): 153 | # 容器和图形的内切多边形计算 154 | part = place_list[i] 155 | key = { 156 | 'A': '-1', 157 | 'B': str(i), #TODO:检查 应该是B在数据集中的顺序 158 | 'inside': True, 159 | 'A_rotation': 0, 160 | 'B_rotation': 0 161 | } 162 | tmp_json_key = json.dumps(key) 163 | if not tmp_json_key in self.nfp_cache: #如果不在NEST缓存中就加入待计算列表 164 | nfp_pairs.append({ 165 | 'A': self.container, 166 | 'B': part, # {'area': 169.0, 'p_id': '0', 'points': [{'x': 165, 'y': 233}, {'x': 152, 'y': 233}, {'x': 152, 'y': 220}, {'x': 165, 'y': 220}]} 167 | 'key': key 168 | }) 169 | # else: #如果在NEST缓存中,就将其提取出来放到new_cache中,等下用于替换NEST缓存,这样nest缓存中的nfp更可能用到 170 | # # 万年用不到的NEST NFP缓存就丢弃 171 | # new_cache[tmp_json_key] = self.nfp_cache[tmp_json_key] 172 | 173 | # 图形与图形之间的外切多边形计算 174 | for j in range(0, len(place_list)): 175 | placed = place_list[j] 176 | key = { 177 | 'A': str(j), 178 | 'B': str(i), 179 | 'inside': False, 180 | 'A_rotation': 0, 181 | 'B_rotation': 0 182 | } 183 | tmp_json_key = json.dumps(key) 184 | if not tmp_json_key in self.nfp_cache: 185 | nfp_pairs.append({ 186 | 'A': placed, 187 | 'B': part, 188 | 'key': key 189 | }) 190 | # else: 191 | # new_cache[tmp_json_key] = self.nfp_cache[tmp_json_key] 192 | 193 | #不删除旧NFP 194 | #self.nfp_cache = new_cache 195 | 196 | 197 | 198 | # 计算所有图形两两组合的相切多边形(NFP) 199 | # from tool.calculate_npf import NFP_Calculater 200 | # nfp_calculater=NFP_Calculater(self.config) 201 | # pair_list = [] 202 | # for pair in nfp_pairs: #计算待计算NFP 203 | # pair_list.append(nfp_calculater.process_nfp(pair)) 204 | 205 | #**********批量计算nfp***************************************************# 206 | from main import batchNFPCalculate 207 | pair_list=batchNFPCalculate(self.nWorker,nfp_pairs) 208 | #***********************************************************************# 209 | 210 | #print(pair_list) 211 | 212 | #将待计算列表计算出的nfp添加到cache中 213 | if pair_list: 214 | for i in range(0, len(pair_list)): 215 | if pair_list[i]:#{'key': pair['key'], 'value': nfp} 216 | key = json.dumps(pair_list[i]['key']) 217 | self.nfp_cache[key] = pair_list[i]['value']#{"pair['key']":nfp} 218 | 219 | #计算结束.计算结果在self.nfp_cache中 220 | #print("nfp",self.nfp_cache) 221 | #print("计算NFP结束") 222 | #向子线程发送缓存和容器 223 | from main import batchSendContainerAndNFPCache 224 | batchSendContainerAndNFPCache(self.nWorker,self.container,self.nfp_cache) 225 | 226 | def polygon_offset(self, polygon, offset): 227 | """偏移多边形 228 | 229 | Args: 230 | polygon (list): 多边形 231 | offset ([type]): 偏移量 232 | 233 | Returns: 234 | list: 偏移后的图形 235 | """ 236 | is_list = True 237 | if isinstance(polygon[0], dict): 238 | polygon = [[p['x'], p['y']] for p in polygon] 239 | is_list = False 240 | 241 | miter_limit = 2 242 | co = pyclipper.PyclipperOffset(miter_limit, self.config['curveTolerance']) 243 | co.AddPath(polygon, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON) 244 | result = co.Execute(1*offset) 245 | if not is_list: 246 | result = [{'x': p[0], 'y':p[1]} for p in result[0]] 247 | return result 248 | 249 | def clear(self): 250 | """从打包模块中清除所有多边形 251 | """ 252 | self.shapes = None 253 | 254 | def run(self): 255 | """ 256 | 运行打包操作 257 | 如果开多线程,可以在这里设计检查中断信号 258 | """ 259 | 260 | if self.GA is None: 261 | faces = list() 262 | for i in range(0, len(self.shapes)): 263 | shape = copy.deepcopy(self.shapes[i]) 264 | shape['points'] = self.polygon_offset(shape['points'], self.config['spacing']) 265 | faces.append([str(i), shape]) 266 | 267 | # 按面积排序 268 | faces = sorted(faces, reverse=True, key=lambda face: face[1]['area']) 269 | 270 | #TODO:施工 271 | #按复杂度分类,重新排 272 | if settings.COMPLEX_FIRST_STRATEGY: 273 | do1=True 274 | do2=False 275 | do3=False 276 | elif settings.COMPLEX_FIRST_AREA_SECOND_STRATEGY: 277 | do1=True 278 | do2=True 279 | do3=False 280 | elif settings.MIXED_COMPLEX_STRATEGY: 281 | do1=True 282 | do2=False 283 | do3=True 284 | if do1: 285 | list_Dio=[] 286 | list_L=[] 287 | list_Square=[] 288 | for item in faces: 289 | if len(item[1]["points"])>6: 290 | list_Dio.append(item) 291 | elif len(item[1]["points"])==6: 292 | list_L.append(item) 293 | else: 294 | list_Square.append(item) 295 | if do2: 296 | percent=0.9 297 | BigDio=list_Dio[0:int(len(list_Dio)*percent)] 298 | SmallDio=list_Dio[int(len(list_Dio)*percent):] 299 | BigL=list_L[0:int(len(list_L)*percent)] 300 | SmallL=list_L[int(len(list_L)*percent):] 301 | BigS=list_Square[0:int(len(list_Square)*percent)] 302 | SmallS=list_Square[int(len(list_Square)*percent):] 303 | faces=BigDio+BigL+BigS+SmallDio+SmallL+SmallS 304 | elif do3: 305 | percent=0.5 306 | SmallS=list_Square[int(len(list_Square)*percent):] 307 | BigS=list_Square[0:int(len(list_Square)*percent)] 308 | Mixed=list_Dio+list_L+BigS 309 | Mixed=sorted(Mixed, reverse=True, key=lambda Mixed: Mixed[1]['area']) 310 | print(Mixed) 311 | print("****") 312 | print(SmallS) 313 | faces=Mixed+SmallS 314 | else: 315 | faces=list_Dio+list_L+list_Square 316 | self.launch_workers(faces) 317 | else: 318 | self.launch_workers() 319 | 320 | def launch_workers(self, adam=None): 321 | """ 322 | 主过程,根据生成的基因组,求适应值,找最佳结果 323 | 324 | Args: 325 | adam (list, optional): 初始个体. Defaults to None. 326 | """ 327 | if self.GA is None: 328 | offset_bin = copy.deepcopy(self.container) 329 | offset_bin['points'] = self.polygon_offset(self.container['points'], self.config['spacing']) 330 | self.GA = genetic_algorithm(adam, offset_bin, self.config) 331 | else: 332 | self.GA.generation() 333 | 334 | # 计算每一组基因的适应值 335 | # for i in range(0, self.GA.config['populationSize']): 336 | # res = self.find_fitness(self.GA.population[i]) 337 | # self.GA.population[i]['fitness'] = res['fitness'] 338 | # self.results.append(res) 339 | 340 | from main import batchMpiEval 341 | self.results=batchMpiEval(self.nWorker,self.GA.population) 342 | for i in range(0, self.GA.config['populationSize']): 343 | self.GA.population[i]['fitness'] = self.results[i]['fitness'] 344 | 345 | # 找最佳结果 346 | if len(self.results) > 0: 347 | best_result = self.results[0] 348 | 349 | for p in self.results: 350 | if p['fitness'] < best_result['fitness']: 351 | best_result = p 352 | 353 | if self.best is None or best_result['fitness'] < self.best['fitness']: 354 | self.best = best_result 355 | 356 | #self.results [{'placements': all_placements, 'fitness': fitness,'min_width':min_width, 'paths': paths, 'area': bin_area}] 357 | #精英 self.best 358 | #print(self.best) 359 | 360 | def clean_polygon(self, polygon): 361 | """清多边形 362 | 363 | Args: 364 | polygon ([type]): [description] 365 | 366 | Returns: 367 | [type]: [description] 368 | """ 369 | simple = pyclipper.SimplifyPolygon(polygon, pyclipper.PFT_NONZERO) 370 | 371 | if simple is None or len(simple) == 0: 372 | return None 373 | 374 | biggest = simple[0] 375 | biggest_area = pyclipper.Area(biggest) 376 | for i in range(1, len(simple)): 377 | area = abs(pyclipper.Area(simple[i])) 378 | if area > biggest_area: 379 | biggest = simple[i] 380 | biggest_area = area 381 | 382 | clean = pyclipper.CleanPolygon(biggest, self.config['curveTolerance']) 383 | if clean is None or len(clean) == 0: 384 | return None 385 | return clean 386 | 387 | 388 | from tools.calculate_npf import NFP_Calculater 389 | def find_fitness(individual,container,nfp_cache): 390 | """ 391 | 求解适应值 392 | 393 | Args: 394 | individual (dict): 个体 395 | container (dict): 容器 396 | nfp_cache (dict): nfp缓存 397 | 398 | Returns: 399 | dict: 评估结果 400 | """ 401 | place_list = copy.deepcopy(individual['placement']) 402 | rotations = copy.deepcopy(individual['rotation']) 403 | ids = [p[0] for p in place_list] 404 | 405 | for i in range(0, len(place_list)): 406 | place_list[i].append(rotations[i]) 407 | 408 | 409 | nfp_pairs = list() 410 | for i in range(0, len(place_list)): 411 | # 容器和图形的内切多边形计算 412 | part = place_list[i] 413 | key = { 414 | 'A': '-1', 415 | 'B': part[0], 416 | 'inside': True, 417 | 'A_rotation': 0, 418 | 'B_rotation': rotations[i] 419 | } 420 | 421 | tmp_json_key = json.dumps(key) 422 | if not tmp_json_key in nfp_cache: 423 | nfp_pairs.append({ 424 | 'A': container, 425 | 'B': part[1], 426 | 'key': key 427 | }) 428 | 429 | 430 | # 图形与图形之间的外切多边形计算 431 | for j in range(0, i): 432 | placed = place_list[j] 433 | key = { 434 | 'A': placed[0], 435 | 'B': part[0], 436 | 'inside': False, 437 | 'A_rotation': rotations[j], 438 | 'B_rotation': rotations[i] 439 | } 440 | tmp_json_key = json.dumps(key) 441 | if not tmp_json_key in nfp_cache: 442 | nfp_pairs.append({ 443 | 'A': placed[1], 444 | 'B': part[1], 445 | 'key': key 446 | }) 447 | pair_list = list() 448 | for pair in nfp_pairs: 449 | pair_list.append(NFP_Calculater.process_nfp(pair)) 450 | if pair_list: 451 | for i in range(0, len(pair_list)): 452 | if pair_list[i]:#{'key': pair['key'], 'value': nfp} 453 | key = json.dumps(pair_list[i]['key']) 454 | nfp_cache[key] = pair_list[i]['value']#{"pair['key']":nfp} 455 | 456 | worker = placement_worker.PlacementWorker( 457 | container, place_list, ids, rotations, ThisClass.config, nfp_cache) 458 | result=worker.place_paths() 459 | return result 460 | 461 | def draw_result(shift_data, polygons,polygons_str, bin_polygon, bin_bounds,file_path,file_id): 462 | """从结果中得到平移旋转的数据,把原始图像移到到目标地方,然后保存结果 463 | """ 464 | def myrotate_polygon(contour, angle): 465 | rotated = [] 466 | #angle = angle * math.pi / 180 467 | if angle==0: 468 | cosangle=1 469 | sinangle=0 470 | elif angle==90: 471 | cosangle=0 472 | sinangle=1 473 | elif angle==180: 474 | cosangle=-1 475 | sinangle=0 476 | elif angle==270: 477 | cosangle=0 478 | sinangle=-1 479 | for x,y in contour: 480 | rotated.append([ 481 | x *cosangle - y * sinangle, 482 | x * sinangle + y *cosangle 483 | ]) 484 | return Polygon(rotated) 485 | 486 | # 生产多边形类 487 | #print(polygons) 488 | shapes = list() 489 | for polygon in polygons: 490 | contour = [[p['x'], p['y']] for p in polygon['points']] 491 | shapes.append(Polygon(contour)) 492 | 493 | bin_shape = Polygon([[p['x'], p['y']] for p in bin_polygon['points']]) 494 | 495 | shape_area = bin_shape.area(0) 496 | 497 | solution = list() 498 | rates = list() 499 | #loops=1 500 | #print(shift_data) 501 | shapes_before=copy.deepcopy(shapes) 502 | for s_data in shift_data: 503 | #print(loops) 504 | #loops=loops+1 505 | # 一个循环代表一个容器的排版 506 | tmp_bin = list() 507 | total_area = 0.0 508 | for move_step in s_data: 509 | if move_step['rotation'] > 0:#改为大于0 510 | # 坐标原点旋转 511 | #print("before",[p for p in shapes[int(move_step['p_id'])].contour(0)]) 512 | #shapes[int(move_step['p_id'])].rotate(math.pi / 180 * move_step['rotation'], 0, 0) 513 | shapes[int(move_step['p_id'])]= myrotate_polygon(shapes[int(move_step['p_id'])].contour(0),move_step['rotation']) 514 | #print("after",[p for p in shapes[int(move_step['p_id'])].contour(0)]) 515 | #shapes[int(move_step['p_id'])]= shapes[int(move_step['p_id'])] 516 | # 平移 517 | shapes[int(move_step['p_id'])].shift(move_step['x'], move_step['y']) 518 | tmp_bin.append(shapes[int(move_step['p_id'])]) 519 | total_area += shapes[int(move_step['p_id'])].area(0) 520 | #print("total_area",total_area) 521 | # 当前排版总面积 522 | rates.append(total_area) 523 | solution.append(tmp_bin) 524 | # 显示结果 525 | idx=0 526 | myresult="" 527 | max_x=0 528 | max_y=0 529 | while(idxmax_x:max_x=x 537 | if y>max_y:max_y=y 538 | outpolygon=outpolygon+"({x},{y})".format(x=x/settings.SCALE,y=y/settings.SCALE) 539 | text=\ 540 | """In Polygon: 541 | {inpolygon} 542 | Out Polygon: 543 | {outpolygon}\n""".format(inpolygon=inpolygon,outpolygon=outpolygon) 544 | myresult=myresult+text 545 | idx=idx+1 546 | myresult=myresult.rstrip("\n") 547 | result_file=file_path+"/result_"+file_id+".txt" 548 | # import os 549 | # if os.path.exists(file_path+"/result.txt"): 550 | # i=1 551 | # flag=1 552 | # while flag: 553 | # if os.path.exists(file_path+"/result_"+str(i)+".txt"): 554 | # i=i+1 555 | # continue 556 | # result_file=file_path+"/result_"+str(i)+".txt" 557 | # flag=0 558 | with open(result_file,"w")as file_hand: 559 | file_hand.write(myresult) 560 | if settings.DEBUG: 561 | print("polygon total area:",rates[-1]/(settings.SCALE*settings.SCALE)) 562 | print("bin:",max_x/10,max_y/10) 563 | print("occupation:",rates[-1]/(max_x*max_y)) 564 | if settings.DRAWPIC: 565 | draw_polygon(solution, rates, bin_bounds, bin_shape,max_x,max_y,rates[-1]/(max_x*max_y)) 566 | 567 | 568 | def draw_polygon(solution, rates, bin_bounds, bin_shape,packed_x,packed_y,occupation): 569 | """绘制多边形 570 | 571 | Args: 572 | solution (dict): 解决方案 573 | rates (list): rates 574 | bin_bounds (dict): 容器边界 575 | bin_shape (dict): 容器 576 | packed_x (float): 打包后最大的x 577 | packed_y (float): 打包后最大的y 578 | occupation (float): 占用率 579 | """ 580 | import matplotlib.pyplot as plt 581 | import matplotlib.patches as patches 582 | base_width = 8 583 | base_height = base_width * bin_bounds['height'] / bin_bounds['width'] 584 | num_bin = len(solution) 585 | fig_height = num_bin * base_height 586 | # fig1 = Figure(figsize=(base_width, fig_height)) 587 | # FigureCanvas(fig1) 588 | fig1 = plt.figure(figsize=(base_width, fig_height)) 589 | fig1.suptitle('Polygon packing', fontweight='bold') 590 | 591 | i_pic = 1 # 记录图片的索引 592 | for shapes in solution: 593 | # 坐标设置 594 | ax = plt.subplot(num_bin, 1, i_pic, aspect='equal') 595 | # ax = fig1.set_subplot(num_bin, 1, i_pic, aspect='equal') 596 | #ax.set_title('Num %d bin, rate is %0.4f' % (i_pic, rates[i_pic-1])) 597 | ax.set_title('%0.4f,%0.4f,%0.4f'%(packed_x,packed_y,occupation)) 598 | i_pic += 1 599 | ax.set_xlim(bin_bounds['x'] - 10, bin_bounds['width'] + 50) 600 | ax.set_ylim(bin_bounds['y'] - 10, bin_bounds['height'] + 50) 601 | 602 | output_obj = list() 603 | output_obj.append(patches.Polygon(bin_shape.contour(0),fc="white")) 604 | output_obj.append(patches.Polygon([(0,0),(packed_x,0),(packed_x,packed_y),(0,packed_y)],lw=1,edgecolor='m')) 605 | #output_obj.append(patches.Polygon(bin_shape.contour(0), fc='green')) 606 | for s in shapes: 607 | color=[random.random(),random.random(),random.random()] 608 | output_obj.append(patches.Polygon(s.contour(0),color=color,alpha=0.5)) 609 | 610 | #output_obj.append(patches.Polygon(s.contour(0), fc='yellow', lw=1, edgecolor='m')) 611 | for p in output_obj: 612 | ax.add_patch(p) 613 | plt.show() 614 | # fig1.save() 615 | 616 | def content_loop_rate(best, n,file_path,file_id, loop_time=20,height=100): 617 | """固定迭代次数 618 | 619 | Args: 620 | best (dict): 最优良的个体 621 | n (NEST): 打包者 622 | file_path (str): 保存路径 623 | file_id (str): 文件id 624 | loop_time (int, optional): 迭代次数. Defaults to 20. 625 | height (int, optional): 默认高度. Defaults to 100. 626 | """ 627 | print("STOP_GENERATION",settings.STOP_GENERATION) 628 | res = best 629 | run_time = loop_time 630 | loops=1 631 | if settings.DEBUG: 632 | import time 633 | current_time=time.time() 634 | last_time=current_time 635 | generation_time=[] 636 | best_fitness_for_all_generation=[] 637 | best_fitness_for_current_generation=[] 638 | square_like_for_all_generation=[] 639 | square_like_for_current_generation=[] 640 | while run_time: 641 | #print("content_loop_rate",loops) 642 | loops=loops+1 643 | n.run() 644 | best = n.best 645 | #print (best['fitness']) 646 | if best['fitness'] <= res['fitness']: 647 | res = best 648 | #print ('change', res['fitness']) 649 | 650 | #################各代个体的评估结果############################ 651 | #self.results [{'placements': all_placements, 'fitness': fitness,'min_width':min_width, 'paths': paths, 'area': bin_area}] 652 | #精英 self.best 653 | if settings.DEBUG: 654 | current_time=time.time() 655 | generation_time.append(10*(current_time-last_time)) 656 | last_time=current_time 657 | best_fitness_for_all_generation.append(res['fitness']) 658 | best_fitness_for_current_generation.append(best['fitness']) 659 | square_like_for_all_generation.append(res['min_width']/height) 660 | square_like_for_current_generation.append(best['min_width']/height) 661 | #################################################### 662 | 663 | run_time -= 1 664 | 665 | #TODO:改 666 | if n.shapes_total_area/(best['min_width']*settings.BIN_NORMAL[2][1])>settings.SMALLCASE_EXPECTATION: 667 | #print("***",n.shapes_total_area/(best['min_width']*settings.BIN_NORMAL[2][1])) 668 | #print(n.shapes_total_area,best['min_width'],settings.BIN_NORMAL[2][1]) 669 | run_time=False 670 | 671 | if settings.DEBUG: 672 | print("best_fitness_for_all_generation",best_fitness_for_all_generation) 673 | if settings.DRAWPIC: 674 | from matplotlib import pyplot as plt 675 | from matplotlib.pyplot import MultipleLocator 676 | 677 | x = range(1,len(best_fitness_for_all_generation)+1) 678 | 679 | plt.grid(axis='x',color='0.95') 680 | plt.step(x,best_fitness_for_all_generation, label="best_fitness_for_all_generation",color='red',marker='^') 681 | plt.step(x,best_fitness_for_current_generation, label="best_fitness_for_current_generation",color='blue') 682 | plt.xlabel('generation') 683 | plt.ylabel('fitness',color='b') 684 | #ax.legend() 685 | #x_major_locator=MultipleLocator(1) 686 | #ax.xaxis.set_major_locator(x_major_locator) #设置x轴尺度 687 | 688 | plt.figure(2) 689 | plt.step(x,square_like_for_all_generation, label="square_like_for_all_generation",linestyle="--",color='red',marker='^') 690 | plt.step(x,square_like_for_current_generation, label="square_like_for_current_generation",linestyle="--",color='blue') 691 | plt.xlabel('generation') 692 | plt.ylabel('square_like',color='r') 693 | plt.title('Sample Run') 694 | 695 | plt.figure(3) 696 | plt.bar(x, generation_time, color='rgb', tick_label=x) 697 | 698 | draw_result(res['placements'], n.shapes,n.originalshapes, n.container, n.container_bounds,file_path,file_id) 699 | 700 | -------------------------------------------------------------------------------- /data/polygon_area_etc_input_11.txt: -------------------------------------------------------------------------------- 1 | Polygon: 2 | (123,324)(123,315)(121,315)(121,322)(114,322)(114,324) 3 | Polygon: 4 | (171,125)(181,125)(181,134)(171,134) 5 | Polygon: 6 | (152,315)(160,315)(160,317)(153,317)(153,325)(152,325) 7 | Polygon: 8 | (181,296)(171,296)(171,305)(181,305) 9 | Polygon: 10 | (141,145)(141,148)(133,148)(133,145)(136,145)(136,144)(137,144)(137,145) 11 | Polygon: 12 | (99,258)(95,258)(95,265)(99,265) 13 | Polygon: 14 | (191,277)(191,281)(190,281)(190,277) 15 | Polygon: 16 | (76,324)(76,315)(84,315)(84,324) 17 | Polygon: 18 | (12,277)(16,277)(16,294)(0,294)(0,290)(12,290) 19 | Polygon: 20 | (220,163)(220,168)(209,168)(209,163) 21 | Polygon: 22 | (159,161)(152,161)(152,144)(169,144)(169,148)(159,148) 23 | Polygon: 24 | (38,334)(43,334)(43,340)(38,340) 25 | Polygon: 26 | (99,125)(95,125)(95,135)(105,135)(105,133)(99,133) 27 | Polygon: 28 | (95,361)(95,353)(105,353)(105,361)(101,361)(101,364)(100,364)(100,361) 29 | Polygon: 30 | (118,283)(114,283)(114,277)(118,277) 31 | Polygon: 32 | (171,317)(175,317)(175,315)(171,315) 33 | Polygon: 34 | (230,174)(233,174)(233,163)(230,163)(230,167)(228,167)(228,169)(230,169) 35 | Polygon: 36 | (57,301)(59,301)(59,296)(57,296) 37 | Polygon: 38 | (171,355)(171,353)(173,353)(173,355) 39 | Polygon: 40 | (28,315)(19,315)(19,316)(26,316)(26,322)(28,322) 41 | Polygon: 42 | (240,258)(228,258)(228,267)(240,267) 43 | Polygon: 44 | (158,283)(158,277)(152,277)(152,283) 45 | Polygon: 46 | (6,363)(0,363)(0,353)(13,353)(13,355)(6,355) 47 | Polygon: 48 | (66,182)(57,182)(57,185)(64,185)(64,194)(66,194) 49 | Polygon: 50 | (114,230)(126,230)(126,220)(114,220) 51 | Polygon: 52 | (57,129)(57,125)(69,125)(69,129)(65,129)(65,131)(63,131)(63,129) 53 | Polygon: 54 | (83,145)(83,144)(76,144)(76,145) 55 | Polygon: 56 | (174,182)(174,183)(171,183)(171,182) 57 | Polygon: 58 | (72,220)(72,229)(67,229)(67,222)(57,222)(57,220) 59 | Polygon: 60 | (205,266)(205,258)(190,258)(190,266) 61 | Polygon: 62 | (251,239)(250,239)(250,243)(247,243)(247,249)(256,249)(256,243)(251,243) 63 | Polygon: 64 | (76,353)(84,353)(84,357)(76,357) 65 | Polygon: 66 | (1,261)(0,261)(0,258)(1,258) 67 | Polygon: 68 | (18,224)(18,220)(0,220)(0,224)(5,224)(5,227)(10,227)(10,224) 69 | Polygon: 70 | (190,315)(192,315)(192,323)(190,323) 71 | Polygon: 72 | (40,296)(38,296)(38,302)(40,302) 73 | Polygon: 74 | (82,169)(82,170)(80,170)(80,173)(76,173)(76,163)(80,163)(80,169) 75 | Polygon: 76 | (0,125)(7,125)(7,131)(0,131) 77 | Polygon: 78 | (0,144)(1,144)(1,149)(0,149) 79 | Polygon: 80 | (76,341)(76,334)(82,334)(82,341) 81 | Polygon: 82 | (107,299)(107,296)(95,296)(95,307)(101,307)(101,299) 83 | Polygon: 84 | (107,277)(107,287)(104,287)(104,279)(95,279)(95,277) 85 | Polygon: 86 | (0,334)(11,334)(11,344)(0,344) 87 | Polygon: 88 | (219,301)(219,296)(209,296)(209,301)(212,301)(212,304)(214,304)(214,301) 89 | Polygon: 90 | (171,339)(176,339)(176,334)(171,334) 91 | Polygon: 92 | (195,145)(190,145)(190,144)(195,144) 93 | Polygon: 94 | (24,301)(19,301)(19,296)(24,296) 95 | Polygon: 96 | (162,334)(166,334)(166,344)(152,344)(152,341)(162,341) 97 | Polygon: 98 | (57,277)(65,277)(65,282)(57,282) 99 | Polygon: 100 | (247,324)(247,329)(258,329)(258,315)(256,315)(256,324) 101 | Polygon: 102 | (209,334)(209,339)(215,339)(215,334) 103 | Polygon: 104 | (38,130)(38,134)(49,134)(49,125)(46,125)(46,130) 105 | Polygon: 106 | (57,206)(57,201)(62,201)(62,206) 107 | Polygon: 108 | (231,334)(228,334)(228,345)(237,345)(237,339)(231,339) 109 | Polygon: 110 | (0,239)(0,248)(1,248)(1,240)(8,240)(8,239) 111 | Polygon: 112 | (199,172)(199,163)(190,163)(190,172) 113 | Polygon: 114 | (158,163)(152,163)(152,170)(158,170)(158,168)(159,168)(159,167)(158,167) 115 | Polygon: 116 | (209,246)(211,246)(211,239)(209,239) 117 | Polygon: 118 | (19,258)(24,258)(24,263)(19,263) 119 | Polygon: 120 | (190,130)(190,134)(200,134)(200,125)(195,125)(195,130) 121 | Polygon: 122 | (247,220)(256,220)(256,221)(248,221)(248,228)(247,228) 123 | Polygon: 124 | (143,163)(143,172)(133,172)(133,163) 125 | Polygon: 126 | (216,229)(216,220)(215,220)(215,228)(209,228)(209,229) 127 | Polygon: 128 | (171,239)(181,239)(181,250)(171,250) 129 | Polygon: 130 | (190,203)(190,201)(196,201)(196,203) 131 | Polygon: 132 | (114,182)(116,182)(116,184)(114,184) 133 | Polygon: 134 | (38,243)(38,244)(38,244)(38,247)(43,247)(43,239)(38,239)(38,243) 135 | Polygon: 136 | (254,337)(247,337)(247,334)(254,334) 137 | Polygon: 138 | (95,182)(96,182)(96,184)(95,184) 139 | Polygon: 140 | (42,150)(38,150)(38,144)(42,144) 141 | Polygon: 142 | (140,135)(142,135)(142,125)(133,125)(133,127)(140,127) 143 | Polygon: 144 | (114,211)(114,201)(116,201)(116,209)(123,209)(123,211) 145 | Polygon: 146 | (133,248)(133,239)(141,239)(141,248) 147 | Polygon: 148 | (122,150)(122,148)(120,148)(120,144)(114,144)(114,156)(120,156)(120,150) 149 | Polygon: 150 | (196,182)(190,182)(190,185)(196,185) 151 | Polygon: 152 | (97,165)(95,165)(95,163)(97,163) 153 | Polygon: 154 | (157,358)(152,358)(152,353)(157,353) 155 | Polygon: 156 | (193,248)(190,248)(190,239)(200,239)(200,241)(193,241) 157 | Polygon: 158 | (44,315)(38,315)(38,321)(44,321) 159 | Polygon: 160 | (139,353)(143,353)(143,364)(133,364)(133,359)(139,359) 161 | Polygon: 162 | (60,338)(60,339)(59,339)(59,342)(57,342)(57,334)(59,334)(59,338) 163 | Polygon: 164 | (65,357)(57,357)(57,353)(65,353) 165 | Polygon: 166 | (247,144)(247,145)(250,145)(250,144) 167 | Polygon: 168 | (76,189)(80,189)(80,182)(76,182) 169 | Polygon: 170 | (156,136)(152,136)(152,125)(161,125)(161,128)(156,128) 171 | Polygon: 172 | (233,239)(233,244)(228,244)(228,239) 173 | Polygon: 174 | (137,191)(133,191)(133,182)(142,182)(142,185)(137,185) 175 | Polygon: 176 | (209,191)(209,182)(211,182)(211,190)(219,190)(219,191) 177 | Polygon: 178 | (0,201)(0,210)(9,210)(9,201) 179 | Polygon: 180 | (76,201)(76,212)(78,212)(78,203)(86,203)(86,201) 181 | Polygon: 182 | (171,277)(171,287)(183,287)(183,277) 183 | Polygon: 184 | (106,149)(106,144)(95,144)(95,149) 185 | Polygon: 186 | (0,188)(0,182)(18,182)(18,193)(12,193)(12,188) 187 | Polygon: 188 | (247,277)(255,277)(255,280)(248,280)(248,288)(247,288) 189 | Polygon: 190 | (152,211)(152,201)(165,201)(165,211) 191 | Polygon: 192 | (133,315)(133,320)(140,320)(140,315) 193 | Polygon: 194 | (25,239)(29,239)(29,255)(19,255)(19,251)(25,251) 195 | Polygon: 196 | (133,205)(133,204)(136,204)(136,201)(142,201)(142,209)(136,209)(136,205) 197 | Polygon: 198 | (232,303)(232,296)(228,296)(228,303) 199 | Polygon: 200 | (57,144)(57,145)(60,145)(60,144) 201 | Polygon: 202 | (254,206)(254,201)(247,201)(247,206) 203 | Polygon: 204 | (211,269)(209,269)(209,258)(218,258)(218,261)(211,261) 205 | Polygon: 206 | (76,277)(76,283)(83,283)(83,277) 207 | Polygon: 208 | (190,303)(190,306)(201,306)(201,296)(199,296)(199,303) 209 | Polygon: 210 | (114,170)(120,170)(120,163)(114,163) 211 | Polygon: 212 | (6,174)(0,174)(0,163)(17,163)(17,167)(6,167) 213 | Polygon: 214 | (101,239)(104,239)(104,240)(108,240)(108,246)(95,246)(95,240)(101,240) 215 | Polygon: 216 | (66,258)(57,258)(57,263)(66,263) 217 | Polygon: 218 | (114,337)(114,334)(118,334)(118,337) 219 | Polygon: 220 | (88,243)(88,242)(85,242)(85,239)(76,239)(76,247)(85,247)(85,243) 221 | Polygon: 222 | (122,296)(114,296)(114,301)(122,301) 223 | Polygon: 224 | (152,296)(153,296)(153,300)(152,300) 225 | Polygon: 226 | (24,131)(19,131)(19,125)(24,125) 227 | Polygon: 228 | (261,127)(261,125)(247,125)(247,135)(251,135)(251,127) 229 | Polygon: 230 | (152,264)(152,267)(154,267)(154,272)(159,272)(159,258)(154,258)(154,264) 231 | Polygon: 232 | (235,353)(228,353)(228,359)(235,359) 233 | Polygon: 234 | (57,163)(61,163)(61,168)(57,168) 235 | Polygon: 236 | (19,334)(29,334)(29,336)(21,336)(21,345)(19,345) 237 | Polygon: 238 | (152,233)(165,233)(165,220)(152,220) 239 | Polygon: 240 | (52,224)(52,220)(38,220)(38,224)(43,224)(43,226)(46,226)(46,224) 241 | Polygon: 242 | (120,353)(120,356)(114,356)(114,353) 243 | Polygon: 244 | (99,223)(99,220)(95,220)(95,223) 245 | Polygon: 246 | (228,149)(228,147)(233,147)(233,144)(239,144)(239,155)(233,155)(233,149) 247 | Polygon: 248 | (0,322)(8,322)(8,315)(0,315) 249 | Polygon: 250 | (190,353)(190,354)(196,354)(196,353) 251 | Polygon: 252 | (247,296)(257,296)(257,300)(249,300)(249,310)(247,310) 253 | Polygon: 254 | (190,343)(190,334)(203,334)(203,343) 255 | Polygon: 256 | (232,225)(232,223)(231,223)(231,220)(228,220)(228,232)(231,232)(231,225) 257 | Polygon: 258 | (171,163)(178,163)(178,167)(171,167) 259 | Polygon: 260 | (78,128)(76,128)(76,125)(78,125) 261 | Polygon: 262 | (200,228)(190,228)(190,227)(198,227)(198,220)(200,220) 263 | Polygon: 264 | (143,277)(133,277)(133,287)(143,287) 265 | Polygon: 266 | (101,315)(103,315)(103,317)(106,317)(106,324)(95,324)(95,317)(101,317) 267 | Polygon: 268 | (228,317)(235,317)(235,315)(228,315) 269 | Polygon: 270 | (40,354)(38,354)(38,353)(40,353) 271 | Polygon: 272 | (228,187)(233,187)(233,182)(228,182) 273 | Polygon: 274 | (176,211)(181,211)(181,201)(171,201)(171,203)(176,203) 275 | Polygon: 276 | (38,277)(46,277)(46,278)(39,278)(39,284)(38,284) 277 | Polygon: 278 | (104,334)(104,344)(95,344)(95,334) 279 | Polygon: 280 | (27,144)(27,154)(26,154)(26,146)(19,146)(19,144) 281 | Polygon: 282 | (209,325)(218,325)(218,315)(209,315) 283 | Polygon: 284 | (180,144)(171,144)(171,146)(179,146)(179,154)(180,154) 285 | Polygon: 286 | (256,267)(256,258)(247,258)(247,267) 287 | Polygon: 288 | (161,239)(161,247)(160,247)(160,240)(152,240)(152,239) 289 | Polygon: 290 | (29,353)(29,365)(19,365)(19,353) 291 | Polygon: 292 | (139,302)(133,302)(133,296)(139,296) 293 | Polygon: 294 | (95,206)(95,201)(105,201)(105,212)(102,212)(102,206) 295 | Polygon: 296 | (214,285)(209,285)(209,277)(214,277) 297 | Polygon: 298 | (234,201)(228,201)(228,213)(239,213)(239,211)(234,211) 299 | Polygon: 300 | (255,170)(260,170)(260,168)(265,168)(265,163)(247,163)(247,168)(255,168) 301 | Polygon: 302 | (133,266)(133,258)(135,258)(135,266) 303 | Polygon: 304 | (20,282)(20,277)(19,277)(19,282) 305 | Polygon: 306 | (76,296)(76,314)(78,314)(78,303)(85,303)(85,296) 307 | Polygon: 308 | (50,201)(38,201)(38,213)(50,213) 309 | Polygon: 310 | (232,288)(238,288)(238,277)(232,277)(232,280)(228,280)(228,282)(232,282) 311 | Polygon: 312 | (117,130)(114,130)(114,125)(117,125) 313 | Polygon: 314 | (114,241)(117,241)(117,239)(114,239) 315 | Polygon: 316 | (217,136)(209,136)(209,125)(217,125)(217,129)(219,129)(219,131)(217,131) 317 | Polygon: 318 | (61,239)(57,239)(57,244)(61,244) 319 | Polygon: 320 | (173,258)(173,262)(171,262)(171,258) 321 | Polygon: 322 | (122,258)(118,258)(118,260)(114,260)(114,267)(128,267)(128,260)(122,260) 323 | Polygon: 324 | (133,229)(133,220)(135,220)(135,229) 325 | Polygon: 326 | (212,202)(209,202)(209,201)(212,201) 327 | Polygon: 328 | (247,190)(247,182)(257,182)(257,189)(253,189)(253,195)(252,195)(252,190) 329 | Polygon: 330 | (209,353)(214,353)(214,360)(209,360) 331 | Polygon: 332 | (6,298)(0,298)(0,296)(6,296) 333 | Polygon: 334 | (152,188)(152,192)(156,192)(156,196)(164,196)(164,182)(156,182)(156,188) 335 | Polygon: 336 | (38,258)(38,267)(42,267)(42,258) 337 | Polygon: 338 | (38,182)(38,185)(41,185)(41,182) 339 | Polygon: 340 | (29,189)(29,192)(26,192)(26,196)(19,196)(19,182)(26,182)(26,189) 341 | Polygon: 342 | (19,201)(19,208)(24,208)(24,201) 343 | Polygon: 344 | (137,334)(137,337)(133,337)(133,334) 345 | Polygon: 346 | (76,263)(81,263)(81,258)(76,258) 347 | Polygon: 348 | (215,153)(219,153)(219,144)(209,144)(209,146)(215,146) 349 | Polygon: 350 | (38,168)(38,163)(47,163)(47,168) 351 | Polygon: 352 | (63,315)(67,315)(67,331)(57,331)(57,328)(63,328) 353 | Polygon: 354 | (19,163)(28,163)(28,165)(20,165)(20,173)(19,173) 355 | Polygon: 356 | (86,220)(76,220)(76,231)(86,231) 357 | Polygon: 358 | (28,220)(19,220)(19,221)(27,221)(27,227)(28,227) 359 | Polygon: 360 | (180,230)(180,220)(171,220)(171,230) 361 | Polygon: 362 | (233,125)(233,130)(228,130)(228,125) 363 | Polygon: 364 | (254,362)(257,362)(257,353)(247,353)(247,356)(254,356) 365 | Polygon: 366 | (80,312)(80,307)(72,307)(72,312) 367 | Polygon: 368 | (9,402)(13,402)(13,414)(0,414)(0,411)(9,411) 369 | Polygon: 370 | (126,307)(134,307)(134,314)(126,314) 371 | Polygon: 372 | (16,312)(16,307)(0,307)(0,320)(6,320)(6,312) 373 | Polygon: 374 | (162,193)(162,204)(164,204)(164,196)(171,196)(171,193) 375 | Polygon: 376 | (162,459)(162,470)(172,470)(172,459) 377 | Polygon: 378 | (90,196)(90,200)(99,200)(99,196)(95,196)(95,193)(94,193)(94,196) 379 | Polygon: 380 | (270,390)(274,390)(274,383)(270,383) 381 | Polygon: 382 | (54,271)(58,271)(58,269)(54,269) 383 | Polygon: 384 | (144,421)(152,421)(152,428)(144,428) 385 | Polygon: 386 | (224,224)(229,224)(229,212)(216,212)(216,215)(224,215) 387 | Polygon: 388 | (236,288)(242,288)(242,298)(236,298)(236,294)(234,294)(234,293)(236,293) 389 | Polygon: 390 | (206,231)(206,236)(198,236)(198,231) 391 | Polygon: 392 | (236,364)(236,369)(234,369)(234,364) 393 | Polygon: 394 | (101,391)(101,383)(90,383)(90,391) 395 | Polygon: 396 | (63,436)(67,436)(67,421)(54,421)(54,425)(63,425) 397 | Polygon: 398 | (222,231)(222,240)(216,240)(216,231) 399 | Polygon: 400 | (261,337)(265,337)(265,326)(252,326)(252,331)(261,331) 401 | Polygon: 402 | (258,391)(258,383)(252,383)(252,391) 403 | Polygon: 404 | (144,216)(144,212)(158,212)(158,225)(152,225)(152,216) 405 | Polygon: 406 | (72,421)(79,421)(79,427)(72,427) 407 | Polygon: 408 | (154,181)(154,187)(144,187)(144,174)(147,174)(147,181) 409 | Polygon: 410 | (115,259)(115,250)(108,250)(108,259) 411 | Polygon: 412 | (58,189)(54,189)(54,174)(67,174)(67,177)(58,177) 413 | Polygon: 414 | (16,273)(16,274)(10,274)(10,277)(0,277)(0,269)(10,269)(10,273) 415 | Polygon: 416 | (144,239)(144,231)(151,231)(151,239) 417 | Polygon: 418 | (18,345)(19,345)(19,351)(18,351) 419 | Polygon: 420 | (270,365)(270,371)(280,371)(280,365)(276,365)(276,364)(275,364)(275,365) 421 | Polygon: 422 | (54,329)(54,326)(61,326)(61,329) 423 | Polygon: 424 | (288,174)(288,177)(290,177)(290,174) 425 | Polygon: 426 | (188,318)(188,307)(187,307)(187,316)(180,316)(180,318) 427 | Polygon: 428 | (84,459)(72,459)(72,468)(84,468) 429 | Polygon: 430 | (275,198)(270,198)(270,193)(275,193) 431 | Polygon: 432 | (21,164)(18,164)(18,155)(31,155)(31,159)(21,159) 433 | Polygon: 434 | (252,236)(258,236)(258,231)(252,231) 435 | Polygon: 436 | (234,313)(234,307)(243,307)(243,320)(240,320)(240,313) 437 | Polygon: 438 | (28,440)(18,440)(18,455)(28,455)(28,450)(33,450)(33,446)(28,446) 439 | Polygon: 440 | (180,212)(184,212)(184,219)(180,219) 441 | Polygon: 442 | (94,250)(94,254)(90,254)(90,250) 443 | Polygon: 444 | (270,299)(286,299)(286,297)(275,297)(275,288)(270,288) 445 | Polygon: 446 | (270,451)(284,451)(284,440)(270,440) 447 | Polygon: 448 | (288,421)(301,421)(301,423)(292,423)(292,430)(288,430) 449 | Polygon: 450 | (298,269)(298,281)(288,281)(288,269) 451 | Polygon: 452 | (132,408)(132,409)(131,409)(131,413)(126,413)(126,402)(131,402)(131,408) 453 | Polygon: 454 | (310,313)(310,307)(306,307)(306,313) 455 | Polygon: 456 | (129,383)(129,385)(126,385)(126,383) 457 | Polygon: 458 | (169,364)(162,364)(162,369)(169,369) 459 | Polygon: 460 | (44,250)(47,250)(47,261)(36,261)(36,256)(44,256) 461 | Polygon: 462 | (72,174)(72,184)(74,184)(74,176)(81,176)(81,174) 463 | Polygon: 464 | (190,297)(190,288)(180,288)(180,297) 465 | Polygon: 466 | (0,212)(12,212)(12,219)(3,219)(3,229)(0,229) 467 | Polygon: 468 | (198,413)(198,402)(209,402)(209,413) 469 | Polygon: 470 | (25,174)(18,174)(18,179)(24,179)(24,189)(25,189) 471 | Polygon: 472 | (306,288)(306,299)(319,299)(319,288) 473 | Polygon: 474 | (18,383)(18,394)(22,394)(22,386)(32,386)(32,383) 475 | Polygon: 476 | (180,435)(189,435)(189,421)(180,421) 477 | Polygon: 478 | (110,307)(108,307)(108,323)(110,323)(110,318)(112,318)(112,314)(110,314) 479 | Polygon: 480 | (170,272)(170,269)(162,269)(162,272) 481 | Polygon: 482 | (180,158)(180,155)(184,155)(184,158) 483 | Polygon: 484 | (306,257)(311,257)(311,250)(306,250) 485 | Polygon: 486 | (241,358)(243,358)(243,345)(234,345)(234,348)(241,348) 487 | Polygon: 488 | (144,471)(153,471)(153,468)(146,468)(146,459)(144,459) 489 | Polygon: 490 | (281,242)(270,242)(270,231)(281,231) 491 | Polygon: 492 | (310,383)(316,383)(316,396)(310,396)(310,392)(306,392)(306,390)(310,390) 493 | Polygon: 494 | (258,155)(252,155)(252,162)(258,162) 495 | Polygon: 496 | (204,383)(198,383)(198,386)(204,386) 497 | Polygon: 498 | (72,199)(72,193)(79,193)(79,199) 499 | Polygon: 500 | (242,421)(244,421)(244,434)(234,434)(234,430)(242,430) 501 | Polygon: 502 | (72,345)(72,352)(78,352)(78,345) 503 | Polygon: 504 | (13,177)(13,174)(0,174)(0,185)(4,185)(4,177) 505 | Polygon: 506 | (78,407)(78,402)(72,402)(72,407) 507 | Polygon: 508 | (270,329)(270,326)(283,326)(283,335)(278,335)(278,329) 509 | Polygon: 510 | (18,204)(26,204)(26,201)(19,201)(19,193)(18,193) 511 | Polygon: 512 | (162,307)(162,316)(173,316)(173,307) 513 | Polygon: 514 | (180,459)(180,464)(188,464)(188,459) 515 | Polygon: 516 | (148,453)(144,453)(144,440)(154,440)(154,444)(148,444) 517 | Polygon: 518 | (252,207)(252,193)(253,193)(253,203)(259,203)(259,207) 519 | Polygon: 520 | (270,174)(282,174)(282,183)(270,183) 521 | Polygon: 522 | (185,277)(185,269)(180,269)(180,277) 523 | Polygon: 524 | (46,337)(46,341)(36,341)(36,326)(41,326)(41,337) 525 | Polygon: 526 | (306,421)(316,421)(316,427)(306,427) 527 | Polygon: 528 | (82,223)(82,227)(72,227)(72,212)(76,212)(76,223) 529 | Polygon: 530 | (258,278)(258,269)(252,269)(252,278) 531 | Polygon: 532 | (298,207)(302,207)(302,193)(288,193)(288,199)(298,199) 533 | Polygon: 534 | (23,212)(23,219)(18,219)(18,212) 535 | Polygon: 536 | (97,174)(101,174)(101,188)(90,188)(90,184)(97,184) 537 | Polygon: 538 | (81,155)(72,155)(72,161)(80,161)(80,171)(81,171) 539 | Polygon: 540 | (173,260)(173,250)(162,250)(162,260) 541 | Polygon: 542 | (5,305)(0,305)(0,288)(6,288)(6,293)(11,293)(11,297)(5,297) 543 | Polygon: 544 | (252,255)(252,250)(259,250)(259,255) 545 | Polygon: 546 | (126,292)(130,292)(130,288)(126,288) 547 | Polygon: 548 | (0,236)(6,236)(6,231)(0,231) 549 | Polygon: 550 | (152,193)(156,193)(156,204)(144,204)(144,199)(152,199) 551 | Polygon: 552 | (306,326)(306,333)(312,333)(312,326) 553 | Polygon: 554 | (100,288)(104,288)(104,299)(90,299)(90,296)(100,296) 555 | Polygon: 556 | (43,193)(36,193)(36,205)(43,205)(43,201)(46,201)(46,199)(43,199) 557 | Polygon: 558 | (184,332)(180,332)(180,326)(184,326) 559 | Polygon: 560 | (164,326)(164,330)(162,330)(162,326) 561 | Polygon: 562 | (288,326)(293,326)(293,334)(288,334) 563 | Polygon: 564 | (288,408)(288,414)(303,414)(303,402)(301,402)(301,408) 565 | Polygon: 566 | (22,256)(24,256)(24,255)(27,255)(27,250)(18,250)(18,255)(22,255) 567 | Polygon: 568 | (0,258)(0,250)(2,250)(2,258) 569 | Polygon: 570 | (126,212)(126,214)(127,214)(127,212) 571 | Polygon: 572 | (282,273)(282,269)(270,269)(270,273)(274,273)(274,277)(276,277)(276,273) 573 | Polygon: 574 | (90,345)(90,348)(96,348)(96,345) 575 | Polygon: 576 | (144,385)(147,385)(147,383)(144,383) 577 | Polygon: 578 | (18,367)(18,373)(31,373)(31,367)(27,367)(27,364)(24,364)(24,367) 579 | Polygon: 580 | (21,466)(18,466)(18,459)(21,459) 581 | Polygon: 582 | (288,234)(288,231)(291,231)(291,234) 583 | Polygon: 584 | (61,390)(54,390)(54,383)(61,383) 585 | Polygon: 586 | (187,185)(192,185)(192,174)(180,174)(180,178)(187,178) 587 | Polygon: 588 | (0,364)(0,372)(1,372)(1,365)(9,365)(9,364) 589 | Polygon: 590 | (234,449)(246,449)(246,440)(234,440) 591 | Polygon: 592 | (43,348)(43,345)(36,345)(36,348) 593 | Polygon: 594 | (144,345)(147,345)(147,348)(144,348) 595 | Polygon: 596 | (113,427)(113,421)(108,421)(108,427) 597 | Polygon: 598 | (8,193)(10,193)(10,202)(0,202)(0,200)(8,200) 599 | Polygon: 600 | (126,277)(126,269)(127,269)(127,276)(134,276)(134,277) 601 | Polygon: 602 | (252,174)(252,184)(261,184)(261,174) 603 | Polygon: 604 | (298,212)(288,212)(288,213)(296,213)(296,221)(298,221) 605 | Polygon: 606 | (315,269)(315,278)(306,278)(306,269) 607 | Polygon: 608 | (216,406)(222,406)(222,402)(216,402) 609 | Polygon: 610 | (153,276)(153,279)(144,279)(144,269)(146,269)(146,276) 611 | Polygon: 612 | (204,344)(206,344)(206,339)(210,339)(210,326)(198,326)(198,336)(204,336) 613 | Polygon: 614 | (78,372)(72,372)(72,364)(78,364) 615 | Polygon: 616 | (126,178)(128,178)(128,174)(126,174) 617 | Polygon: 618 | (12,167)(0,167)(0,164)(9,164)(9,155)(12,155) 619 | Polygon: 620 | (126,459)(126,469)(138,469)(138,459) 621 | Polygon: 622 | (162,402)(167,402)(167,410)(162,410) 623 | Polygon: 624 | (141,369)(141,364)(126,364)(126,376)(130,376)(130,369) 625 | Polygon: 626 | (242,330)(242,334)(234,334)(234,330)(237,330)(237,326)(238,326)(238,330) 627 | Polygon: 628 | (183,199)(180,199)(180,193)(183,193) 629 | Polygon: 630 | (57,250)(54,250)(54,251)(57,251) 631 | Polygon: 632 | (72,262)(72,250)(73,250)(73,259)(80,259)(80,262) 633 | Polygon: 634 | (126,345)(126,355)(136,355)(136,345) 635 | Polygon: 636 | (23,236)(25,236)(25,234)(28,234)(28,231)(18,231)(18,234)(23,234) 637 | Polygon: 638 | (56,201)(56,193)(54,193)(54,201) 639 | Polygon: 640 | (216,271)(216,269)(217,269)(217,271) 641 | Polygon: 642 | (90,444)(90,440)(100,440)(100,444)(97,444)(97,447)(95,447)(95,444) 643 | Polygon: 644 | (76,269)(72,269)(72,276)(76,276) 645 | Polygon: 646 | (274,307)(270,307)(270,309)(274,309) 647 | Polygon: 648 | (216,202)(221,202)(221,193)(216,193) 649 | Polygon: 650 | (60,173)(65,173)(65,155)(54,155)(54,159)(60,159) 651 | Polygon: 652 | (221,174)(221,179)(216,179)(216,174) 653 | Polygon: 654 | (288,217)(288,222)(270,222)(270,212)(278,212)(278,217) 655 | Polygon: 656 | (293,155)(288,155)(288,159)(293,159) 657 | Polygon: 658 | (234,386)(234,383)(243,383)(243,392)(240,392)(240,386) 659 | Polygon: 660 | (42,307)(40,307)(40,309)(36,309)(36,313)(47,313)(47,309)(42,309) 661 | Polygon: 662 | (116,212)(108,212)(108,215)(116,215) 663 | Polygon: 664 | (54,366)(54,364)(56,364)(56,366) 665 | Polygon: 666 | (204,371)(206,371)(206,368)(210,368)(210,364)(198,364)(198,368)(204,368) 667 | Polygon: 668 | (108,326)(115,326)(115,333)(108,333) 669 | Polygon: 670 | (92,161)(90,161)(90,155)(92,155) 671 | Polygon: 672 | (306,181)(306,174)(311,174)(311,181) 673 | Polygon: 674 | (252,425)(252,421)(264,421)(264,432)(261,432)(261,425) 675 | Polygon: 676 | (168,174)(162,174)(162,183)(168,183)(168,179)(171,179)(171,178)(168,178) 677 | Polygon: 678 | (313,155)(313,159)(306,159)(306,155) 679 | Polygon: 680 | (306,345)(306,349)(308,349)(308,345) 681 | Polygon: 682 | (306,193)(318,193)(318,197)(309,197)(309,207)(306,207) 683 | Polygon: 684 | (270,250)(280,250)(280,263)(270,263) 685 | Polygon: 686 | (180,231)(180,240)(182,240)(182,232)(190,232)(190,231) 687 | Polygon: 688 | (9,459)(9,468)(0,468)(0,459) 689 | Polygon: 690 | (185,383)(180,383)(180,389)(185,389) 691 | Polygon: 692 | (205,250)(207,250)(207,260)(198,260)(198,256)(205,256) 693 | Polygon: 694 | (198,350)(198,345)(203,345)(203,350) 695 | Polygon: 696 | (113,167)(117,167)(117,155)(108,155)(108,157)(113,157) 697 | Polygon: 698 | (54,307)(54,312)(62,312)(62,307) 699 | Polygon: 700 | (57,212)(54,212)(54,224)(63,224)(63,221)(57,221) 701 | Polygon: 702 | (258,295)(260,295)(260,293)(263,293)(263,288)(252,288)(252,293)(258,293) 703 | Polygon: 704 | (276,155)(270,155)(270,157)(276,157) 705 | Polygon: 706 | (108,383)(109,383)(109,384)(108,384) 707 | Polygon: 708 | (42,421)(44,421)(44,422)(47,422)(47,426)(36,426)(36,422)(42,422) 709 | Polygon: 710 | (18,406)(24,406)(24,402)(18,402) 711 | Polygon: 712 | (37,443)(36,443)(36,440)(37,440) 713 | Polygon: 714 | (81,297)(72,297)(72,296)(80,296)(80,288)(81,288) 715 | Polygon: 716 | (234,231)(234,240)(243,240)(243,231) 717 | Polygon: 718 | (225,307)(225,315)(224,315)(224,308)(216,308)(216,307) 719 | Polygon: 720 | (153,364)(144,364)(144,375)(153,375) 721 | Polygon: 722 | (208,459)(208,464)(198,464)(198,459) 723 | Polygon: 724 | (198,427)(198,433)(214,433)(214,421)(209,421)(209,427) 725 | Polygon: 726 | (90,307)(90,317)(95,317)(95,309)(105,309)(105,307) 727 | Polygon: 728 | (155,416)(144,416)(144,402)(155,402) 729 | Polygon: 730 | (90,468)(101,468)(101,467)(92,467)(92,459)(90,459) 731 | Polygon: 732 | (126,440)(137,440)(137,449)(126,449) 733 | Polygon: 734 | (108,278)(121,278)(121,277)(112,277)(112,269)(108,269) 735 | Polygon: 736 | (306,231)(306,242)(319,242)(319,231) 737 | Polygon: 738 | (137,242)(126,242)(126,240)(134,240)(134,231)(137,231) 739 | Polygon: 740 | (120,204)(108,204)(108,193)(120,193) 741 | Polygon: 742 | (288,268)(302,268)(302,261)(292,261)(292,250)(288,250) 743 | Polygon: 744 | (47,471)(36,471)(36,459)(47,459) 745 | Polygon: 746 | (317,374)(317,364)(315,364)(315,372)(306,372)(306,374) 747 | Polygon: 748 | (208,222)(208,212)(198,212)(198,222) 749 | Polygon: 750 | (252,212)(252,227)(253,227)(253,217)(260,217)(260,212) 751 | Polygon: 752 | (0,383)(11,383)(11,394)(0,394) 753 | Polygon: 754 | (170,155)(170,162)(169,162)(169,156)(162,156)(162,155) 755 | Polygon: 756 | (47,231)(36,231)(36,242)(47,242) 757 | Polygon: 758 | (216,257)(221,257)(221,250)(216,250) 759 | Polygon: 760 | (146,166)(144,166)(144,155)(154,155)(154,157)(146,157) 761 | Polygon: 762 | (216,288)(216,301)(218,301)(218,291)(227,291)(227,288) 763 | Polygon: 764 | (105,269)(90,269)(90,279)(105,279) 765 | Polygon: 766 | (0,335)(15,335)(15,334)(5,334)(5,326)(0,326) 767 | Polygon: 768 | (317,451)(306,451)(306,440)(317,440) 769 | Polygon: 770 | (293,307)(291,307)(291,309)(288,309)(288,312)(299,312)(299,309)(293,309) 771 | Polygon: 772 | (54,237)(54,231)(56,231)(56,237) 773 | Polygon: 774 | (181,402)(181,403)(180,403)(180,402) 775 | Polygon: 776 | (0,445)(0,440)(5,440)(5,445) 777 | Polygon: 778 | (219,440)(216,440)(216,449)(225,449)(225,445)(219,445) 779 | Polygon: 780 | (258,402)(260,402)(260,404)(263,404)(263,408)(252,408)(252,404)(258,404) 781 | Polygon: 782 | (113,465)(113,459)(108,459)(108,465) 783 | Polygon: 784 | (37,212)(36,212)(36,216)(37,216) 785 | Polygon: 786 | (222,358)(216,358)(216,345)(222,345)(222,349)(224,349)(224,351)(222,351) 787 | Polygon: 788 | (288,346)(288,345)(295,345)(295,346) 789 | Polygon: 790 | (288,367)(289,367)(289,364)(288,364) 791 | Polygon: 792 | (234,217)(234,219)(235,219)(235,222)(237,222)(237,212)(235,212)(235,217) 793 | Polygon: 794 | (222,329)(216,329)(216,326)(222,326) 795 | Polygon: 796 | (162,421)(163,421)(163,423)(162,423) 797 | Polygon: 798 | (148,293)(144,293)(144,288)(148,288) 799 | Polygon: 800 | (162,234)(162,231)(171,231)(171,240)(169,240)(169,234) 801 | Polygon: 802 | (207,193)(207,202)(205,202)(205,194)(198,194)(198,193) 803 | Polygon: 804 | (162,392)(162,383)(174,383)(174,392) 805 | Polygon: 806 | (101,327)(101,326)(90,326)(90,327)(94,327)(94,328)(96,328)(96,327) 807 | Polygon: 808 | (93,231)(90,231)(90,239)(93,239) 809 | Polygon: 810 | (36,288)(36,291)(38,291)(38,288) 811 | Polygon: 812 | (252,345)(252,350)(257,350)(257,345) 813 | Polygon: 814 | (119,366)(119,364)(108,364)(108,373)(110,373)(110,366) 815 | Polygon: 816 | (207,307)(198,307)(198,308)(206,308)(206,315)(207,315) 817 | Polygon: 818 | (54,468)(54,459)(65,459)(65,468) 819 | Polygon: 820 | (18,274)(23,274)(23,269)(18,269) 821 | Polygon: 822 | (36,370)(36,373)(45,373)(45,364)(43,364)(43,370) 823 | Polygon: 824 | (297,288)(297,296)(295,296)(295,289)(288,289)(288,288) 825 | Polygon: 826 | (134,335)(134,326)(126,326)(126,335) 827 | Polygon: 828 | (180,373)(180,364)(184,364)(184,372)(193,372)(193,373) 829 | Polygon: 830 | (234,164)(234,155)(247,155)(247,164) 831 | Polygon: 832 | (185,345)(180,345)(180,350)(185,350) 833 | Polygon: 834 | (54,291)(54,288)(70,288)(70,297)(63,297)(63,291) 835 | Polygon: 836 | (256,376)(255,376)(255,372)(252,372)(252,364)(260,364)(260,372)(256,372) 837 | Polygon: 838 | (170,440)(170,447)(162,447)(162,440) 839 | Polygon: 840 | (306,402)(306,403)(313,403)(313,402) 841 | Polygon: 842 | (22,329)(23,329)(23,328)(25,328)(25,326)(18,326)(18,328)(22,328) 843 | Polygon: 844 | (257,448)(257,440)(252,440)(252,448) 845 | Polygon: 846 | (239,276)(237,276)(237,274)(234,274)(234,269)(244,269)(244,274)(239,274) 847 | Polygon: 848 | (204,176)(198,176)(198,174)(204,174) 849 | Polygon: 850 | (36,269)(36,270)(37,270)(37,269) 851 | Polygon: 852 | (219,155)(216,155)(216,163)(219,163) 853 | Polygon: 854 | (216,422)(219,422)(219,421)(216,421) 855 | Polygon: 856 | (90,374)(99,374)(99,372)(91,372)(91,364)(90,364) 857 | Polygon: 858 | (90,411)(90,402)(99,402)(99,411) 859 | Polygon: 860 | (315,212)(306,212)(306,213)(314,213)(314,219)(315,219) 861 | Polygon: 862 | (108,183)(108,174)(117,174)(117,183) 863 | Polygon: 864 | (90,421)(94,421)(94,426)(90,426) 865 | Polygon: 866 | (216,369)(216,364)(225,364)(225,373)(223,373)(223,369) 867 | Polygon: 868 | (181,250)(184,250)(184,262)(181,262)(181,258)(180,258)(180,256)(181,256) 869 | Polygon: 870 | (0,421)(2,421)(2,427)(0,427) 871 | Polygon: 872 | (126,252)(126,250)(128,250)(128,252) 873 | Polygon: 874 | (126,155)(131,155)(131,160)(126,160) 875 | Polygon: 876 | (119,445)(119,440)(108,440)(108,450)(110,450)(110,445) 877 | Polygon: 878 | (36,407)(36,402)(41,402)(41,407) 879 | Polygon: 880 | (270,426)(270,431)(279,431)(279,421)(275,421)(275,426) 881 | Polygon: 882 | (252,307)(257,307)(257,312)(252,312) 883 | Polygon: 884 | (113,345)(118,345)(118,355)(108,355)(108,351)(113,351) 885 | Polygon: 886 | (0,353)(9,353)(9,352)(2,352)(2,345)(0,345) 887 | Polygon: 888 | (82,334)(82,326)(72,326)(72,334) 889 | Polygon: 890 | (242,203)(234,203)(234,201)(241,201)(241,193)(242,193) 891 | Polygon: 892 | (82,451)(72,451)(72,440)(82,440) 893 | Polygon: 894 | (203,295)(198,295)(198,288)(203,288) 895 | Polygon: 896 | (114,288)(117,288)(117,300)(108,300)(108,296)(114,296) 897 | Polygon: 898 | (27,288)(18,288)(18,290)(26,290)(26,297)(27,297) 899 | Polygon: 900 | (198,165)(198,155)(210,155)(210,165) 901 | Polygon: 902 | (18,307)(23,307)(23,315)(18,315) 903 | Polygon: 904 | (234,257)(234,259)(247,259)(247,250)(245,250)(245,257) 905 | Polygon: 906 | (236,412)(240,412)(240,402)(236,402)(236,406)(234,406)(234,407)(236,407) 907 | Polygon: 908 | (37,181)(36,181)(36,174)(37,174) 909 | Polygon: 910 | (164,213)(164,212)(162,212)(162,213) 911 | Polygon: 912 | (72,231)(81,231)(81,232)(73,232)(73,238)(72,238) 913 | Polygon: 914 | (18,421)(18,431)(29,431)(29,421) 915 | Polygon: 916 | (198,453)(198,440)(202,440)(202,450)(211,450)(211,453) 917 | Polygon: 918 | (173,288)(173,300)(162,300)(162,288) 919 | Polygon: 920 | (64,451)(64,440)(54,440)(54,451) 921 | Polygon: 922 | (111,245)(108,245)(108,231)(123,231)(123,234)(111,234) 923 | Polygon: 924 | (126,421)(140,421)(140,425)(130,425)(130,436)(126,436) 925 | Polygon: 926 | (47,398)(36,398)(36,383)(47,383) 927 | Polygon: 928 | (144,259)(144,250)(150,250)(150,258)(161,258)(161,259) 929 | Polygon: 930 | (229,383)(229,396)(216,396)(216,383) 931 | Polygon: 932 | (197,440)(197,449)(191,449)(191,441)(180,441)(180,440) 933 | Polygon: 934 | (63,358)(54,358)(54,345)(63,345) 935 | Polygon: 936 | (90,212)(90,217)(102,217)(102,212) 937 | Polygon: 938 | (216,272)(216,269)(198,269)(198,278)(200,278)(200,272) 939 | Polygon: 940 | (144,332)(144,330)(151,330)(151,326)(161,326)(161,337)(153,337)(153,332) 941 | Polygon: 942 | (278,354)(270,354)(270,345)(278,345) 943 | Polygon: 944 | (144,307)(144,309)(150,309)(150,307) 945 | Polygon: 946 | (116,402)(108,402)(108,415)(116,415) 947 | Polygon: 948 | (180,358)(180,362)(162,362)(162,345)(167,345)(167,358) 949 | Polygon: 950 | (288,392)(288,383)(294,383)(294,390)(306,390)(306,392) 951 | Polygon: 952 | (247,182)(247,174)(234,174)(234,182) 953 | Polygon: 954 | (54,402)(59,402)(59,408)(54,408) 955 | Polygon: 956 | (90,388)(90,393)(72,393)(72,383)(79,383)(79,388) 957 | Polygon: 958 | (49,161)(49,164)(43,164)(43,169)(36,169)(36,155)(43,155)(43,161) 959 | Polygon: 960 | (270,402)(270,411)(279,411)(279,402) 961 | Polygon: 962 | (288,440)(292,440)(292,448)(288,448) 963 | Polygon: 964 | (126,206)(135,206)(135,193)(126,193) 965 | Polygon: 966 | (216,462)(216,459)(234,459)(234,476)(232,476)(232,462) 967 | --------------------------------------------------------------------------------