Hi,
I have a simple problem that i want to solve using the sparse matrix input to Optimization tool.
Orders | Items | Need Qty |
Ord1 | Item1 | 2 |
Ord1 | Item2 | 2 |
Ord2 | Item1 | 2 |
Ord2 | Item3 | 2 |
The total inventory for items are as below:
constraint | rhs | dir |
Item1 | 2 | <= |
Item2 | 2 | <= |
Item3 | 2 | <= |
And other constraints are as below:
Variable | Coefficient | lb | ub | type |
Ord1 | 1 | 0 | 1 | B |
Ord2 | 1 | 0 | 1 | B |
I want to maximize the numbers of orders that can be fulfilled completely and ensure that total inventory pegged to orders is less than or equal to total available.
I am able to solve this with dense matrix. However I want to solve this using sparse matrix because the real data is 1000 x 11000 in dimension and sparse matrix might work faster. Current solution with dense matrix is not completing after 10 hours.
I am attaching the files.
Regards
Nitin
Gelöst! Gehe zu Lösung.
Hi @nitinbajaj,
Based on a quick review of the error you're receiving here, it may be due to the data being fed into the "A" anchor of the Optimization tool. This anchor, when set to use the Sparse Matrix type, is expecting data in a SLAM form. Can you verify the data you're entering is in the proper format?
You can find more information about this here:
https://help.alteryx.com/current/Optimization.htm?Highlight=sparse
I might also recommend checking out the example workflows for Optimization:
Help -> Sample Workflows -> Predictive tool samples -> Prescriptive Analytics -> Optimization
I've also got some backup on the way that might be able to give you more specific suggestions, but hopefully this gets you started!
Hi @nitinbajaj,
SLAM is a specific format of a sparse matrix comprised of three columns, where the first column is a row number, the second column is a column number, and the third column is the value for that cell. In this format, any cells where the value is equal to zero are excluded, which is part of what can make it more efficient for storage and processing.
So a dense matrix that looks like this:
Would look like this as a SLAM sparse matrix:
Where the first row: 1, 1, 12 is equal to the first cell in the dense matrix (row 1, column 1, value = 12), and so on.
As noted in the help documentation, the sparse matrix mode always assumes the constraints are in rows, meaning that each row must represent a constraint, and each column is a variable.
I've attached a simple example of an Optimization problem with a sparse matrix input. I hope this helps!
- Sydney
Thanks a lot !! This works.
I managed to write R code for creating SLAM matrix, however since the size of matrix is 15000 * 2000 the R code is not able to process this much data in memory and failing. Is there a approach to create SLAM matrix in Alteryx with its own tools?
Regards
Nitin
Hi @nitinbajaj,
You could convert your data to a SLAM format using a Record ID Tool to identify Row Number, a Transpose Tool to convert your data to a column format, a Multi-Row Formula Tool to covert Column Names to Column Numbers, and a Filter Tool to remove 0's.
Please see my example attached.
Thanks a lot!!! This works. You are awesome!!
Regards
Nitin