<?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: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?! in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975533#M4373</link>
    <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now SAS is much better than SOLVER/EXCEL, which only gives out one solution.&amp;nbsp; SAS can pop out all the&amp;nbsp;&lt;/P&gt;
&lt;P&gt;top solutions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Somehow why DATE_BLOCK and TREATMENTS cannot be saved out?!&amp;nbsp; All othrs are OK.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   create data want_x_dtbloc from [d b] DATE_BLOCK;
   create data want_trtmt from [t] TREATMENTS;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;64694     create data want_x_dtbloc from [d b] DATE_BLOCK;
                                                         -
                                                         800
ERROR 800-782: The preceding column type may not be a set.

64695     create data want_trtmt from [t] TREATMENTS;
                                                    -
                                                    800
ERROR 800-782: The preceding column type may not be a set.

64696     create data want_IsGood from [dt bloc] IsGood;
NOTE: The data set WORK.WANT_ISGOOD has 15 observations and 3 variables.
64697     create data want_score from [dt bloc] score;
NOTE: The data set WORK.WANT_SCORE has 15 observations and 3 variables.
64698     create data want_outcome from [d b t m]  outcome;
NOTE: The data set WORK.WANT_OUTCOME has 1080 observations and 5 variables.
64699     create data want_tmin_orig from [d b t] _tmin_orig;
NOTE: The data set WORK.WANT_TMIN_ORIG has 270 observations and 4 variables.
64700  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE OPTMODEL used (Total process time):
      real time           0.28 seconds
      cpu time            0.26 seconds
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 23 Sep 2025 00:14:02 GMT</pubDate>
    <dc:creator>hellohere</dc:creator>
    <dc:date>2025-09-23T00:14:02Z</dc:date>
    <item>
      <title>HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975265#M4360</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the SAS dataset, attached.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data structure is below:&amp;nbsp; I have Date[dt] and BLOC[bloc]. Here are 18 treatments [condi_id] for each Date/BLOC[dt/bloc].&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original treatment outcome are _tmin_orig.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now here are improvement trials[ A/B/C/D] on each treatment [from a new dimension/sampling].&amp;nbsp; The outcomes are _tmin,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;_tmin_ew, _tmin_wt_r, and _tmin_wt_r2&amp;nbsp; for A/B/C/D respectively.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Objective is find &lt;STRONG&gt;the&amp;nbsp;best improvement method [ONE out of A/B/C/D]&lt;/STRONG&gt;&amp;nbsp; and &lt;STRONG&gt;the best 2-treatment combination&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;[TWO of the 18 treatment, condi_id=1~18] to ensure that&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;the treatment for &lt;U&gt;EACH DATE/BLOC[dt/bloc]&lt;/U&gt; is safe-guarded:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt; _tmin_XXX [ONE from A/B/C/D with TWO from 18 treatments/condi_id=1~18] is lower than _tmin_orig.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The penalty function is Score 1 if meet the criteria; Score -5 if not.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;The GOAL is to Maxime the SUM of TOTAL SCORE for all DATE/BLOC[dt/bloc].&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Thanks,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sc.png" style="width: 590px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/110032iCD0B691F05323CE0/image-size/large?v=v2&amp;amp;px=999" role="button" title="sc.png" alt="sc.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Sep 2025 16:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975265#M4360</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-17T16:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975283#M4361</link>
      <description>&lt;P&gt;If I understand correctly, the following code does what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   set mm_out_x6_x;
   rename _tmin=method1 _tmin_ew=method2 _tmin_wt_r=method3 _tmin_wt_r2=method4;
run;

