BookmarkSubscribeRSS Feed
Ujjawal
Quartz | Level 8

Thanks @RobPratt for your suggestion. It works like a charm. You have been very helpful. Well appreciated!  I was wondering whether we can add a constraint of max number of 'Manager' and 'Analyst' in your OPTMODEL code. For example, there are 100 high value customers (based on > 50 sale) in a particular region. We require only 34 Managers (=100/3). Suppose we have currently 50 managers in this location so customers should be allocated to max 34 Managers (not 50). It may make some customers are not allocated to the nearest manager. Same logic holds for 'Analyst' as per their customers constraint.

RobPratt
SAS Super FREQ

If I understand correctly, you want to limit the number of managers that are used.  In that case, you have a p-median problem in which the managers are the facilities.  Explicitly, you can replace the Cardinality constraints in the previous code with the following:

 

   var UseManager {PORTFOLIO_MANAGERS} binary;
   con Capacity {p in PORTFOLIO_MANAGERS}:
      sum {<c,(p)> in CP_PAIRS} Assign[c,p] 
   <= (if position[p] = 'Manager' then 3 else 5) * UseManager[p];
   con Cardinality:
      sum {p in PORTFOLIO_MANAGERS} UseManager[p] <= 34;
Ujjawal
Quartz | Level 8

Thank you so much.  In this section of code "sum {p in PORTFOLIO_MANAGERS} UseManager[p] <= 34;", i was trying to calculate 34 from the customer's file. I added this code ' ceil(sum {c in customers} debt[c] / 3) ' instead of 34. But it does not work.

RobPratt
SAS Super FREQ

That syntax looks fine.  Did you declare and read the debt parameter before trying to use it in the constraint?

 

Did you get an error message or an unexpected solution?

Ujjawal
Quartz | Level 8
I apologize for confusing you. It's the same sales parameter( changed the parameter name in my code). I have used ceil(sum {c in customers} sales[c] > 50 / 3). I am trying to calculate the number of customers having sales greater than 50.It doesn't return an error but ahows infessible solution.

After all these constraints, a few customers are being ignored in the optimization. For example - there are 500 customers in the customer table. In the final result, it is assigning PMs against 497 customers. When method = comcomp is enabled, it returns 494 customers. Another thing i observed, when I use method = concomp, it doesn't return optimization result when there is out of memory. But sas returns the best possible solution when this method is disabled.

RobPratt
SAS Super FREQ

One way to correction your expression is to insert some parentheses:

   ceil(sum {c in customers} (sales[c] > 50) / 3)

This is equivalent to any of the following:

   ceil(sum {c in customers} (if sales[c] > 50 then 1 else 0) / 3)
   ceil(sum {c in customers} (if sales[c] > 50 then 1) / 3)
   ceil(sum {c in customers: sales[c] > 50} 1 / 3)
   ceil(card({c in customers: sales[c] > 50}) / 3)

You can use the EXPAND statement to see the resulting constraint:

   expand Cardinality;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 20 replies
  • 2115 views
  • 7 likes
  • 4 in conversation