Git Product home page Git Product logo

2d-irregular-packing-algorithm's Introduction

Hi there 👋

I am a PhD student studying in the Department of Industrial Systems Engineering and Management, National University of Singapore.

Currently, my research interests mainly concern optimization and management in transportation research. Vist my homepage.

If you have anything question about my repositories, welcome to email [email protected].

GitHub Stats

2d-irregular-packing-algorithm's People

Contributors

prinway avatar seanys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

2d-irregular-packing-algorithm's Issues

python ga.py fails often

hit enter before done
changes currently made

gravity_lowest.py
for i in range(1,len(polygons)):
for i in range(1,len(self.polygons)):

nfp.py
inter=Polygon(self.sliding).intersection(Polygon(self.stationary))
+print(inter)

error:

POLYGON EMPTY
Traceback (most recent call last):
File "ga.py", line 205, in
bestSequence=geneticAlgorithm(population=polyList, popSize=10, eliteSize=5, mutationRate=0.1, generations=3)
File "ga.py", line 143, in geneticAlgorithm
pop,popRanked = nextGeneration(pop, eliteSize, mutationRate)
File "ga.py", line 127, in nextGeneration
popRanked = rankSequences(currentGen) # 获得子代
File "ga.py", line 39, in rankSequences
fitnessResults[i] = Fitness(population[i]) # index和fitness共同排序
File "ga.py", line 17, in Fitness
pp=GravityLowestAlgorithm(sequence).start()
File "/home/ /gravity_lowest.py", line 20, in start
self.placePoly(i)
File "/home/ /gravity_lowest.py", line 58, in placePoly
nfp=NFP(main,adjoin).nfp
File "/home/ /nfp.py", line 22, in init
self.main()
File "/home/ /nfp.py", line 61, in main
if geoFunc.computeInterArea(mapping(inter))>1:
File "/home/ /geo_func.py", line 51, in computeInterArea
poly=inter["coordinates"][0]
IndexError: tuple index out of range

this is shapely.Polygon.intersection != geo_func.py

inter=Polygon(self.sliding).intersection(Polygon(self.stationary))

from shapely docs:

Note

These methods will always return a geometric object. An intersection of disjoint geometries for example will return an empty GeometryCollection, not None or False. To test for a non-empty result, use the geometry’s is_empty property.

in just python

from shapely.geometry import Polygon,Point,mapping,LineString
stationary= [[1083.333333333333, 433.3333333333335], [1283.3333333333333, 433.3333333333335], [1383.3333333333333, 533.3333333333335], [1383.3333333333333, 733.3333333333334], [1283.3333333333333, 833.3333333333334], [1083.333333333333, 833.3333333333334], [983.3333333333331, 733.3333333333334], [983.3333333333331, 533.3333333333335]]
sliding = [[983.3333333333331, -16.66666666666646], [1183.333333333333, 83.33333333333354], [1383.3333333333333, -16.66666666666646], [1283.3333333333333, 183.33333333333343], [1383.3333333333333, 483.3333333333334], [1183.333333333333, 383.3333333333334], [983.3333333333331, 483.3333333333334], [1083.333333333333, 283.3333333333334]]
inter=Polygon(sliding).intersection(Polygon(stationary))
print(inter)
POLYGON EMPTY

Blf.contain_length does not always equals to Global_lowest_length

After the Genetic Algorithm has finished, the global_best_sequence is loaded into another BottomLeftFillobject - i guess for plotting purpose. However, changing

blf=BottomLeftFill(self.width,PolyListProcessor.getPolysVertices(self.global_best_sequence),NFPAssistant=self.NFPAssistant)
blf.showAll()

in genetic_algorithm.py into

blf=BottomLeftFill(self.width,PolyListProcessor.getPolysVertices(self.global_best_sequence),NFPAssistant=self.NFPAssistant)
assert self.global_lowest_length == blf.contain_length
blf.showAll()

I think the problem might come from the fact that in line 88 self.getNextGeneration() is called after self.getLengthRanked(). That is, entries in self.pop might be modified by self.getNextGeneration() right before self.global_best_sequence is set to the gen with the lowest fitness. I tried to solve this by calling self.getLengthRanked() right after
self.getNextGeneration() again.

License

Hi,

I noticed there's no license indicated for this project. Could that be updated so I can decide whether I can use this?

Kind regards

Error computing NFP

Hi, I'm creating my own irregular packing (online) algorithm for my Bachelor's thesis and want to use your implementations in my benchmarks for comparison.

However, when trying to compute NFP in nfp_test.py using poly1=json.loads(df['polygon'][11]) and poly2=json.loads(df['polygon'][14]) from my crystals.csv dataset, it writes "出现相交区域". It happens only in combination of those 2 polygons, combinations of any other polygons are without error.
This is probably the reason why I get "没有计算出可行向量" and "出现相交区域" during running any packing algorithms with my dataset.

crystals.txt
(The file is .txt because Github doesn't allow .csv files)

EDIT: Looks like removing those 2 polygons + this: 2,"[[0.0, 0.0], [10.667, 55.333], [-33.333, 65.333], [-51.333, 58.0], [-66.667, 12.666], [-48.667, -10.0], [-38.667, -5.334], [-28.667, -8.0], [-12.0, 2.0]]" makes your algorithms run without errors.

Library language - Chinese vs english

All comments in code are in Chinese. Would it be possible to translate these so that we people on the other side of the planet could use the library too? ;) I think possibly both languages could be present side by side at least in function docs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.