proc optmodel;
   /* read input data */
   set METHODS = 1..4;
   set &amp;lt;str,num,num&amp;gt; DATE_BLOCK_TREATMENT;
   num _tmin_orig {DATE_BLOCK_TREATMENT};
   num outcome {DATE_BLOCK_TREATMENT, METHODS};
   read data have into DATE_BLOCK_TREATMENT=[dt bloc condi_id] _tmin_orig
      {m in METHODS} &amp;lt;outcome[dt,bloc,condi_id,m]=col('method'||m)&amp;gt;;
   set TREATMENTS = setof {&amp;lt;d,b,t&amp;gt; in DATE_BLOCK_TREATMENT} t;
   set DATE_BLOCK = setof {&amp;lt;d,b,t&amp;gt; in DATE_BLOCK_TREATMENT} &amp;lt;d,b&amp;gt;;

   /* define optimization model */
   var SelectMethod {METHODS} binary;
   var SelectTreatment {TREATMENTS} binary;
   var IsGood {DATE_BLOCK} binary;
   /* if IsGood[d,b] = 1 then Score[d,b] = 1 else Score[d,b] = -5 */
   impvar Score {&amp;lt;d,b&amp;gt; in DATE_BLOCK} = 1 * IsGood[d,b] - 5 * (1 - IsGood[d,b]);
   max TotalScore = sum {&amp;lt;d,b&amp;gt; in DATE_BLOCK} Score[d,b];
   con CardinalityMethod:
      sum {m in METHODS} SelectMethod[m] = 1;
   con CardinalityTreatment:
      sum {t in TREATMENTS} SelectTreatment[t] = 2;
   /* if IsGood[d,b] = SelectMethod[m] = SelectTreatment[t] = 1 then outcome[d,b,t,m] &amp;lt; _tmin_orig[d,b,t] */
   con NoGood {&amp;lt;d,b,t&amp;gt; in DATE_BLOCK_TREATMENT, m in METHODS: outcome[d,b,t,m] &amp;gt;= _tmin_orig[d,b,t]}:
      IsGood[d,b] + SelectMethod[m] + SelectTreatment[t] &amp;lt;= 2; 

   /* call MILP solver */
   solve;

   /* create output data */
   create data want_method from [method] SelectMethod;
   create data want_treatment from [treatment] SelectTreatment;
   create data want_dt_bloc from [dt bloc] IsGood Score;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;An optimal solution selects method 3 and treatments 12 and 15, yielding a maximum total score of -21.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this does not match your expectation, please provide a sample solution, together with the calculation of its total score.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Sep 2025 19:52:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975283#M4361</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-17T19:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975295#M4362</link>
      <description>&lt;P&gt;Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to save-out the top 3/5 two-treatment combinations on DATE/BLOC?&amp;nbsp;want_treatment has the top one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need top N to make a judgement call later, the do step 2, to maximize the ABS(_tmin_xxx-_tmin_orig) for DATE/BLOC with constrains.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Sep 2025 00:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975295#M4362</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-18T00:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975297#M4363</link>
      <description>&lt;P&gt;To get the 5 best pairs of treatments, you can replace the SOLVE and CREATE DATA statements as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   /* call MILP solver to find top few solutions for SelectTreatment */
   num numSolsWanted = 5;
   num numSolsFound init 0;
   set SOLS = 1..numSolsFound;
   set TREATMENTS_s {SOLS};
   con ExcludeSolution {s in SOLS}:
      sum {t in TREATMENTS_s[s]} SelectTreatment[t] &amp;lt;= card(TREATMENTS_s[s]) - 1;
   for {1..numSolsWanted} do;
      put numSolsFound=;
      solve;
      numSolsFound = numSolsFound + 1;
      TREATMENTS_s[numSolsFound] = {t in TREATMENTS: SelectTreatment[t].sol &amp;gt; 0.5};
      create data ('want_method'||numSolsFound) from [method] SelectMethod;
      create data ('want_treatment'||numSolsFound) from [treatment] SelectTreatment;
      create data ('want_dt_bloc'||numSolsFound) from [dt bloc] IsGood Score;
   end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Sep 2025 00:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975297#M4363</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-18T00:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975318#M4364</link>
      <description>&lt;P&gt;I bet I replace correctly. But the code complains, see below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even I tried other ways around, still.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure, is computer setting thing or not.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  /* call MILP solver , TOP one only
   solve;
   create data want_method from [method] SelectMethod;
   create data want_treatment from [treatment] SelectTreatment;
   create data want_dt_bloc from [dt bloc] IsGood Score;*/

   /*solver, top n*/
   num numSolsWanted = 5;
   num numSolsFound init 0;
   set SOLS = 1..numSolsFound;
   set TREATMENTS_s {SOLS};
   con ExcludeSolution {s in SOLS}:
      sum {t in TREATMENTS_s[s]} SelectTreatment[t] &amp;lt;= card(TREATMENTS_s[s]) - 1;
   for {1..numSolsWanted} do;
      put numSolsFound=;
      solve;
      numSolsFound = numSolsFound + 1;
      TREATMENTS_s[numSolsFound] = {t in TREATMENTS: SelectTreatment[t].sol &amp;gt; 0.5};
      create data ('want_method'||numSolsFound) from [method] SelectMethod;
      create data ('want_treatment'||numSolsFound) from [treatment] SelectTreatment;
      create data ('want_dt_bloc'||numSolsFound) from [dt bloc] IsGood Score;
   end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;13623        create data 'want_method'||numSolsFound from [method] SelectMethod;
                         -------------
                         22
                         76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13624        create data ('want_treatment'||numSolsFound) from [treatment]
                         -
                         22
                         76
