Hello, I am relatively new to SAS and am working on an optimization problem using PROC OPTMODEL. The problem is the following: different products have different annual sales (e.g. $10,000 for product x, $15,000 for product y, etc). In addition to the actual sales, each product is assigned *estimated* sales in order to to guide things like marketing budgets, etc. The estimated sales are grouped by product category, meaning that, within a product category, different individual products can either exceed, or fall short of, this estimated sales. Currently, the majority of products have actual sales that exceed estimates sales. I would like to reset the estimated sales targets in such a way that minimizes the number of times this happens. Essentially, I want to perform an optimization over the set of products and find the new level of estimated sales that minimizes the number of times that true sales exceed estimated sales. The obvious answer is to reset the estimate sales level to something very high, but I need to constrain the new estimated sales to be relatively close to the previous estimate sales. As I wrote above, I think that PROC OPTMODEL might work for this. I have coded a toy example which I believe captures the salient features of this problem. The problem includes actual sales for 8 (imaginary) products, and has as the constraint that the optimal level of estimates sales can not exceed 20 when summed over all 8 products. I'm modeling this using the sign() function. The issue, however, is that the code, below, doesn't give me the correct answer! The optimal solution ("thresh") should be anything between 2 and 2.5. This would lead actual sales to exceed estimated sales for 6 of the 8 products without violating the constraint. As is, the code hits the maximum number of iterations at 5000, and returns a solution of .9999. Question 1: why is this not returning a correct answer? What am I doing wrong? data sales;
input spend @@;
datalines;
1 5 6 10 12 13 3 2
;
proc optmodel;
set SPENDING;
num spend {SPENDING}; read data sales into SPENDING = [_N_] spend;
print spend;
var thresh>=0;
var signfunction{i in SPENDING};
min p = sum{i in SPENDING} signfunction[i];
con sf {i in SPENDING}: signfunction[i]= sign(spend[i] - thresh);
con bc: (sum{i in SPENDING} thresh) <= 20;
solve;
print thresh; /*this SHOULD be something from 2 to 2.5...*/
quit; Question 2: When I impose the constraint sf in the optimization problem, this gives me an entirely different (and wrong) answer of an optimal threshold of .01. See below. Why is this happening? proc optmodel;
set SPENDING;
num spend {SPENDING};
read data sales into SPENDING = [_N_] spend;
print spend;
var thresh>=0;
min p = sum{i in SPENDING} sign(spend[i] - thresh);
con bc: (sum{i in SPENDING} thresh) <= 20;
solve;
print thresh; /*this SHOULD be something from 2 to 2.5...*/
quit; Thank you in advance.
... View more