• Post Reply Bookmark Topic Watch Topic
  • New Topic
permaculture forums growies critters building homesteading energy monies kitchen purity ungarbage community wilderness fiber arts art permaculture artisans regional education skip experiences global resources cider press projects digital market permies.com pie forums private forums all forums
this forum made possible by our volunteer staff, including ...
master stewards:
  • Anne Miller
  • jordan barton
  • Pearl Sutton
  • r ranson
  • Nicole Alderman
  • Greg Martin
  • Steve Thorn
stewards:
  • paul wheaton
  • Leigh Tate
  • Mike Haasl
master gardeners:
  • John F Dean
gardeners:
  • Carla Burke
  • Stacie Kim
  • Jay Angler

Why there is not a software solution to find optimal planting layouts for plots/beds/guilds.

 
pollinator
Posts: 253
Location: USDA Zone 8b
43
monies foraging books medical herbs homestead
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you ever wished you had design software that could magically generate a garden/plot layout for you? What about one that takes into account spacing and companion planting of each plant?

After all in practice whether on paper, manually in software or right in the dirt we can generally tell where something should go just by using our human brains.
So why is there not a neat piece of software that creates a layout all perfectly measured with plants next to their companions all with the press of a button? Sounds simple right?

Well I tried....here is what I learned; lets break down the problem.

The parameters:

-Let's let "r" represent the radius of a plant; being the distance it should be planted away from another plant of its kind.

-And lets say we want rectangular plots we will then have the parameters of length "x" and width "y" these will be the bounding coordinates that we want to plant in.

-Now plants should be represented as circles because root systems don't necessarily grow in just 4 directions like a square. So we will use the expression of (Pi * r^2) for the area of a plant.

-For the rectangular plot we need to find the area so we use the expression of simply (x * y) lets call this variable "a".

-We will let "n" represent the number of plants we want in our plot and "t" be the total area of all the plants.

-Also for each plant we need to keep track of its distance & relationship relative to every other plant.

Goals:

We need to do the following things with those parameters..

A) Find if the total area of of plants fits within the area of the plot. If not there is not an optimal solution. Easy enough if a - (n* t) >= 0 then we can fit the plants in the plot and can proceed to B.

B) Figure out how in the world you fit a bunch of differently sized circles into a rectangle using up as much space as possible while keeping some sort of orientation for companion benefits...

Goal B?
Ok so how is that done? Well here we have run into what's called a packing problem. Specifically a circle packing problem more specifically an unequal circle packing problem (unless you are planting a monoculture). In computer science this problem is considered NP hard.

When it comes to packing problems there are quite a few we have found proven algorithms for, such as packing uniform circles in a square although there isn't really a one size fits all algorithm for every case, for example after a certain number of circles it ceases to be optimal See wikipedia

Of course our goal would be to pack unequal circles into a rectangle for this problem there are a few research papers but these may only address the packing of unequal circles but likely not with the relationship of companion planting kept in mind which adds another big problem on top of unequal circle packing.

This means a whole new algorithm to solve a likely one-off very difficult problem in not just computer science but in geometry in general, I would have to write a research paper like "Simultaneous sorting & packing of circles within rectangles" or something. Not to mention calculation Pi for all the circles, all the distance/angle checks would get computationally expensive.

So why pack unequal circles into a rectangle?

You are probably thinking "ok find another "less optimal" solution I don't measure my garden with a ruler anyways lol". But unequal circles are the best representation for the plant in 2D space.

Alright there are a few alternative solutions to choose from:

1) Pack the circles into a circle or square instead of a rectangle, this would leave the relationship issue to be solved but would use much more researched algorithms.

2) Represent the plant with a square instead, square packing algorithms are much more researched and used in digital industries and include simpler implementations such as the Greedy Packing algorithm. Personally I have implemented this for another project and it was still a pain in the butt.

3) You may want to sort the plants by their neighbors/companions then arrange them in that order, for example along a linear line/curve/path, however this would not account for rows or better offset rows like in permaculture and would only be separated by distance and in a fixed order of relation.

3b) Take the 3rd option and figure out positioning in a grid and try and take into account the above and below rows and shift entire rows to try and find an optimal distance/companion relationship between each layer.

4) AI, have AI mimic human thought and try to figure out where everything should fit.


The problem with all these solutions is that none of them would be theoretically as optimal as packing circles in a convex polygon such as a rectangle. This just means your software would not output a perfect optimally spaced coherent garden plan for you to look at. But they would get pretty close and probably better than we could do by hand anyway.



TL;DR Not all problems in geometry and mathematics have actually been solved including many packing problems, which would be required to write code for something like this. Mathematically perfect garden plans require more research.


 
pollinator
Posts: 1642
Location: Canadian Prairies - Zone 3b
428
  • Likes 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's interesting to try to capture all the variables in one place. Our current system is horribly inefficient, deploying independently mobile sensor units with rather unreliable memory systems but possessing unique data processing capabilities that seem to defy current mathematical constructs, and a wholly irrational tendency to repeat variations of the same experiments endlessly. Surely there is a better way.

I kid, sir. I kid
 
T Simpson
pollinator
Posts: 253
Location: USDA Zone 8b
43
monies foraging books medical herbs homestead
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could also not plan at all and just seed bomb your yard. lol