13624! SelectTreatment;
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13625        create data ('want_dt_bloc'||numSolsFound) from [dt bloc] IsGood Score;
                         -
                         22
                         76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;13395        create data ('want_method'||numSolsFound) from [method] SelectMethod;
                         -
                         22
                         76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13396        create data ('want_treatment'||numSolsFound) from [treatment]
                         -
                         22
                         76
13396! SelectTreatment;
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13397        create data ('want_dt_bloc'||numSolsFound) from [dt bloc] IsGood Score;
                         -
                         22
                         76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13452        create data ("want_method"||numSolsFound) from [method] SelectMethod;
                         -
                         22
                         76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13453        create data ("want_treatment"||numSolsFound) from [treatment]
                         -
                         22
                         76
13453! SelectTreatment;
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13454        create data ("want_dt_bloc"||numSolsFound) from [dt bloc] IsGood Score;
                         -
                         22
                         76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13509        create data  "want_method"||numSolsFound from [method] SelectMethod;
                          -------------
                          22
                          76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13510        create data ("want_treatment"||numSolsFound) from [treatment]
                         -
                         22
                         76
13510! SelectTreatment;
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13511        create data ("want_dt_bloc"||numSolsFound) from [dt bloc] IsGood Score;
                         -
                         22
                         76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13566        create data  want_method||numSolsFound from [method] SelectMethod;
                                     --             ----          ------------
                                     22             537           595
                                     200
