ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
RESUELTAS

HELP! How to use ITERATIVE MACRO

amruta
Asteroide

 

Input: If I am given multiple food products. And the quantities of food bags varies in lbs (less than 10)

 

Problem statement: Assign each food bag a BOX NUMBER and each BOX cannot be greater than 10lbs, can be equal to 10lbs or as close as 10.

I have to fill up the boxes to fullest i.e.10 lbs. The boxes can be left partial (less than 10) only if there is no other option, else try to fill up to fullest. See trial workflow and sample input data attached and expected output.

 

How would you compute? please help.

 

Assumption - do not mix different food types.

 

amruta_1-1649118585037.png

 

8 RESPUESTAS 8
apathetichell
Arturo

i do not believe this is a batch macro or an iterative macro problem - this needs the optimization tool.

SPetrie
Púlsar

You could do it with an iterative macro and a couple mluti-rows.

One multi-row (grouped by food type) to test the totals and another to identify the ones that move on to the box.

SPetrie_0-1649137072711.png

SPetrie_1-1649137117775.png

 

 

Qiu
21 - Polaris
21 - Polaris

@SPetrie  
Nice work.
I was acutally looking into this one, and learned it is a typical Bin packing problem.

https://en.wikipedia.org/wiki/Bin_packing_problem

Maybe I can try something different later. 

 

JarekSkudrzyk
Bólido

@SPetrie brilliant solution!

Qiu
21 - Polaris
21 - Polaris

@SPetrie 
lets submit it as a weekly challenge. 😁


I just noticed that the Bag (lbs) is already sorted in the input file, so maybe we can add one Sorting tool and it will be method of "Best Fit Decreasing".
https://www.youtube.com/watch?v=7QBwgI7h-zw

BagSplit.PNG

In this video, we use two different bin-packing algorithms to solve the same problem. For more info, visit the Math for Liberal Studies homepage: http://webspace.ship.edu/jehamb/mls/index.html
SPetrie
Púlsar

@Qiu Thats a great suggestion.

Thanks for the link as well. I thought I had heard of a problem like this before, but didnt realize there was an actual name for the type of problem :)

Tyro_abc
Bólido

@SPetrie  - this is awesome, and I agree with @Qiu 's suggestion.

amruta
Asteroide

@SPetrie This is awesome, It works like a charm. Thank you so much for your time and help!

@Qiu Thank you for your suggestion.

Etiquetas
Autores con mayor cantidad de soluciones