Fournier Transform ?

41 views
Skip to first unread message

Nicolas Sprotti

unread,
Sep 23, 2021, 11:06:07 AM9/23/21
to 'Suhas Parandekar' via netlogo-users
Hi everyone,

I am working on a supply chain replenishment simulation to better control inventory level at every nodes without the need to maintain accurate inventory on hand (labor consuming). Each turtles is a node in the supply chain with their dedicated inventory level.
The approach is to look at the inventory level as a cyclical pattern function of sales velocity, case pack and delivery schedule.

The thinking is to apply the Fourier Transform to extract these info and suggest to proper quantity to replenish from there.

Any idea or model leveraging a Fourier you've heard of I could look into ?
I've done some research. No luck.

Thank you !
Nico

Michael Tamillow

unread,
Sep 23, 2021, 11:58:37 AM9/23/21
to Nicolas Sprotti, 'Suhas Parandekar' via netlogo-users
So, each turtle would individually be making decisions off the global inventory modeled by the Fourier transform?

Sent from my iPhone

On Sep 23, 2021, at 10:06 AM, Nicolas Sprotti <nicolas...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/Mailbird-5bbd2372-9876-4ec3-969a-6dade81c3353%40gmail.com.

Nicolas Sprotti

unread,
Sep 23, 2021, 12:06:57 PM9/23/21
to Michael Tamillow, 'Suhas Parandekar' via netlogo-users
Thank you Michael.

Each turtle or node within the supply chain make their own decision (quantity to re-order) based on their own demand (to be maybe transform with Fourier), not based on the overall inventory available. It is pure pull : this is what I need based on my demand type of thing.