ERROR 22-322: Syntax error, expecting one of the following: (, FROM.

ERROR 537-782: The symbol 'from' is unknown.

ERROR 595-782: The implied subscript count does not match array 'SelectMethod', 0 NE
               1.

ERROR 200-322: The symbol is not recognized and will be ignored.

13566!       create data  want_method||numSolsFound from [method] SelectMethod;
                                                          ------
                                                          537
ERROR 537-782: The symbol 'method' is unknown.

13567        create data ("want_treatment"||numSolsFound) from [treatment]
                         -
                         22
                         76
13567! SelectTreatment;
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

13568        create data ("want_dt_bloc"||numSolsFound) from [dt bloc] IsGood Score;
                         -
                         22
                         76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Sep 2025 12:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975318#M4364</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-18T12:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975319#M4365</link>
      <description>&lt;P&gt;if I just take this as below,&amp;nbsp; the code does not complain and the dataset is created. Surely ONLY THE # 5.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; create data want_m from [method] SelectMethod;
      create data want_t from [treatment] SelectTreatment;
      create data want_d from [dt bloc] IsGood Score;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;numSolsFound=0
numSolsFound=1
numSolsFound=2
numSolsFound=3
numSolsFound=4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Sep 2025 12:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975319#M4365</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-18T12:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975324#M4366</link>
      <description>&lt;P&gt;It looks like you are using an old version of SAS.&amp;nbsp; That dynamic data set name functionality was introduced in SAS/OR 14.1 in SAS 9.4M3 in 2015:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/ormpug/68156/HTML/default/viewer.htm#ormpug_optmodel_details40.htm" target="_blank" rel="noopener"&gt;Data Set Input/Output :: SAS/OR(R) 14.1 User's Guide: Mathematical Programming&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a workaround that uses PROC APPEND inside a SUBMIT block:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   /* call MILP solver to find top few solutions for SelectTreatment */
   num numSolsWanted = 5;
   num numSolsFound init 0;
   set SOLS = 1..numSolsFound;
   set TREATMENTS_s {SOLS};
   con ExcludeSolution {s in SOLS}:
      sum {t in TREATMENTS_s[s]} SelectTreatment[t] &amp;lt;= card(TREATMENTS_s[s]) - 1;
   for {1..numSolsWanted} do;
      put numSolsFound=;
      solve;
      numSolsFound = numSolsFound + 1;
      TREATMENTS_s[numSolsFound] = {t in TREATMENTS: SelectTreatment[t].sol &amp;gt; 0.5};
      create data want_method from [method] sol=numSolsFound SelectMethod;
      create data want_treatment from [treatment] sol=numSolsFound SelectTreatment;
      create data want_dt_bloc from [dt bloc] sol=numSolsFound IsGood Score;
      submit;
         proc append base=want_method_all data=want_method;
         run;
         proc append base=want_treatment_all data=want_treatment;
         run;
         proc append base=want_dt_bloc_all data=want_dt_bloc;
         run;
      endsubmit;
   end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Sep 2025 14:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975324#M4366</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-18T14:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975358#M4367</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2025 08:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975358#M4367</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-19T08:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975408#M4368</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am playing the codes. I still have one confusion. Sorry OPT Model is quite new to me.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Initially it is to pick 1 out 4 Methods and 2 out 18 Treatments, right?&lt;/P&gt;
&lt;P&gt;If loose the constrains, say, 2/4 for Methods and 4/18 for Treatments,&amp;nbsp; the final Result Score should be better off, Right?&lt;/P&gt;
&lt;P&gt;BUT the best one is only -45. The before is -21, right?&amp;nbsp; I am confused.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   con CardinalityMethod:
      sum {m in METHODS} SelectMethod[m] = 2;
   con CardinalityTreatment:
      sum {t in TREATMENTS} SelectTreatment[t] = 4;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;FULL CODE is below, seems nothing altered. If switch back to&amp;nbsp;&lt;CODE class=" language-sas"&gt;SelectMethod[m] = 1;&amp;nbsp;and&amp;nbsp;SelectTreatment[t] = 2;, the top &lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;result score is -21.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
	https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975265#M4360
*/
%let optds=mm_out_x6_x;
data have;
   set &amp;amp;optds.;
   rename _tmin=method1 _tmin_ew=method2 _tmin_wt_r=method3 _tmin_wt_r2=method4;
run;

title "OPT on &amp;amp;optds.";
proc optmodel;
   /* read input data */
   set METHODS = 1..4;
   set &amp;lt;str,num,num&amp;gt; DATE_BLOCK_TREATMENT;
   num _tmin_orig {DATE_BLOCK_TREATMENT};
   num outcome {DATE_BLOCK_TREATMENT, METHODS};
   read data have into DATE_BLOCK_TREATMENT=[dt bloc condi_id] _tmin_orig
      {m in METHODS} &amp;lt;outcome[dt,bloc,condi_id,m]=col('method'||m)&amp;gt;;
   set TREATMENTS = setof {&amp;lt;d,b,t&amp;gt; in DATE_BLOCK_TREATMENT} t;
   set DATE_BLOCK = setof {&amp;lt;d,b,t&amp;gt; in DATE_BLOCK_TREATMENT} &amp;lt;d,b&amp;gt;;

   /* define optimization model */
   var SelectMethod {METHODS} binary;
   var SelectTreatment {TREATMENTS} binary;
   var IsGood {DATE_BLOCK} binary;
   /* if IsGood[d,b] = 1 then Score[d,b] = 1 else Score[d,b] = -5 */
   impvar Score {&amp;lt;d,b&amp;gt; in DATE_BLOCK} = 1 * IsGood[d,b] - 5 * (1 - IsGood[d,b]);
   max TotalScore = sum {&amp;lt;d,b&amp;gt; in DATE_BLOCK} Score[d,b];
   con CardinalityMethod:
      sum {m in METHODS} SelectMethod[m] = 1;
   con CardinalityTreatment:
      sum {t in TREATMENTS} SelectTreatment[t] = 2;
   /* if IsGood[d,b] = SelectMethod[m] = SelectTreatment[t] = 1 then outcome[d,b,t,m] &amp;lt; _tmin_orig[d,b,t] */
   con NoGood {&amp;lt;d,b,t&amp;gt; in DATE_BLOCK_TREATMENT, m in METHODS: outcome[d,b,t,m] &amp;gt;= _tmin_orig[d,b,t]}:
      IsGood[d,b] + SelectMethod[m] + SelectTreatment[t] &amp;lt;= 2; 

   /* call MILP solver , TOP one only
   solve;
   create data want_method from [method] SelectMethod;
   create data want_treatment from [treatment] SelectTreatment;
   create data want_dt_bloc from [dt bloc] IsGood Score;*/

   /*solver, top n
   num numSolsWanted = 5;
   num numSolsFound init 0;
   set SOLS = 1..numSolsFound;
   set TREATMENTS_s {SOLS};
   con ExcludeSolution {s in SOLS}:
      sum {t in TREATMENTS_s[s]} SelectTreatment[t] &amp;lt;= card(TREATMENTS_s[s]) - 1;
   for {1..numSolsWanted} do;
      solve;
      numSolsFound = numSolsFound + 1;
	   put numSolsFound=;
      TREATMENTS_s[numSolsFound] = {t in TREATMENTS: SelectTreatment[t].sol &amp;gt; 0.5};
      create data ('want_m'||numSolsFound) from [method] SelectMethod;
      create data ('want_t'||numSolsFound) from [treatment] SelectTreatment;
      create data(' want_d'||numSolsFound) from [dt bloc] IsGood Score;
   end;*/

   num numSolsWanted = 5;
   num numSolsFound init 0;
   set SOLS = 1..numSolsFound;
   set TREATMENTS_s {SOLS};
   con ExcludeSolution {s in SOLS}:
      sum {t in TREATMENTS_s[s]} SelectTreatment[t] &amp;lt;= card(TREATMENTS_s[s]) - 1;
   for {1..numSolsWanted} do;
      put numSolsFound=;
      solve;
      numSolsFound = numSolsFound + 1;
      TREATMENTS_s[numSolsFound] = {t in TREATMENTS: SelectTreatment[t].sol &amp;gt; 0.5};
      create data want_method from [method] sol=numSolsFound SelectMethod;
      create data want_treatment from [treatment] sol=numSolsFound SelectTreatment;
      create data want_dt_bloc from [dt bloc] sol=numSolsFound IsGood Score;
      submit;
         proc append base=want_method_all data=want_method;
         run;
         proc append base=want_treatment_all data=want_treatment;
         run;
         proc append base=want_dt_bloc_all data=want_dt_bloc;
         run;
	  endsubmit;
   end;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Sep 2025 14:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975408#M4368</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-20T14:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975417#M4369</link>
      <description>Because the two cardinality constraints are equalities, increasing the right-hand side values does not make the problem looser.  If the = were instead &amp;lt;=, then increasing the right-hand side would indeed yield a relaxation.  Do you want to select exactly the specified numbers or at most the specified numbers?&lt;BR /&gt;</description>
      <pubDate>Sat, 20 Sep 2025 20:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975417#M4369</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-20T20:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975431#M4370</link>
      <description>&lt;P&gt;Let's me try around. See whether I can get it in SOLVER/EXCEL, match or not.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;THanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Sep 2025 12:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975431#M4370</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-21T12:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975461#M4371</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried out with SOLVER/EXCEL. The result screen copy is below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also I attach the EXCEL file here. All are color-coded, I bet it is clear in EXCEL.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess I did not clearly expressed somewhere. Would you take a peek and make a check?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SOLVER.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/110075i469A0D094427B3E1/image-size/large?v=v2&amp;amp;px=999" role="button" title="SOLVER.jpg" alt="SOLVER.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Sep 2025 07:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975461#M4371</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-22T07:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975486#M4372</link>
      <description>&lt;P&gt;To match the Excel logic, you can change the optimization model as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   /* define optimization model */
   var SelectTreatment {TREATMENTS} binary;
   var SelectMethod {METHODS} binary;
   var SelectTreatmentMethod {TREATMENTS, METHODS} binary;
   var IsGood {DATE_BLOCK} binary;
   /* if IsGood[d,b] = 1 then Score[d,b] = 1 else Score[d,b] = -5 */
   impvar Score {&amp;lt;d,b&amp;gt; in DATE_BLOCK} = 1 * IsGood[d,b] - 5 * (1 - IsGood[d,b]);
   max TotalScore = sum {&amp;lt;d,b&amp;gt; in DATE_BLOCK} Score[d,b];
   con CardinalityTreatment:
      sum {t in TREATMENTS} SelectTreatment[t] = 2;
   con CardinalityMethod:
      sum {m in METHODS} SelectMethod[m] = 1;
   /* SelectTreatmentMethod[t,m] &amp;lt;= SelectTreatment[t] * SelectMethod[m] */
   con Linearize1 {t in TREATMENTS, m in METHODS}:
      SelectTreatmentMethod[t,m] &amp;lt;= SelectTreatment[t];
   con Linearize2 {t in TREATMENTS, m in METHODS}:
      SelectTreatmentMethod[t,m] &amp;lt;= SelectMethod[m];
   con AtLeastOneGood {&amp;lt;d,b&amp;gt; in DATE_BLOCK}:
      IsGood[d,b] &amp;lt;= sum {&amp;lt;(d),(b),t&amp;gt; in DATE_BLOCK_TREATMENT, m in METHODS: outcome[d,b,t,m] &amp;lt; _tmin_orig[d,b,t]} SelectTreatmentMethod[t,m];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The idea is that if IsGood[d,b] = 1, the AtLeastOneGood constraint will force SelectTreatmentMethod[t,m] = 1 for at least one t and m such that outcome[d,b,t,m] &amp;lt; _tmin_orig[d,b,t].&amp;nbsp; And the Linearize1 and Linearize2 constraints together force SelectTreatment[t] = 1 and SelectMethod[m] = 1 for that t and m.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With these changes, the optimal objective value is 3, and there are 13 such optimal solutions for SelectTreatment.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2025 15:40:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975486#M4372</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-23T15:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975533#M4373</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now SAS is much better than SOLVER/EXCEL, which only gives out one solution.&amp;nbsp; SAS can pop out all the&amp;nbsp;&lt;/P&gt;
&lt;P&gt;top solutions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Somehow why DATE_BLOCK and TREATMENTS cannot be saved out?!&amp;nbsp; All othrs are OK.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   create data want_x_dtbloc from [d b] DATE_BLOCK;
   create data want_trtmt from [t] TREATMENTS;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;64694     create data want_x_dtbloc from [d b] DATE_BLOCK;
                                                         -
                                                         800
ERROR 800-782: The preceding column type may not be a set.

64695     create data want_trtmt from [t] TREATMENTS;
                                                    -
                                                    800
ERROR 800-782: The preceding column type may not be a set.

64696     create data want_IsGood from [dt bloc] IsGood;
NOTE: The data set WORK.WANT_ISGOOD has 15 observations and 3 variables.
64697     create data want_score from [dt bloc] score;
NOTE: The data set WORK.WANT_SCORE has 15 observations and 3 variables.
64698     create data want_outcome from [d b t m]  outcome;
NOTE: The data set WORK.WANT_OUTCOME has 1080 observations and 5 variables.
64699     create data want_tmin_orig from [d b t] _tmin_orig;
NOTE: The data set WORK.WANT_TMIN_ORIG has 270 observations and 4 variables.
64700  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE OPTMODEL used (Total process time):
      real time           0.28 seconds
      cpu time            0.26 seconds
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Sep 2025 00:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975533#M4373</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-23T00:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975537#M4374</link>
      <description>&lt;P&gt;Correct syntax is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   create data want_x_dtbloc from [d b]=DATE_BLOCK;
   create data want_trtmt from [t]=TREATMENTS;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Sep 2025 04:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975537#M4374</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-23T04:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975925#M4375</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are 18 treatments, some are from same Category[See the screen copy below].&lt;/P&gt;
&lt;P&gt;Now, I need to enforce ONE AND ONLY ONE from condi_id=[2/3/4] is selected.&lt;/P&gt;
&lt;P&gt;Note the total selected treatments is STILL TWO.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to specify the "con"? Thanks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="treatment_grp.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/110223i07952B714390186A/image-size/large?v=v2&amp;amp;px=999" role="button" title="treatment_grp.jpg" alt="treatment_grp.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 08:49:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975925#M4375</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-29T08:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975943#M4376</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   con CardinalityTreatment234:
      sum {t in 2..4} SelectTreatment[t] = 1;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Sep 2025 13:46:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975943#M4376</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-29T13:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975944#M4377</link>
      <description>Thanks a lot!</description>
      <pubDate>Mon, 29 Sep 2025 13:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/975944#M4377</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-29T13:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/976097#M4378</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am moving to the 2nd stage, to MAXimize the total sum of difference between _tmin_orig and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the _tmin from the four METHODs, while only consider the TotalScore from previous runs[as&lt;/P&gt;
&lt;P&gt;viable candidates] is &amp;gt;= a threshold, say TotalScore&amp;gt;=4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I keep trying around, but does not get through.&amp;nbsp; The codes below complains.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you help me on this?!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Selection Count for METHODS=2 and The Selection for Treatment=2, please.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   var Score {&amp;lt;d,b&amp;gt; in DATE_BLOCK} = 1 * IsGood[d,b] - 5 * (1 - IsGood[d,b]);
   var TotalScore = sum {&amp;lt;d,b&amp;gt; in DATE_BLOCK} Score[d,b];
   impvar difx{&amp;lt;d,b&amp;gt; in DATE_BLOCK} = outcome[d,b]* IsGood[d,b]-_time_orig[b];
   max TotalDif =sum {&amp;lt;d,b&amp;gt; in DATE_BLOCK} difx[d,b];


con MinScore TotalScore &amp;gt;=&amp;amp;N.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   con CardinalityTreatment:
      sum {t in TREATMENTS} SelectTreatment[t] = 2;
   con CardinalityMethod:
      sum {m in METHODS} SelectMethod[m] = 2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Oct 2025 07:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/976097#M4378</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-10-01T07:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO Find the Best Combination Of Treatments for Date/BLOC[dt/bloc] ?!</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/976098#M4379</link>
      <description>&lt;P&gt;The main reason is to safe-guard the improvement: 1) to improve across as many blocs as&lt;/P&gt;
&lt;P&gt;possible [stage I] and 2) to max the improvement [stage II], only from candidates from stage I.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are quite possibilities somewhere here is a huge diff between _tmin_orig and _tmin[from 4 METHODs], but only&amp;nbsp;for one/two blocs while fail to improve at all the blocs leftover.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Oct 2025 07:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HOW-TO-Find-the-Best-Combination-Of-Treatments-for-Date-BLOC-dt/m-p/976098#M4379</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-10-01T07:50:27Z</dc:date>
    </item>
  </channel>
</rss>

