community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
#SANTALYTICS

Gather all 9 clues to complete the final Weekly Challenge on Dec 16!

Learn More
SOLVED

Optimization with Sparse Matrix input

Meteoroid

Hi,

 

I have a simple problem that i want to solve using the sparse matrix input to Optimization tool.

OrdersItemsNeed Qty
Ord1Item12
Ord1Item22
Ord2Item12
Ord2Item32

 

The total inventory for items are as below:

constraintrhsdir
Item12<=
Item22<=
Item32<=

And other constraints are as below:

VariableCoefficientlbubtype
Ord1101B
Ord2101B

 

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

Alteryx
Alteryx

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!

Mike Spoula
Solutions Architect - Services
Alteryx
Meteoroid
Thanks for replying!!

I went through all the sample workflows and help. I did not find any example for SLAM format input to Optimization. I am just looking for an example on the format of SLAM as input that is acceptable to "Optimization" element.

Kindly help.

Regards
Nitin
Data Scientist
Data Scientist

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:

 

densemartix.png

 

Would look like this as a SLAM sparse matrix:

 

SLAMmatrix.png

 

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

 

 

Meteoroid

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

Data Scientist
Data Scientist

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.

 

2018-09-18_9-54-26.png

 

 

Please see my example attached. 

 

 

Meteoroid

Thanks a lot!!! This works. You are awesome!!

 

Regards

Nitin

Labels