<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Proc Optmodel constraint help in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-constraint-help/m-p/725486#M3354</link>
    <description>&lt;P&gt;Thank you again!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Mar 2021 16:15:01 GMT</pubDate>
    <dc:creator>SAScowboy</dc:creator>
    <dc:date>2021-03-11T16:15:01Z</dc:date>
    <item>
      <title>Proc Optmodel constraint help</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-constraint-help/m-p/725243#M3352</link>
      <description>&lt;P&gt;Could someone help me figure out how to add a constraint that requires at least one of adwords 3,5,7 to be bought?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also how to force the model to never buy adword 35?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;BR /&gt;set ADWORDS = 1..100;&lt;BR /&gt;num cost_per_click{ADWORDS} = ranuni(123);&lt;BR /&gt;num clicks{ADWORDS} = ranuni(567);&lt;BR /&gt;num conversions{ADWORDS} = ranuni(789);&lt;BR /&gt;num revperconversion=10;&lt;BR /&gt;var buy{ADWORDS} &amp;gt;=0;&lt;BR /&gt;max effectiveness =sum{a in ADWORDS}((revperconversion*conversions[a])-(clicks[a]*cost_per_click[a]))*buy[a];&lt;BR /&gt;con buyAtMost50: sum{a in ADWORDS}buy[a]&amp;lt;=50;&lt;BR /&gt;con buyAtMostOfEven: sum{a in ADWORDS: mod(a,2) = 0}buy[a]&amp;lt;=10;&lt;BR /&gt;con buyAtMostOfOdd: sum{a in ADWORDS: mod(a,1) = 0}buy[a]&amp;lt;=20;&lt;BR /&gt;solve;&lt;BR /&gt;Quit;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 19:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-constraint-help/m-p/725243#M3352</guid>
      <dc:creator>SAScowboy</dc:creator>
      <dc:date>2021-03-10T19:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Optmodel constraint help</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-constraint-help/m-p/725476#M3353</link>
      <description>&lt;P&gt;First a correction to your constraint:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con buyAtMostOfOdd: sum{a in ADWORDS: mod(a,2) = 1}buy[a]&amp;lt;=20;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now here is a way to force 3, 5, 7:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con AtLeastOne357: sum {a in {3,5,7}} buy[a] &amp;gt;= 1;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And here are four alternative ways to avoid 35.&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Explicit constraint:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con No35: buy[35] = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Fixed variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;fix buy[35] = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Change index set declaration:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set ADWORDS = 1..100 diff {35};&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Modify index set after declaration:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set ADWORDS init 1..100;
ADWORDS = ADWORDS diff {35};&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Mar 2021 16:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-constraint-help/m-p/725476#M3353</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2021-03-11T16:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Optmodel constraint help</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-constraint-help/m-p/725486#M3354</link>
      <description>&lt;P&gt;Thank you again!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 16:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-constraint-help/m-p/725486#M3354</guid>
      <dc:creator>SAScowboy</dc:creator>
      <dc:date>2021-03-11T16:15:01Z</dc:date>
    </item>
  </channel>
</rss>