Edit: just be sure to calculate the trajectory of each seed so they land perfectly spaced. XD
 
pollinator
Posts: 2002
Location: Denmark 57N
503
fungi foraging trees cooking food preservation
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problems just get worse the more you think about it, plants size depends on their neighbours so your circles would need to grow or shrink depending on the neighbouring plants. For example we had a rhubarb plant (a lovely circular plant) growing under alder trees, it was about 3ft wide. we moved it into a good sunny spot and it grew to 8ft Ø.
Now Rhubarb is a nice stand alone plant that nothing can grow under, but other plants are not, You can easily grow something shade loving under fennel for example so some circles but not all could overlap.
Also height no good putting the tall plants in the south of the garden and casting shade on everything all day. (reverse for your hemisphere/climate)
 
pollinator
Posts: 784
Location: Thunder Bay, Ontario, Canada
117
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like you said, you aren't looking for THE optimum solution.

When a human goes about planting a bed, they have a primary plant in mind for a given area, and then support plants. So we tend to assign some form of weighting / ranking system to each type of plant, beginning with the highest ranked plant and filling in the available space.

My initial approach would be a greedy algorithm based on the weighting previously assigned to each plant type in the compatibility set.  I would also make use of a randomizing element that makes sure the packing isn't 100% optimal and there is more space left available for the lower weighted plants. That randomizing element will influence the overall balance of species, and at some point you may wish to replace it as a preset or configurable variable. Either way, it is necessary to avoid a "monocrop with a few extras" scenarios.

Once I had that basic approach more or less working and verified it does as I expected. I would start focusing on making that randomizing element more sophisticated. For example, an auto-tune / sweep algorithm that runs the packing algorithm over and over, each time incrementally changing this variable until the closest result to a target blend of species representation was achieved.

Another approach entirely:
Each plant species has an optimal growing density that can be represented by a grid. Starting with the largest grid spacing from the set of grids that are selected based on the plant species and working to the smallest, find the rotation angle of each grid such that when overlaid on the grow bed, the number of bisecting lines is maximized.

This provides the maximum number of each type of plant that can fit in the bed and is pretty quick using some matrix arithmetic.

Now start stacking each grid as a layer on top of the base garden bed shape and since we're really only interested in where the lines bisect, we can represent them as a set of points. As you do so, you will need to make a decision about what to do when a point gets closer to another previously laid down point by a previously determined threshold. Answering the question "do I remove the existing point, or do I not place this point" is where the real complexity lies, but hopefully this is enough info to communicate the concept.

Good luck!
 
T Simpson
pollinator
Posts: 253
Location: USDA Zone 8b
43
monies foraging books medical herbs homestead
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another method could be to sort the plants by relation and start with adding a plant in a corner offset by the maximum radius that a plant would grow to. Then sweep through the list of plants and simulate the growth from the minimum spacing of the plant in a monoculture to the radius it would reach in maturity + the offset of its neighboring minimum radius until there is no more space.

The challenge is making sure you can fit all the plants you want into the space. So you would then have to weigh the plants so that if there is not enough room for the next plants in the list you don't allow room for certain plants to be spaced for their maximum radius.

Kind of like an octree.



Could also try and use a Voroni or Julia/fractal pattern and place the plants sorted by scale and linear relation along nodes in descending order, probably not the best design but it would look cool.
 
Posts: 142
49
  • Likes 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A final consideration is diminishing rate of return. At some point, the calories consumed by a human brain running overclocked trying to figure a means of squeezing those last couple plants into the space will exceed the caloric value of said plants.
 
Douglas Alpenstock
pollinator
Posts: 1642
Location: Canadian Prairies - Zone 3b
428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Optimizing is an interesting exercise. Though without regional soil and climate inputs into the model, I can't see a path to implementing the results. Even with those inputs providing an broad approximation, I find it takes a year of observant eyes and boots on the ground in all seasons to find the starting line for a specific site. My 2c.
 
T Simpson
pollinator
Posts: 253
Location: USDA Zone 8b
43
monies foraging books medical herbs homestead
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Douglas Alpenstock wrote:Optimizing is an interesting exercise. Though without regional soil and climate inputs into the model, I can't see a path to implementing the results. Even with those inputs providing an broad approximation, I find it takes a year of observant eyes and boots on the ground in all seasons to find the starting line for a specific site. My 2c.



I suppose it is assumed that for the garden bed you are planting in you already know the soil PH and climate location so you only input plant that you know would grow there.

Approximations would have to to made no matter the model used, such as a plant's distance as to not compete for resources and the maximum radius a plant can grow to cover. There is to much variation in nature for those data points to be accurate.

This would more be to serve as a tool for creating digital representations of of guilds/beds for use in design than actual instructions. Though actual instructions would be really cool haha.
 
Posts: 616
Location: Abkhazia · Cfa (humid subtropical) - temperate · clay soil
76
cat forest garden trees solar wood heat woodworking
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Having written optimizers for far easier and well-defined problems, I'd rather just plant what I want. Much faster than trying to input all variables (soil, water, sun, wind) over time.
 
please buy my thing and then I'll have more money:
Permaculture Voices 1, 2 and 3 - all 117 hours of video!
https://permies.com/t/voices123
reply
    Bookmark Topic Watch Topic
  • New Topic