Logic assignment for parameters
Posted: Fri Dec 22, 2017 1:59 am
I’m trying to use the following logic to assign parameters for Mn(n)
For n=1to 100 by 1;
Mn(1)=0, Mn(2)=0, is the initial value;
If n is odd, then Mn(n)=n-2+ Mn( (n-1)/2 ) + Mn( (n+1)/2 ) ;
If n is even, then Mn(n)=n-2+ 2*Mn( (n)/2 );
I am trying to run the following model, but I am not successful. Can anyone help me achieve this goal?
Best Regards!
Hefeng
***=============================================================================
SETS
i component /i1*i100/ ;
Scalar
Count ;
Count=1;
Parameters
Nni(i)
;
Nni('i1')=0;
Nni('i2')=0;
while( (Count<=100),
if( (mod(Count,2)=1),
Nni(i)$(ord(i)=Count)=Count-2+Nni(i)$(ord(i)=(Count-1)/2)+Nni(i)$(ord(i)=(Count+1)/2) ;
else
Nni(i)$(ord(i)=Count)= Count-2+2*Nni(i)$(ord(i)=Count/2) ;
);
Count=Count+1;
);
Display Nni ;
For n=1to 100 by 1;
Mn(1)=0, Mn(2)=0, is the initial value;
If n is odd, then Mn(n)=n-2+ Mn( (n-1)/2 ) + Mn( (n+1)/2 ) ;
If n is even, then Mn(n)=n-2+ 2*Mn( (n)/2 );
I am trying to run the following model, but I am not successful. Can anyone help me achieve this goal?
Best Regards!
Hefeng
***=============================================================================
SETS
i component /i1*i100/ ;
Scalar
Count ;
Count=1;
Parameters
Nni(i)
;
Nni('i1')=0;
Nni('i2')=0;
while( (Count<=100),
if( (mod(Count,2)=1),
Nni(i)$(ord(i)=Count)=Count-2+Nni(i)$(ord(i)=(Count-1)/2)+Nni(i)$(ord(i)=(Count+1)/2) ;
else
Nni(i)$(ord(i)=Count)= Count-2+2*Nni(i)$(ord(i)=Count/2) ;
);
Count=Count+1;
);
Display Nni ;