Reputation: 1
I am currently building an optimal allocation model using scipy.optimize.linprog python code and need to show the results on Tableau.
For simplicity's sake I will say that I have two tables: A- the supply available of the different Supply Buckets and B- the different recipients and how many objects they have demanded in each Slot.
A =
Object | Available |
---|---|
Bucket 1 | 100 |
Bucket 2 | 100 |
B =
Recipient | Object Demanded | Slot 1 | Slot 2 |
---|---|---|---|
Recipient 1 | Bucket 1 | 20 | 30 |
Recipient 2 | Bucket 1 | 60 | 50 |
Recipient 2 | Bucket 2 | 20 | 10 |
The optimisation will give as an output, how many objects are coming from each viable Supply Bucket to each Slot of each Recipient, e.g., How many doses will be going from Bucket 1 to Recipient 1 in Slot 1?, then again for Slot 2?
The objective function ends up being of size n (in this case n=6), the number of bounds ends up being of size m (here m=8, 6 of which being how many objects were demanded in each slot and 2 being the limit on supply) and the list of constraints is of size n x m.
In order to make the size of all fiels the same size to use them as TabPY SCRIPT arguments, I unioned both tables and filter accordingly inside the Python Script, giving me columns of size 5. However, TabPy is now expecting a return list also of size 5 now, or that the returned value will then be repeated 5 times and in this case, my desired returned list is of size n=6.
Is there a way of getting TabPy to return a list of different size than what it received? Or do you have any suggestions as to how I can transform my data to make this function work?
Workarounds I have attempted:
screenshot of how string output looks
Upvotes: 0
Views: 121
Reputation: 791
You can import your data from its respective source or tables and then blend them in tableau on [object]
and [object_demanded]
.
Upvotes: 0