Dear Dr , if you have any problem with Sim sip SAM software .I can help you to update .

Have a good time

Dr Mohsen Barouni

On Mon, Feb 17, 2014 at 3:20 PM, JosÃ© Luis Viveros AÃ±orve wrote:

Thanks, Leonidas! I will try.

Best,

Luis

On Friday, February 14, 2014 10:35:39 AM UTC+1, Leonidas Paroussos wrote:

Dear Luis,

I have been using the code below, hope it is what you need

Best,

Leonidas

$TITLE RAS

$SET DIR E:\

Set i Biggest dimension of the matrix /1*100/;

Set tg column and row constraints /col,row/;

Alias (i,j);

Parameters

M_INI(i,j) Initial Matrix.

ColTot(i) Column Totals.

RowTot(j) Row Totals.

BalMat(i,j) Balanced Matrix.

TOLERANCE_COL(i) Absolute column difference from target.

TOLERANCE_ROW(i) Absolute row difference from target.

TOL_AB(i) Total difference by row-col.

CHKCOLROW Check for column and row sum equality.

TARGET(*,tg) Column & Row constraints.

;

Scalars

COUNT A counter /1/

TOLERANCE Starting value /10/

*-------------------------------------------------------------*

TOL Tolerance limit set by USER /1.e-7/

ITER Iteration limit set by USER /100/

;

*------------ INCLUDE INITIAL MATRIX & CONSTRAINTS -----------*

$libinclude xlimport m_ini “%DIR%INPUT.xls” MATRIX!C4:BR65

$libinclude xlimport target “%DIR%INPUT.xls” CONSTRAINT!B5:D72

ChkColRow=sum(i,target(i,“col”))-sum(i,target(i,“row”));

display target;

abort$(ChkColRow ge 0.000000001) “Row & Column Sum not equal” , ChkColRow ;

*--------------------------- RAS -----------------------------*

ColTot(i)=sum(j, m_ini(j,i));

BalMat(i,j)=(m_ini(i,j)/ColTot(j))$(ColTot(j) ne 0) +0.;

Loop(i ,

BalMat(i,j)=BalMat(i,j)*Target(j,“col”);

);

RowTot(j)=sum(i, BalMat(j,i));

While ((Tolerance ge Tol and count le Iter),

Loop(j ,

BalMat(i,j)=(BalMat(i,j)*Target(i,“row”)/RowTot(i))(RowTot(i) ne 0) + 0.;
);
ColTot(i)=sum(j, BalMat(j,i));
Loop(i ,
BalMat(i,j)=(BalMat(i,j)*Target(j,"col")/ColTot(j))(ColTot(j) ne 0) + 0;

);

RowTot(j)=sum(i, BalMat(j,i));

ColTot(i)=sum(j, BalMat(j,i));

Tolerance_Col(i)=ColTot(i)-Target(i,“col”);

Tolerance_Row(j)=RowTot(j)-Target(j,“row”);

Tol_ab(j) = abs(Tolerance_Col(j))+abs(Tolerance_Row(j));

Tolerance = sum(i, Tol_ab(i));

COUNT=COUNT+1;

);

Display BalMat,Tolerance_Col,Tolerance_Row;

Display Tol_ab,tolerance,count;

*---------------- Export Balanced matrix to EXCEL -------------*

BalMat(i,j)$(not BalMat(i,j))=eps;

$libinclude xldump balmat “%dir%BAL_MAT.xls” balmat

2014-02-14 11:15 GMT+02:00 JosÃ© Luis Viveros AÃ±orve :

Dear all,

Hope you are doing well.

I would like to update a small matrix using the RAS method in GAMS. I have the row and column totals. Does anyone can share with me an example or a reference about how to do it in GAMS?

I will be very grateful with any guidance!

## Best,

Luis Viveros

University of Bonn

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.

To post to this group, send email to gams...@googlegroups.com.

–

Dr. Leonidas Paroussos

Economist

National Technical University of Athens

Iroon Polytechniou Str. 9, Zografou-Athens, Greece P.O. 15773

Tel: +30-210-7723630; +30-6974489729

Fax:+30-210-7723630

e-mail: paro...@gmail.com

web: www.e3mlab.ntua.gr

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.

To post to this group, send email to gamsworld@googlegroups.com.

Visit this group at http://groups.google.com/group/gamsworld.

For more options, visit https://groups.google.com/groups/opt_out.