<?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 proc optmodel - must be different constrain in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-must-be-different-constrain/m-p/126131#M689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this is quite simple but given I have no experience with optimisation using proc optmodel I am struggling to find solution. &lt;/P&gt;&lt;P&gt;I have a list of customers that are eligible for various offers. I would like to assign offers with 2 constrains. &lt;BR /&gt;-One customer can only be assigned to 2 offers. &lt;BR /&gt;-for every customers -assigned offers can not be from the same conflict group&lt;/P&gt;&lt;P&gt;Objective is to maximize sum of ranking.&lt;/P&gt;&lt;P&gt;I have managed to do first constrain but I am struggling with second.&lt;/P&gt;&lt;P&gt;Here is the code. Would be great if someone could help on this.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data opti1;&lt;BR /&gt;input custid $ output_code $ conflict_group ranking;&lt;BR /&gt;datalines;&lt;BR /&gt;ab1 a 1 45&lt;BR /&gt;ab1 b 1 8&lt;BR /&gt;ab1 c 2 91&lt;BR /&gt;ab1 d 3 80&lt;BR /&gt;ab5 a 1 51&lt;BR /&gt;ab5 b 1 8&lt;BR /&gt;ab5 c 2 2&lt;BR /&gt;ab5 d 3 91&lt;BR /&gt;ab5 e 3 23&lt;BR /&gt;ab5 f 4 58&lt;BR /&gt;ab8 a 1 72&lt;BR /&gt;ab8 b 1 48&lt;BR /&gt;ab8 c 2 27&lt;BR /&gt;ab8 d 3 43&lt;BR /&gt;ab8 e 3 96&lt;BR /&gt;ab8 f 4 5&lt;BR /&gt;ab8 g 4 49&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sort data=opti1 out=opti2 nodupkey;&lt;BR /&gt;by custid;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;BR /&gt;set &amp;lt;str,str&amp;gt; CUST_camp;&lt;BR /&gt;num ranking {CUST_camp};&lt;BR /&gt;num conflict_group {CUST_camp};&lt;BR /&gt;read data opti1 into CUST_camp=[custid output_code] ranking conflict_group;&lt;BR /&gt;set &amp;lt;str&amp;gt; CUST;&lt;BR /&gt;read data opti2 into CUST=[custid];&lt;BR /&gt;var assign{cust_camp} binary;&lt;BR /&gt;*constrain 1- max 2 offers per customer;&lt;BR /&gt;con cust_max_con {i in cust}:&lt;BR /&gt;sum {&amp;lt;(i),j&amp;gt; in cust_camp} assign[i,j] &amp;lt;=2; *not more than 2 per custid;&lt;BR /&gt;/* &lt;BR /&gt;*constrain 2- 2 selected offers per custid can not be in the same conflict group;&lt;BR /&gt;con cust_conflict {i in cust}:&lt;BR /&gt;((setof{&amp;lt;(i),j&amp;gt; in cust_camp} conflict_group[i,j] * assign[i,j]) inter (setof{&amp;lt;(i),j&amp;gt; in cust_camp} conflict_group[i,j] * assign[i,j]))={0};&lt;BR /&gt;*/&lt;BR /&gt;max response=sum {&amp;lt;i,j&amp;gt; in cust_camp} ranking[i,j] * assign[i,j];&lt;BR /&gt;solve with milp;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Jul 2013 15:43:49 GMT</pubDate>
    <dc:creator>vanpoecke</dc:creator>
    <dc:date>2013-07-03T15:43:49Z</dc:date>
    <item>
      <title>proc optmodel - must be different constrain</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-must-be-different-constrain/m-p/126131#M689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this is quite simple but given I have no experience with optimisation using proc optmodel I am struggling to find solution. &lt;/P&gt;&lt;P&gt;I have a list of customers that are eligible for various offers. I would like to assign offers with 2 constrains. &lt;BR /&gt;-One customer can only be assigned to 2 offers. &lt;BR /&gt;-for every customers -assigned offers can not be from the same conflict group&lt;/P&gt;&lt;P&gt;Objective is to maximize sum of ranking.&lt;/P&gt;&lt;P&gt;I have managed to do first constrain but I am struggling with second.&lt;/P&gt;&lt;P&gt;Here is the code. Would be great if someone could help on this.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data opti1;&lt;BR /&gt;input custid $ output_code $ conflict_group ranking;&lt;BR /&gt;datalines;&lt;BR /&gt;ab1 a 1 45&lt;BR /&gt;ab1 b 1 8&lt;BR /&gt;ab1 c 2 91&lt;BR /&gt;ab1 d 3 80&lt;BR /&gt;ab5 a 1 51&lt;BR /&gt;ab5 b 1 8&lt;BR /&gt;ab5 c 2 2&lt;BR /&gt;ab5 d 3 91&lt;BR /&gt;ab5 e 3 23&lt;BR /&gt;ab5 f 4 58&lt;BR /&gt;ab8 a 1 72&lt;BR /&gt;ab8 b 1 48&lt;BR /&gt;ab8 c 2 27&lt;BR /&gt;ab8 d 3 43&lt;BR /&gt;ab8 e 3 96&lt;BR /&gt;ab8 f 4 5&lt;BR /&gt;ab8 g 4 49&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sort data=opti1 out=opti2 nodupkey;&lt;BR /&gt;by custid;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;BR /&gt;set &amp;lt;str,str&amp;gt; CUST_camp;&lt;BR /&gt;num ranking {CUST_camp};&lt;BR /&gt;num conflict_group {CUST_camp};&lt;BR /&gt;read data opti1 into CUST_camp=[custid output_code] ranking conflict_group;&lt;BR /&gt;set &amp;lt;str&amp;gt; CUST;&lt;BR /&gt;read data opti2 into CUST=[custid];&lt;BR /&gt;var assign{cust_camp} binary;&lt;BR /&gt;*constrain 1- max 2 offers per customer;&lt;BR /&gt;con cust_max_con {i in cust}:&lt;BR /&gt;sum {&amp;lt;(i),j&amp;gt; in cust_camp} assign[i,j] &amp;lt;=2; *not more than 2 per custid;&lt;BR /&gt;/* &lt;BR /&gt;*constrain 2- 2 selected offers per custid can not be in the same conflict group;&lt;BR /&gt;con cust_conflict {i in cust}:&lt;BR /&gt;((setof{&amp;lt;(i),j&amp;gt; in cust_camp} conflict_group[i,j] * assign[i,j]) inter (setof{&amp;lt;(i),j&amp;gt; in cust_camp} conflict_group[i,j] * assign[i,j]))={0};&lt;BR /&gt;*/&lt;BR /&gt;max response=sum {&amp;lt;i,j&amp;gt; in cust_camp} ranking[i,j] * assign[i,j];&lt;BR /&gt;solve with milp;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 15:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-must-be-different-constrain/m-p/126131#M689</guid>
      <dc:creator>vanpoecke</dc:creator>
      <dc:date>2013-07-03T15:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel - must be different constrain</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-must-be-different-constrain/m-p/126132#M690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand correctly, the following should do what you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set CONFLICT_GROUPS {i in CUST} = setof {&amp;lt;(i),j&amp;gt; in CUST_CAMP} conflict_group[i,j];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; con cust_conflict {i in cust, g in CONFLICT_GROUPS&lt;I&gt;}:&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum {&amp;lt;(i),j&amp;gt; in CUST_CAMP: conflict_group[i,j] = g} assign[i,j] &amp;lt;= 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; expand cust_conflict;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 16:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-must-be-different-constrain/m-p/126132#M690</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2013-07-03T16:13:17Z</dc:date>
    </item>
  </channel>
</rss>

