<?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: Minimize a function f(x) over a given domain - CLP optmodel in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916828#M4087</link>
    <description>&lt;P&gt;With your new data, you can omit i and j, and I think the following does what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data VData;
   input v remi $ class $;
   datalines;
100 205 MA
300 802 MB
600 605 PB
200 604 PB
300 725 SI
500 215 SI
;&lt;BR /&gt;
data PData;
   input p remi $ aop $ class $;
   datalines;
10 205 15 MA
11.25 802 18 MB
10 605 26 PB
11.5 604 35 PB
10.25 725 44 SI
12 725 42 SI
110.75 725 46 SI
10.25 215 87 SI
11.25 215 89 SI
;&lt;BR /&gt;
proc optmodel;
   set &amp;lt;str,str&amp;gt; REMI_CLASS;
   num v {REMI_CLASS};
   read data VData into REMI_CLASS=[remi class] v;
   set &amp;lt;str,str,str&amp;gt; REMI_CLASS_AOP;
   num p {REMI_CLASS_AOP};
   read data PData into REMI_CLASS_AOP=[remi class aop] p;

   var X {REMI_CLASS_AOP} binary;

   min f = abs(sum {&amp;lt;r,c,a&amp;gt; in REMI_CLASS_AOP} (if char(c,1) = 'M' then 1 else -1)*v[r,c]*p[r,c,a]*X[r,c,a]);

   con OneValue {&amp;lt;r,c&amp;gt; in REMI_CLASS}:
      sum {&amp;lt;(r),(c),a&amp;gt; in REMI_CLASS_AOP} X[r,c,a] = 1;

   solve linearize;

   print X;
   print {&amp;lt;r,c&amp;gt; in REMI_CLASS} (sum {&amp;lt;(r),(c),a&amp;gt; in REMI_CLASS_AOP} p[r,c,a]*X[r,c,a]);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 19 Feb 2024 17:22:12 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2024-02-19T17:22:12Z</dc:date>
    <item>
      <title>Minimize a function f(x) over a given domain - CLP - OPTMODEL</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916435#M4070</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to understand if there is a way to find the best configuration to minimize a function over a given domain of variables x, y, z:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example using default values:&lt;BR /&gt;xij like and list of arrays {3 , 4 ,5}, y {6, 7 , 8}, z{1, 2 , 3}&lt;/P&gt;&lt;P&gt;Vi {100, 200, 300}&lt;/P&gt;&lt;P&gt;min f(x) = sum (xij*Vi)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The best configuration will be 3*100 + 6*200 + 1*300&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am staring to check the CLP and the OPTMODEL, do you have real example for this kind of problem?&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&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;</description>
      <pubDate>Fri, 16 Feb 2024 13:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916435#M4070</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-16T13:20:44Z</dc:date>
    </item>
    <item>
      <title>Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916419#M4071</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to understand if there is a way to find the best configuration to minimize a function over a given domain of variables x, y, z:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example using default values:&lt;BR /&gt;xij like and list of arrays {3 , 4 ,5}, y {6, 7 , 8}, z{1, 2 , 3}&lt;/P&gt;&lt;P&gt;Vi {100, 200, 300}&lt;/P&gt;&lt;P&gt;min f(x) = sum (xij*Vi)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The best configuration will be 3*100 + 6*200 + 1*300&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am staring to check the CLP and the OPTMODEL, do you have real example for this kind of problem?&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 09:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916419#M4071</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-16T09:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916429#M4072</link>
      <description>&lt;P&gt;You'd better post it at OR forum.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Mathematical-Optimization/bd-p/operations_research" target="_blank"&gt;https://communities.sas.com/t5/Mathematical-Optimization/bd-p/operations_research&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and calling&amp;nbsp;&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;Here is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
set idx={1..9};
num x{idx}=[3    4   5  6   7   8   1   2    3];
num v{idx}=[100 100 100 200 200 200 300 300 300];
var a{idx} binary;

min obj=sum{i in idx} a[i]*x[i]*v[i];

con con1:sum{i in 1..3} a[i]=1;
con con2:sum{j in 4..6} a[j]=1;
con con3:sum{k in 7..9} a[k]=1;

solve with clp / findallsolns;

print obj a x v;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1708085607984.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93822i33D2C4E20FC7000D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1708085607984.png" alt="Ksharp_0-1708085607984.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 12:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916429#M4072</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-02-16T12:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP - OPTMODEL</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916460#M4073</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/449771"&gt;@harmonic&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I de-duplicated your question by moving your topic thread in programming board to same&amp;nbsp;topic thread in Operations Research board (this one!).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of using SAS Optimization (definitely a good choice!), you can also do this via our Interactive Matrix Language (IML). From that IML module you also have access to several solvers.&lt;BR /&gt;However, I cannot do this short program quickly for you from the top of my head. Maybe&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;can.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Two tips for optimizing a function that has a restricted domain &lt;BR /&gt;By Rick Wicklin on The DO Loop August 21, 2019&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/08/21/tips-optimize-restricted-domain.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2019/08/21/tips-optimize-restricted-domain.html&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Least-squares optimization and the Gauss-Newton method &lt;BR /&gt;By Rick Wicklin on The DO Loop March 16, 2022&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2022/03/16/least-squares-gauss-newton.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2022/03/16/least-squares-gauss-newton.html&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 14:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916460#M4073</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2024-02-16T14:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP - OPTMODEL</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916471#M4074</link>
      <description>Will the different arrays always share the same length (3 in your example)?&lt;BR /&gt;&lt;BR /&gt;Will the array values always consist of consecutive integers or can they be arbitrary?</description>
      <pubDate>Fri, 16 Feb 2024 14:19:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916471#M4074</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2024-02-16T14:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916484#M4075</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;I will focus on my real problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I have two different types of data inputs and I want to determine which one is better for my objective function.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fabiopuddu_0-1708094806827.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93842i568F0F8E8E534903/image-size/medium?v=v2&amp;amp;px=400" role="button" title="fabiopuddu_0-1708094806827.png" alt="fabiopuddu_0-1708094806827.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fabiopuddu_1-1708094836175.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93843i7D0F9F9687A6FC7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="fabiopuddu_1-1708094836175.png" alt="fabiopuddu_1-1708094836175.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Next, I would like to create different arrays from the input in the procedure as follows (maybe using read data into):&lt;/P&gt;&lt;P&gt;- vol_M1: {100, 100}&lt;BR /&gt;- pcs_M1: {10, 10.5}&lt;BR /&gt;- vol_S1: {300, 300}&lt;BR /&gt;- pcs_S1: {11, 11.5}&lt;BR /&gt;- vol_S2: {400, 400}&lt;BR /&gt;- pcs_S2: {12}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. After that, I need to determine the best configuration using all combinations to minimize the absolute value of 'f'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The minimum absolute value of 'f' is calculated as follows:&lt;/P&gt;&lt;P&gt;Min |f| = vol_M1_i * pcs_M1_i – [(vol_s1_j * pcs_S1_j) + (vol_S2_k * pcs_S2_k)]&lt;/P&gt;&lt;P&gt;Where:&lt;BR /&gt;- i ranges from 1 to the dimension of pcs_M1&lt;BR /&gt;- j ranges from 1 to the dimension of pcs_S1&lt;BR /&gt;- k ranges from 1 to the dimension of pcs_S2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. How can I implement this in Proc OPTMODEL?&lt;/P&gt;&lt;P&gt;This is a sample, but I have 7000 different "cod" items.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 14:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916484#M4075</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-16T14:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916488#M4076</link>
      <description>&lt;P&gt;I don't quite understand.&amp;nbsp; Can you please do the following to help clarify?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First describe the business problem, without algebra or explicit data.&amp;nbsp; Maybe trying to match supplies and demands as closely as possible?&amp;nbsp; Then express the objective function explicitly using your small sample data.&amp;nbsp; Finally, provide the expected optimal solution for your sample data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Rob&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 15:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916488#M4076</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2024-02-16T15:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP - OPTMODEL</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916584#M4078</link>
      <description>&lt;P&gt;Here's a way to use the CLP solver with the ELEMENT predicate to solve your sample problem:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   set ISET = 1..3;
   set JSET = 1..3;
   num a {ISET, JSET} = [
      3 4 5
      6 7 8
      1 2 3
   ];
   num v {ISET} = [100 200 300];

   var Index {ISET} &amp;gt;= 1 &amp;lt;= 3 integer;
   var X {ISET} integer;

   min f = sum {i in ISET} v[i]*X[i];

   /* X[i] = a[i,Index[i]] */
   con ElementCon {i in ISET}:
      element(Index[i], {j in JSET} a[i,j], X[i]);

   solve;

   print Index X;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: Print Table" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;[1]&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Index&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;X&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 16 Feb 2024 21:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916584#M4078</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2024-02-16T21:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916594#M4079</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I will repost my answer, I don't know why I can't find it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My business solution is to find the best configuration to minimize the obj function with a clp or a optmodel because with a for cycle there will be a lot of iterations&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example using these arrays in a for cycle:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;vol_M1: {100, 100}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;pcs_M1: {10, 10.5}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;vol_S1: {300, 300}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;pcs_S1: {11, 11.5}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;vol_S2: {400, 400}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;pcs_S2: {12}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Min |f| = vol_M1_i * pcs_M1_i – [(vol_s1_j * pcs_S1_j) + (vol_S2_k * pcs_S2_k)] &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. 100*10 - [(300*11) + (400*12)] = -7100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. 100*10.5 - [(300*11) + (400*12)&lt;/SPAN&gt;&lt;SPAN&gt;] = -7050&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. 100*10 - [(300*11.5) + (400*12)] =&amp;nbsp; - 7250&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4. 100*10.5 - [(300*11.5) + (400*12)]&amp;nbsp; = -7200&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The best configuration will be the 2. because is a minimum local (next to zero)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 23:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916594#M4079</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-16T23:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP - OPTMODEL</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916595#M4080</link>
      <description>&lt;P&gt;I neet to take the values from the input table that I put in the previous post if there is a way to do it. And create arrays.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 23:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916595#M4080</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-16T23:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916600#M4081</link>
      <description>&lt;P&gt;The following does what I think you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data VData;
   input i v;
   datalines;
1 100
2 300
3 400
;

data PData;
   input i j p;
   datalines;
1 1 10
1 2 10.5
2 1 11
2 2 11.5
3 1 12
;

proc optmodel;
   set ISET;
   num v {ISET};
   read data VData into ISET=[i] v;
   set &amp;lt;num,num&amp;gt; IJ;
   num p {IJ};
   read data PData into IJ=[i j] p;

   var X {IJ} binary;

   min f = abs(sum {&amp;lt;i,j&amp;gt; in IJ} (if i = 1 then 1 else -1)*v[i]*p[i,j]*X[i,j]);

   con OneValue {i in ISET}:
      sum {&amp;lt;(i),j&amp;gt; in IJ} X[i,j] = 1;

   solve linearize;

   print X;
   print {i in ISET} (sum {&amp;lt;(i),j&amp;gt; in IJ} p[i,j]*X[i,j]);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;DIV class="branch"&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;The SAS System&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV class="c proctitle"&gt;The OPTMODEL Procedure&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: Problem Summary" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;Problem Summary&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Sense&lt;/TH&gt;
&lt;TD class="r data"&gt;Minimization&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Function&lt;/TH&gt;
&lt;TD class="r data"&gt;f&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Type&lt;/TH&gt;
&lt;TD class="r data"&gt;Nonlinear&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Number of Variables&lt;/TH&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Bounded Above&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Bounded Below&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Bounded Below and Above&lt;/TH&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Free&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Fixed&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Binary&lt;/TH&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Integer&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Number of Constraints&lt;/TH&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Linear LE (&amp;lt;=)&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Linear EQ (=)&lt;/TH&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Linear GE (&amp;gt;=)&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Linear Range&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Constraint Coefficients&lt;/TH&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR size="3" /&gt;
&lt;P&gt;&lt;A name="IDX48" target="_blank"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;The SAS System&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="c proctitle"&gt;The OPTMODEL Procedure&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: Solution Summary" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;Solution Summary&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Solver&lt;/TH&gt;
&lt;TD class="r data"&gt;MILP&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Algorithm&lt;/TH&gt;
&lt;TD class="r data"&gt;Branch and Cut&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Function&lt;/TH&gt;
&lt;TD class="r data"&gt;f&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Solution Status&lt;/TH&gt;
&lt;TD class="r data"&gt;Optimal&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Value&lt;/TH&gt;
&lt;TD class="r data"&gt;7050&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Relative Gap&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Absolute Gap&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Primal Infeasibility&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Bound Infeasibility&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Integer Infeasibility&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Best Bound&lt;/TH&gt;
&lt;TD class="r data"&gt;7050&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Nodes&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Solutions Found&lt;/TH&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Iterations&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Presolve Time&lt;/TH&gt;
&lt;TD class="r data"&gt;0.02&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Solution Time&lt;/TH&gt;
&lt;TD class="r data"&gt;0.02&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&lt;A name="IDX49" target="_blank"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: X" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="3" scope="colgroup"&gt;X&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c headerempty" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;1&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;2&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&lt;A name="IDX50" target="_blank"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: Print Table" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;[1]&lt;/TH&gt;
&lt;TH class="c headerempty" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;10.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="r data"&gt;11.0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="r data"&gt;12.0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 17 Feb 2024 02:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916600#M4081</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2024-02-17T02:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP - OPTMODEL</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916655#M4082</link>
      <description>&lt;P&gt;Maybe I understood what you need.&lt;/P&gt;
&lt;P&gt;The following code I wrote is very clumsy .&lt;/P&gt;
&lt;P&gt;Maybe &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt; could give you succinct and better code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

/**************************************/
data have;
input cod $ vol pcs;
cards;
M1 100 10
M1 100 10.5
S1 300 11
S1 300 11.5
S2 400 12
S2 400 .
;
run;
data temp;
 set have;
 id+1;
run;
proc transpose data=temp out=temp2(where=(col1 is not missing));
by id cod;
var vol pcs;
run;
data vol pcs;
 set temp2;
 if _name_='vol' then output vol;
 if _name_='pcs' then output pcs;
run;
proc sql;
create table temp3 as
select a.cod as cod,a.col1 as vol,b.col1 as pcs
 from vol as a,pcs as b
  where a.cod=b.cod;
quit;
data want;
 set temp3;
 if cod ne 'M1' then vol=-vol;
run;


/*Make marco variables to be parameters*/
proc sql noprint;
select count(*) into :nobs from want;
select pcs into :pcs separated by ' ' from want;
select vol into :vol separated by ' ' from want;
quit;
data idx;
 set want;
 by cod notsorted;
 retain start;
 if first.cod then start=_n_;
 if last.cod  then do;end=_n_;idx+1;output;end;
 keep idx cod start end;
run;
filename x temp;
data _null_;
set idx;
file x;
put 'con con' idx +(-1)':sum{a' idx 'in ' start +(-1)'..' end '} a[a' idx +(-1)']=1;';
run;


proc optmodel;
set idx={1..&amp;amp;nobs.};
num x{idx}=[&amp;amp;pcs.];
num v{idx}=[&amp;amp;vol.];
var a{idx} binary;

min obj=abs(sum{i in idx} a[i]*x[i]*v[i]);

%include x;&lt;BR /&gt;solve linearize;
/*  solve with blackbox; */
/*   solve with clp ;   */
print obj a x v;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1708228799445.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93896i621B81A0CBE370CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1708228799445.png" alt="Ksharp_0-1708228799445.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2024 04:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916655#M4082</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-02-18T04:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916751#M4083</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Really nice solution, and if I have n variables do you think this solution will be acceptable?&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input cod $ vol pcs;&lt;BR /&gt;cards;&lt;BR /&gt;M1 100 10&lt;BR /&gt;M2 100 10.5&lt;/P&gt;&lt;P&gt;.......&lt;/P&gt;&lt;P&gt;Mn 150 11&lt;BR /&gt;S1 300 11&lt;BR /&gt;S1 300 11.5&lt;BR /&gt;S2 400 12&lt;BR /&gt;S2 400 .&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;Sn 200 10.5&lt;BR /&gt;;&lt;BR /&gt;run;&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="fabiopuddu_0-1708331614344.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93911i3C755FC0798E00F1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="fabiopuddu_0-1708331614344.png" alt="fabiopuddu_0-1708331614344.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where M got just one p for each observation and S different p. M and S are the variable vol.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 10:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916751#M4083</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-19T10:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP - OPTMODEL</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916793#M4084</link>
      <description>&lt;P&gt;Nice solution, I have just matched this issue:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fabiopuddu_0-1708353879723.png" style="width: 739px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93915i4FEA5004422766BF/image-dimensions/739x349?v=v2" width="739" height="349" role="button" title="fabiopuddu_0-1708353879723.png" alt="fabiopuddu_0-1708353879723.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 14:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916793#M4084</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-19T14:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916800#M4085</link>
      <description>&lt;P&gt;The following will work even if you have more than one p for each M observation.&amp;nbsp; It is more efficient and less error-prone to avoid duplicating data, so I have retained two separate data sets:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data VData;
   input cod $ vol;
   datalines;
M1 100
M2 100
Mn 150
S1 300
S2 400
Sn 200
;&lt;BR /&gt;
data PData;
   input cod $ j pcs;
   datalines;
M1 1 10
M2 1 10.5
Mn 1 11
S1 1 11
S1 2 11.5
S2 1 12
Sn 1 10.5
;&lt;BR /&gt;
proc optmodel;
   set &amp;lt;str&amp;gt; ISET;
   num v {ISET};
   read data VData into ISET=[cod] v=vol;
   set &amp;lt;str,num&amp;gt; IJ;
   num p {IJ};
   read data PData into IJ=[cod j] p=pcs;

   var X {IJ} binary;

   min f = abs(sum {&amp;lt;i,j&amp;gt; in IJ} (if char(i,1) = 'M' then 1 else -1)*v[i]*p[i,j]*X[i,j]);

   con OneValue {i in ISET}:
      sum {&amp;lt;(i),j&amp;gt; in IJ} X[i,j] = 1;

   solve linearize;

   print X;
   print {i in ISET} (sum {&amp;lt;(i),j&amp;gt; in IJ} p[i,j]*X[i,j]);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Feb 2024 15:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916800#M4085</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2024-02-19T15:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916819#M4086</link>
      <description>&lt;P&gt;Thank you for you quick reply, I don't understand how to keep the value char, the final problem is more complex then this one, I created sample tables like that:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;data VData;&lt;BR /&gt;input i v remi $ class $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 100 205 MA&lt;BR /&gt;2 300 802 MB&lt;BR /&gt;3 600 605 PB&lt;BR /&gt;4 200 604 PB&lt;BR /&gt;5 300 725 SI&lt;BR /&gt;6 500 215 SI&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data PData;&lt;BR /&gt;input i j p remi $ aop $ class $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1 10 205 15 MA&lt;BR /&gt;2 1 11.25 802 18 MB&lt;BR /&gt;3 1 10 605 26 PB&lt;BR /&gt;4 1 11.5 604 35 PB&lt;BR /&gt;5 1 10.25 725 44 SI&lt;BR /&gt;5 2 12 725 42 SI&lt;/P&gt;&lt;P&gt;5 3 110.75 725 46 SI&lt;BR /&gt;6 1 10.25 215 87 SI&lt;BR /&gt;6 2 11.25 215 89 SI&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The objective is to output the configuration of "aop" and "pcs" codes to minimize abs(f)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tot_in=sum(sum(of M:), -1 * sum(of PB:));&lt;BR /&gt;tot_out=sum(sum(of P:), sum(of SI:), -1 * sum(of PB:));&lt;BR /&gt;f=sum(tot_in, -tot_out);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NB: just the points with class "SI" got different "pcs" for the same "remi" code.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 16:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916819#M4086</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-19T16:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916828#M4087</link>
      <description>&lt;P&gt;With your new data, you can omit i and j, and I think the following does what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data VData;
   input v remi $ class $;
   datalines;
100 205 MA
300 802 MB
600 605 PB
200 604 PB
300 725 SI
500 215 SI
;&lt;BR /&gt;
data PData;
   input p remi $ aop $ class $;
   datalines;
10 205 15 MA
11.25 802 18 MB
10 605 26 PB
11.5 604 35 PB
10.25 725 44 SI
12 725 42 SI
110.75 725 46 SI
10.25 215 87 SI
11.25 215 89 SI
;&lt;BR /&gt;
proc optmodel;
   set &amp;lt;str,str&amp;gt; REMI_CLASS;
   num v {REMI_CLASS};
   read data VData into REMI_CLASS=[remi class] v;
   set &amp;lt;str,str,str&amp;gt; REMI_CLASS_AOP;
   num p {REMI_CLASS_AOP};
   read data PData into REMI_CLASS_AOP=[remi class aop] p;

   var X {REMI_CLASS_AOP} binary;

   min f = abs(sum {&amp;lt;r,c,a&amp;gt; in REMI_CLASS_AOP} (if char(c,1) = 'M' then 1 else -1)*v[r,c]*p[r,c,a]*X[r,c,a]);

   con OneValue {&amp;lt;r,c&amp;gt; in REMI_CLASS}:
      sum {&amp;lt;(r),(c),a&amp;gt; in REMI_CLASS_AOP} X[r,c,a] = 1;

   solve linearize;

   print X;
   print {&amp;lt;r,c&amp;gt; in REMI_CLASS} (sum {&amp;lt;(r),(c),a&amp;gt; in REMI_CLASS_AOP} p[r,c,a]*X[r,c,a]);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Feb 2024 17:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916828#M4087</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2024-02-19T17:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916919#M4088</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and if I would like to add constraints for the p value like 9&amp;lt;p&amp;lt;12?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And try to change the solver with CLP or MILP?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 11:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916919#M4088</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-20T11:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916993#M4089</link>
      <description>&lt;P&gt;To restrict the p values, you can either modify the input data or use a WHERE clause in the READ DATA statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   read data PData(where=(9 &amp;lt; p &amp;lt; 12)) into REMI_CLASS_AOP=[remi class aop] p;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You cannot use the CLP solver here because the variables needed to linearize the absolute value are continuous.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 15:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916993#M4089</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2024-02-20T15:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Minimize a function f(x) over a given domain - CLP optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916996#M4090</link>
      <description>&lt;P&gt;1. My goal is to use the p values just with his correspond remi and aop number , how is possible that it will find everytime function next to zero with just a couple of p available for each couple of r and a.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. And can I create a table output with r c a, for values of v p and x?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. For some reason I get this error, I will upload the dataset input.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Problem generation will use 4 threads.
NOTE: The problem has 22246 variables (0 free, 0 fixed).
NOTE: The problem has 22246 binary and 0 integer variables.
NOTE: The problem has 7215 linear constraints (0 LE, 7215 EQ, 0 GE, 0 range).
NOTE: The problem has 22246 linear constraint coefficients.
NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range).
NOTE: The OPTMODEL presolver removed 1567 variables, 1567 linear constraints, and 0 nonlinear constraints.
NOTE: The OPTMODEL presolver replaced 0 nonlinear constraints, 0 objectives, and 0 implicit variables.
NOTE: The OPTMODEL presolver added 0 variables and 0 linear constraints.
NOTE: The OPTMODEL presolved problem has 20679 variables, 5648 linear constraints, and 0 nonlinear constraints.
NOTE: The OPTMODEL presolver removed 1567 linear constraint coefficients, leaving 20679.
ERROR: The NLP solver does not allow integer variables. The black-box solver might be suitable for this problem.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;4. Anyway I found this kind of bug for the X values, it should be 0 or 1.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fabiopuddu_0-1708448945095.png" style="width: 500px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93944iAE1E489EF5EA3476/image-dimensions/500x75?v=v2" width="500" height="75" role="button" title="fabiopuddu_0-1708448945095.png" alt="fabiopuddu_0-1708448945095.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5.Can I use bounds in constraint statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&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;</description>
      <pubDate>Tue, 20 Feb 2024 17:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimize-a-function-f-x-over-a-given-domain-CLP-OPTMODEL/m-p/916996#M4090</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2024-02-20T17:53:59Z</dc:date>
    </item>
  </channel>
</rss>