When put together the overall phenomena we are addressing is what is known in supply chain as the bullwhip effect (why did we have 3 months of toilet paper shortage in the world while in reality the "velocity" of the toilet paper usage didn't change much type of thing).

Michael Tamillow

unread,
Sep 23, 2021, 4:31:42 PM9/23/21
to Nicolas Sprotti, 'Suhas Parandekar' via netlogo-users
Well that’s an easy question to answer, and it is highly correlated with the fact that everyone seemed to gain 20 - 50 lbs overnight and liquor sales spiked 50% immediately with the evaporation of toilet paper supplies. Everyone was pooping their brains out as they ate and drank away their problems and wallowed in self pity at the end of the world. Of course the ending of the story is that when the world did not end they were shocked and confused and in fear of showing their faces for their selfish gluttony, they covered them in masks and demanded we all do so, so that we could not differentiate between the cowards and the courageous. 

I for one did not need toilet paper, because I lost ten pounds immediately as I could not eat and did not poop in response to the thought that the whole world had gone chaotic in the selfish sort of barbarous way Tom Hobbes warned of. Unlike Tom Hobbes, I do not believe that more centralized control and abuse of authority will protect us from this side of people, quite the opposite. People must expose themselves to the risk of death from their friends and relatives and even absolute strangers with a sort of blind trust that in religious parlance we call “love”. I don’t think you will derive that solution through your ABM though…

Anyways, Fourier transforms are incredibly useful in many places. It looks like you are best served by using the python or R extension and inserting the solutions in a way that applies best for you. Honestly, I have not seen any application of Fourier transforms in well known models and it does not appear that an extension has been created specifically for this purpose.

Sent from my iPhone

On Sep 23, 2021, at 11:06 AM, Nicolas Sprotti <nicolas...@gmail.com> wrote:



Dale Frakes

unread,
Sep 23, 2021, 4:57:39 PM9/23/21
to netlog...@googlegroups.com
Nico,

you also might want to look at more traditional forecasting methods as a way to decompose your demand signals.  Forecasting Principles and Practice by Hyndman & Athanasopoulos (https://otexts.com/fpp3/) is an excellent introduction (using R).

It's not clear if you intend for each agent to do its own forecasting or if you want to do that out of Netlogo, but either way, the methods from FPP would probably be helpful and not too difficult to implement in NetLogo.


As for toilet paper specifically... I'm having trouble finding the article I read, but there were a number of things that drove that craziness.  First, the supply chains for TP are very efficient in terms of supplying a commodity product with nearly rock-solid stable demand.  Remember that any excess inventory (of raw materials or finished goods is "waste" and costs money).  TP factories are tooled and staffed to make "just enough" and in normal times, that's just fine.  Stores rarely run out, everyone gets their normal amount and there's no problem.

Now people suddenly detect there might be a problem.  So, without even hoarding, some large percentage of people think, "I better just grab an extra pack while I'm here"... and suddenly that rock solid demand and jumped... and suddenly there are stories with pictures of empty store shelves...

But if this was all there was, the problem would have sorted itself out pretty quickly... people who have a few extra packs will likely not end up buying TP for a while and then you'd see the classic bullwhip effect with gluts of TP in stores and warehouses.

However, there's a difference in the TP products used in institutional settings vs. at home.  Oddly enough, they're different products with different raw materials and different production methods and factories (or lines within factories).  Suddenly in April 2020, a huge number of people were suddenly not in institutional settings and were instead at home.  So in addition to a short-term spike in demand for home TP products due to anticipated shortages, there was also a real underlying change in demand... shifting from institutional TP to home TP.

This lead to a long-term fundamental change to the product demand.  But with the supply chains so highly tuned to be profitable (and waste free), this change was hard to adjust to.  Home TP factories would need to increase capacity.  This would take time and capital... but what corporate board wants to approve doubling the size of a TP factory when in 2 years everything is likely to go back to normal?  Worse, the institutional TP manufacturing can't simply be converted to make home TP, so they actually have a glut of capacity and inventory.

That doesn't take into account the possibility that production itself was shut down due to outbreaks, which probably also did happen.

So at the crux of it, the TP problem was one where we had a highly tuned and efficient system for supplying a commodity product with very stable demand, and it suffered a rapid change in that demand and took longer than expected to return to a "normal" state.


On 9/23/21 1:31 PM, Michael Tamillow wrote:
 Well that’s an easy question to answer, and it is highly correlated with the fact that everyone seemed to gain 20 - 50 lbs overnight and liquor sales spiked 50% immediately with the evaporation of toilet paper supplies. Everyone was pooping their brains out as they ate and drank away their problems and wallowed in self pity at the end of the world. Of course the ending of the story is that when the world did not end they were shocked and confused and in fear of showing their faces for their selfish gluttony, they covered them in masks and demanded we all do so, so that we could not differentiate between the cowards and the courageous. 
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/E55B1D06-9B80-4E87-BC99-7DD216342A6E%40gmail.com.

-- 
Dale Frakes
Adjunct Instructor, PhD Candidate
PSU Systems Science
dfr...@pdx.edu - http://web.pdx.edu/~dfrakes/

Michael Tamillow

unread,
Sep 24, 2021, 9:13:07 AM9/24/21
to Dale Frakes, 'Saadi Hayet' via netlogo-users
Hi Dale,

While I appreciate your theory on the toilet paper shortage, I don't see how it has anything to do with poop. I can't imagine why people would stock up on toilet paper unless they were pooping. By rational economics, more toilet paper demand = more poop. Only an economic theory on toilet paper which is poopy could possibly hold any validity. 

James Steiner

unread,
Sep 24, 2021, 9:21:32 AM9/24/21
to netlogo-users
Poe’s law is finna get a real workout in this thread. 

So, is there an answer to OP’s question?

~~James

Michael Tamillow

unread,
Sep 24, 2021, 10:15:44 AM9/24/21
to James Steiner, netlogo-users
There is wisdom in absurdity.

The answer is to make a reporter that represents the function:

image.png

Or to use the python or R extension.

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.

Nicolas Sprotti

unread,
Sep 24, 2021, 5:46:48 PM9/24/21
to Michael Tamillow, James Steiner, 'Suhas Parandekar' via netlogo-users
Thank you. This is helpful (I am not a scientist nor mathematician).

As far as the bullwhip effect phenomenon, I probably should have go the route of the recent price swing of lumber instead of TP as a business example.

For everyone interested in phenomenon emergence, the bullwhip effect is pure inefficiency in the supply chain. In the case of lumber prices swings nobody is actually making more money. This is pure entropy in the system.
It would be like the mailman deliver my mails then go back to the post-office, pick my neighbor mails and go deliver them. My neighbor and I both get the mail (at a higher price point), the mailman is busy but nobody is gaining efficiency.

There are some literature on this observe phenomenon. The beer game is the most famous.
It usually a function of :
1. Stock order policy
2. Human bias / gaming
3 Order batching

My little project is focusing on optimizing the stock order policy.

Thank you again for the engagement,
Nico

Michael Tamillow

unread,
Sep 25, 2021, 9:43:56 AM9/25/21
to Nicolas Sprotti, James Steiner, 'Suhas Parandekar' via netlogo-users
 With lumber price swings, yes, somebody is making more money. But what I think you mean is that there is no overall utility gain. The money gained and lost is overall more random than anything, who was in the right place at the right time - like musical chairs. But really, prices are just market signals and price and utility are often disconnected. So “making money” and adding real economic gains that are going to improve the standard of living over time are two different things.

Additionally, in monetary policy, Keynesianism is all the rage these days. It is that way because it allows politicians to justify the continued expenditures without any regard to budgets. This was Socrates’ argument against democracy. The majority want to rob the wealthy minority out of envy. There is no greater wealthy minority than the children and unborn, and straddling them with debt is a type of robbery. +1 for Socrates.

Anyways, Keynesianism has driven many fundamental inefficiencies across the entire economy because it is built on the principle that inefficiencies just aren’t that important to consider. As long as people have money to spend, who cares whether they work, or at least whether they work on the right task? Rather than the mailman delivering one letter and the next, he just doesn’t deliver them at all and still gets paid. Rather, he sits at home and ponders whatever it is that mailmen ponder. This is even worse inefficiency than your example, and very in tune with what has actually happened in the past 35 years. (Greenspan’s put is my marker).

Whole industries were getting bailed out across the entire economy for not working. How could that result in anything but inefficiencies?

Thank you to the explanation 

Sent from my iPhone

On Sep 24, 2021, at 4:46 PM, Nicolas Sprotti <nicolas...@gmail.com> wrote:


Thank you. This is helpful (I am not a scientist nor mathematician).

As far as the bullwhip effect phenomenon, I probably should have go the route of the recent price swing of lumber instead of TP as a business example.

For everyone interested in phenomenon emergence, the bullwhip effect is pure inefficiency in the supply chain. In the case of lumber prices swings nobody is actually making more money. This is pure entropy in the system.
It would be like the mailman deliver my mails then go back to the post-office, pick my neighbor mails and go deliver them. My neighbor and I both get the mail (at a higher price point), the mailman is busy but nobody is gaining efficiency.

There are some literature on this observe phenomenon. The beer game is the most famous.
It usually a function of :
1. Stock order policy
2. Human bias / gaming
3 Order batching

My little project is focusing on optimizing the stock order policy.

Thank you again for the engagement,
Nico

On 9/24/2021 10:15:43 AM, Michael Tamillow <mikaelta...@gmail.com> wrote:

There is wisdom in absurdity.

The answer is to make a reporter that represents the function:

<image.png>


Or to use the python or R extension.

James Steiner

unread,
Sep 25, 2021, 11:13:23 AM9/25/21
to netlogo-users
So, here’s a pretty clear walk through of implementing a discrete Fourier transform in code. Probably most efficiently done in an extension, but might be fun to implement in vanilla NetLogo using turtles as the complex number objects, that is, “turtles-own [ real imaginary ]”, rather than lists of lists, paired lists, or whatever else. 

Michael Tamillow

unread,
Sep 25, 2021, 5:09:43 PM9/25/21
to James Steiner, netlogo-users
Some troll had DDOSed the other thread - thanks James!
____________________________________________

extensions [ py ]

to setup ; Here we setup the connection to python and import a few libraries
  py:setup py:python
  py:run "import numpy as np"
  py:run "from scipy.fft import fft" ; for fourier transforms
  reset-ticks
end

to go
  let xl (list 1.0 2.0 1.0 -1.0 1.5) ; take a netlogo list
  show get_fourier xl ; this is the function invocation for the reporter, show prints it out
end

to-report get_fourier [seq]
  py:set "xl" seq ; here we use the netlogo list and put it into python space
  py:run "print(fft(xl))"   ; this is simply to show the actual result, which includes complex variables
  let fourier py:runresult "fft(xl)" ; this puts the result of the fft into the variable to be returned
  report fourier
end

OUTPUT (run setup + go):

[ 4.5       -0.j          2.08155948-1.65109876j -1.83155948+1.60822041j
 -1.83155948-1.60822041j  2.08155948+1.65109876j]

Python error output:
/Users/Mike/netlogo/NetLogo 6.2.0/NetLogo 6.2.0.app/Contents/../../extensions/.bundled/py/pyext.py:115: ComplexWarning: Casting complex values to real discards the imaginary part
  return float(o)

observer: [4.5 2.081559480312316 -1.831559480312316 -1.831559480312316 2.081559480312316]

On Sat, Sep 25, 2021 at 10:13 AM James Steiner <grego...@gmail.com> wrote:
So, here’s a pretty clear walk through of implementing a discrete Fourier transform in code. Probably most efficiently done in an extension, but might be fun to implement in vanilla NetLogo using turtles as the complex number objects, that is, “turtles-own [ real imaginary ]”, rather than lists of lists, paired lists, or whatever else. 

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages