BookmarkSubscribeRSS Feed
Emara
Calcite | Level 5

Hi all,

In my problem, I have two non linear constrains ; one of them in is arl1 <= 4 and the other one arl0 >= 500 and this is my problem because when I wrote  these constraints using proc iml, the SAS considers them as equality constraints and I get an arl0 value=500, so how can I write this constraint in SAS so that it is considered as a greater than constraint? please note that I set optn[10]=2;optn[11]=0;


This is part of my program :

start
arl(x);

bb0=j(2,1,0.);

m=100;

  meuw=0;

  L=x[2]*SQRT(x[1]/(2-x[1]));

t=2*m+1;

   delta=2*L/t;

    z=-L+.5*delta;

  do
i=
2 to t;

k=-L+(i-.5)*delta;

z=z//k;

  end;

        do
i=
1 to t;

        zz=0;

   

                           do
j=
1 to t;

kone=((z[j,]+delta/2)-(1-x[1])*z[i,])/x[1];

              ktwo=((z[j,]-delta/2)-(1-x[1])*z[i,])/x[1];

            
pij=probnorm(kone)-probnorm(ktwo);

              zz=zz//pij;

              end;

       if
i=
1 then r=zz;

       else

       r=r||zz;

       end;

       
v=j(t,
1,0);

       v[((t+1)/2),]=1;

      
v=t(v);

  r=r[2:t+1,];

r=t(r);

arl=inv(I(t)-r)*j(t,1,1);

 

arl0=(v*arl);

  bb0[1]=arl0-500;

m=100;

shift=2;

L=x[2]*SQRT(x[1]/((2-x[1])));

t=2*m+1;

delta=2*L/t;

 

z=-L+.5*delta;

do
i=
2 to t;

k=-L+(i-.5)*delta;

z=z//k;

end;

          do
i=
1 to t;

        zz=0;

              do
j=
1 to t;

              kone=((z[j,]+delta/2)-(1-x[1])*z[i,])/x[1];

                ktwo=((z[j,]-delta/2)-(1-x[1])*z[i,])/x[1];

            
pij=probnorm(kone-(shift*sqrt(n)))-probnorm(ktwo-(shift*sqrt(n)));

 

              zz=zz//pij;

 

              end;

        if
i=
1 then r=zz;

       else

       r=r||zz;

       end;

       
v=j(t,
1,0);

       v[((t+1)/2),
]=
1;

       
v=t(v);

r=r[2:t+1,];

r=t(r);

arl=inv((I(t)-r))*j(t,1,1);

arl1=(v*arl);

      
bb0[
2]=4-arl1;

    return (bb0);

finish
arl;

con
= {
0.   0.,

        1.   .};

x={0.3  2.5};

optn=j(1,11,.);optn[1]=0;optn[2]=2;optn[10]=2;optn[11]=0;

 

CALL nlpnms(rc,xres,"Cost",x,optn,con)nlc="arl";

quit;

Thanks,

Aya

1 REPLY 1
Rick_SAS
SAS Super FREQ

Documentation and an example of using a linear constraint matrix is available at

SAS/IML(R) 12.3 User's Guide

However, you need to debug your function before you can optimize it.  It looks to me like the 'n' in sqrt(n) is not defined. Also, you are dividing by x[1], so you need to introduce the constraint that x1>0.

SAS INNOVATE 2024

innovate-wordmarks-white-horiz.png

SAS is headed back to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team.

Interested in speaking? Content from our attendees is one of the reasons that makes SAS Innovate such a special event!

Submit your idea!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 739 views
  • 0 likes
  • 2 in conversation