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

Alteryx designer Discussions

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

Linear optimization setup

Highlighted
Asteroid

Hi,

 

I am trying to set up a Linear optimization solution in Alteryx using the optimization tool in Prescriptive, but I am not getting the desired results (no solution).

 

I do have the problem definition and solution in the attached excel, however I am not sure if I am setting it up right in Alteryx (attached workflow).

Any help is appreciated.

 

Thanks,

Ashish

 

 

Asteroid

@KuoL

I read through your post on setting up LP, thanks for the post; It was useful. I was wondering if you have a suggestion for me on what I might be doing wrong.

 

Thanks,

Ashish

Asteroid

Replying just to bring it up in the list. Please help if you can.. Also please comment if this post needs to be modified.

Data Scientist
Data Scientist

Hi @Ashish

 

I was able to take a look at your workflow today, and I think I have a few ideas as to what is happening. 

 

For your "O" input, I think your type needs to be "B" for binary instead of "I". This is because each employee/office combination can only be selected once, making in a yes/no binary variable. 

 

2018-04-17_11-53-27.png

 

For your "A" input, the matrix needs to be configured so that the Offices are the fields. This is because we are attempting to populated offices with office/employee combinations. Office availability is your constraint. 

 

2018-04-17_11-42-31.png

 

On the same note, your "B" input needs to reflect those office constraints. In your case, you are expecting full occupancy, dir set to "==" is appropriate. rhs should reflect occupancy. 

 

 

2018-04-17_11-52-01.png

 

In this configuration, your variables are in rows. So you will want to set the Select constrain mode for Input Anchor A to Dense matrix, variables in rows. 

 

2018-04-17_11-54-16.png

 

 

 

With this input configuration, I am able to run your optimization problem.

 

Does this all make sense? Do you have any further questions? Let me know!

 

Asteroid

Hi @SydneyF,

 

Thanks for your response, It is very helpful. the workflow runs now. However there is one problem that I see.

 

When I removed the Employees from constraints, although I do get a solution but the solution is not correct. 

In the image below I have highlighted when one employee is assigned more than one office and some of the employees did not get assigned any office. 

I want to make sure that every employee gets one office assigned.

 

LP solution.jpg

 

Can you help me further to fix this ?

Thanks again for your help.

 

Ashish

Data Scientist
Data Scientist

Hi @Ashish

 

To add the Employee constraint, simply add the Employee matrix to the "A" input", as you had done in your original configuration. The difference from your original configuration is that you only want 1's and Nulls in the matrix. The 1's represent a combination meeting a criteria (office 1 or Employee 1). 

 

2018-04-18_8-14-33.png

 

 

And add the Employee == 1 constraint to the "B" input. All Employees should be set to ==1, as you want to be sure that each gets assigned once, and only once, again, as you had done in your original configuration. 

 

2018-04-18_8-16-33.png

 

Please be sure to check that the order of your constrains in the "A" input left to right matches the order of your constraints in the "B" input. 

 

This configuration produces your expected result, where each employee is assigned to only one office. 

 

2018-04-18_8-18-32.png

 

Do the configurations of the Optimization Tool inputs make sense? Are there any further questions I can help you with? Please let me know!

 

Thanks!

Asteroid

Hi @SydneyF,

 

Your solution looks correct, it seems to me that this is exactly what I did in my workflow (except the type = "I" instead of "B" although in my mind it should not matter because the combination of type, lb and ub should take care of that)

But I still get "solution undefined". I am attaching my workflow again if you can please see where I am messing it up. 

 

Thanks again for you helping.

Ashish

Data Scientist
Data Scientist

Hi @Ashish,

 

In order to have the optimization run correctly, I made two major changes to your original workflow. The first is change from "I" to "B". The second is that in the "A" input, all values must be set equal to 1. A "1" indicates that a combination meets a criteria (e.g., Employee1Office1 has a 1 for Office_1 and a 1 for Employee_1). You want these values to all be 1, even for the offices (like Office 5) that will take two employees. This is because even though some of the offices can have two occupants, each combination (e.g., Employee5Office5) only meets the "Office" criteria once. Having 2's in the matrix with 2 being the maximum value for that office makes the optimization equation unsolvable, because the 2 constraint is met with only one employee assigned to the office.

 

2018-04-18_8-14-33.png

 

The double occupancy office constraint is set in the "B" input, where you set an Office needing to be equal to 2, instead of 1. 

 

Does this make sense? Please let me know.

 

 

 

 

Asteroid

Hi @SydneyF,

 

Yes this is perfect. It make sense what you did there.

 

Thanks a lot Sydney! Have a great day.

 

Ashsih

Asteroid

Posting the workflow solution for community members to use.

 

Thanks!

Labels