I don't understand why the my CON 7 is causing the problem to be infeasible?
Here's my code LOG:
Yes, as long as 50000 is <= Input_Budget[j] for campaign j.
It is hard to tell for sure from just looking at your log, but here is what I suspect is going on. You declared this constraint:
con Mycon7 {i in OBS}:
Optimized_Budget[i]<=if Media_Tactics[i]='Offsite Display Walmart Network' then 2000000;
For the IF-THEN/ELSE expression, there is a default of ELSE 0, so what you declared is equivalent to this:
con Mycon7 {i in OBS}:
Optimized_Budget[i]<=if Media_Tactics[i]='Offsite Display Walmart Network' then 2000000 else 0;
Because Optimized_Budget[i] is declared with >= 0 and this constraint forces that variable to be <= 0 if Media_Tactics[i] is not 'Offsite Display Walmart Network', the effect is that Optimized_Budget[i] = 0 in that case.
I think you instead meant for the constraint to be enforced only if the condition is satisfied, which you can do as follows:
con Mycon7 {i in OBS: Media_Tactics[i]='Offsite Display Walmart Network'}:
Optimized_Budget[i] <= 2000000;
And for a constraint with only one variable, it is more efficient to instead omit the constraint and just change the variable bounds:
for {i in OBS: Media_Tactics[i]='Offsite Display Walmart Network'}
Optimized_Budget[i].ub = 2000000;
If I guessed wrong about your intent, I recommend trying the suggestion in the log to use the IIS= option to help diagnose infeasibility:
solve with lp / iis=1;
expand / iis;
Your Mycon1 looks like an attempt to do that:
con Mycon1 {i in OBS}:
sum {j in OBS} Optimized_Budget[j] <= &overall_input_budget * (1+&allowed_budget_inc) * (1-&value_add_pct);
This family of constraints is indexed by i, but nothing in the constraint refers to i, so you end up with the exact same constraint over and over again. Instead, I think you intended to declare a single constraint:
con Mycon1:
sum {j in OBS} Optimized_Budget[j] <= &overall_input_budget * (1+&allowed_budget_inc) * (1-&value_add_pct);
Thank you.
And assuming I can set global constraint (if/then) conditions using this single constraint?
Not sure I follow. Do you mean that you want to use a logical condition with respect to the input data to determine whether to impose a single constraint?
Meaning - could I do this:
con Mycon1 {sum {j in OBS} Optimized_Budget[j]='Offsite Display Walmart Network'}: Optimized_Budget[i]<=200000;
No, that syntax will yield errors, and the logical condition compares a sum of decision variables to a string, so it would never be true.
Do you maybe want the following?
con Mycon1: sum {i in OBS: Media_Tactics[i]='Offsite Display Walmart Network'} Optimized_Budget[i] <= 200000;
If not, what is the business rule that you are trying to enforce?
Here's the example of data I am trying to model:
I would like to set a global constraint for Media_Tactics Offsite Display Walmart Network to be less than $350K, but also additional sub-constraints Campaign_Line_Item criteria.
Media_Tactics | Campaign_Line_Item | Input_Budget |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Standard Audience|In Market Ornaments|47490|7974158 | $ 25,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Custom Audience|Ornaments Heavy Spenders|47490|7974159 | $ 30,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Propensity Audience|Ornaments|47490|7974160 | $ 30,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Standard Audience|Persona Gifters|47490|7974165 | $ 25,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Custom Audience|Ornaments Previous Purchasers|47490|7974169 | $ 25,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Custom Audience|Collectibles Heavy Spenders|47490|7974171 | $ 25,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Custom Audience|Families with Kids+Previous Ornaments Purchasers|47490|7974174 | $ 25,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Propensity Audience|Gifting Supplies|47490|7974175 | $ 25,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Custom Audience|Nov&DecShoppers|47490|7974178 | $ 25,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Custom Audience|GenZMillenial&PopCulture|47490|7974179 | $ 20,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Custom Audience|Heavy Spenders Home Decor|47490|8003807 | $ 20,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Propensity Audience|Holiday Decor|47490|8005360 | $ 25,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Standard Audience|In Market Christmas|47490|7974163 | $ 25,000.00 |
Offsite Display Walmart Network | Walmart DSP|Display|Cross Device|Custom Audience|Contextual Holidays and Celebrations|47490|7974199 | $ 20,000.00 |
Offsite Display Walmart Network | Walmart DSP|Pre-roll|Cross Device|Standard Audience|In Market Ornaments|47490|7974313 | $ 20,000.00 |
Offsite Display Walmart Network | Walmart DSP|Pre-roll|Cross Device|Propensity Audience| Ornaments|47490|7974314 | $ 20,000.00 |
Offsite Display Walmart Network | Walmart DSP|Pre-roll|Cross Device|Custom Audience|Ornaments Heavy Spenders|47490|7974315 | $ 20,000.00 |
OK, I think you want the following:
con Mycon1: sum {i in OBS: Media_Tactics[i]='Offsite Display Walmart Network'} Optimized_Budget[i] <= 350000;
con Mycon2 {j in CAMPAIGNS}: sum {i in OBS: Campaign_Line_Item[i]=j} Optimized_Budget[i] <= Input_Budget[j];
Got it.
So this will ensure that:
1. Overall Offsite Display Walmart Network will be less/eq $350K
2. Campaign_Line_Item = to something can be > $50K if needed?
Yes, as long as 50000 is <= Input_Budget[j] for campaign j.
This is giving me an error? Do you know why?
You have parentheses where you should instead use curly braces. Here is correct syntax:
con Mycon9: sum {i in OBS: Campaign_Line_Item[i] in
{'Walmart DSP|Display|Cross Device|Standard Audience|In Market Christmas|47490|7974163'
,'Walmart DSP|Display|Cross Device|Custom Audience|Heavy Spenders Home Decor|47490|8003807'
,'Walmart DSP|Display|Cross Device|Propensity Audience|Holiday Decor|47490|8005360'
,'Walmart DSP|Display|Cross Device|Propensity Audience|Ornaments|47490|7974160'
,'Walmart DSP|Display|Cross Device|Custom Audience|Nov&DecShoppers|47490|7974178'
,'Walmart|Display|Cross Device|Contextual Targeting|Holiday Decor|CY23|47490|7974064'}} Optimized_Budget[i] <= 140000;
I recommend instead defining the set separately to make the code easier for human consumption:
set CAMPAIGNS = {'Walmart DSP|Display|Cross Device|Standard Audience|In Market Christmas|47490|7974163'
,'Walmart DSP|Display|Cross Device|Custom Audience|Heavy Spenders Home Decor|47490|8003807'
,'Walmart DSP|Display|Cross Device|Propensity Audience|Holiday Decor|47490|8005360'
,'Walmart DSP|Display|Cross Device|Propensity Audience|Ornaments|47490|7974160'
,'Walmart DSP|Display|Cross Device|Custom Audience|Nov&DecShoppers|47490|7974178'
,'Walmart|Display|Cross Device|Contextual Targeting|Holiday Decor|CY23|47490|7974064'};
con Mycon9: sum {i in OBS: Campaign_Line_Item[i] in CAMPAIGNS} Optimized_Budget[i] <= 140000;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.