$GDXIN problem

126 views
Skip to first unread message

Fabián Mancilla

unread,
Apr 16, 2012, 5:10:47 PM4/16/12
to gams...@googlegroups.com
I'm trying to load data (subsets and parameters) from a GDX file. I have a system  with two matrices (A and M) but GAMS read the matrix A like a zeros matrix (all coeficients are zero!), but the matrix A have 987 non zero elements. I used the command 'load' in $GDXIN:

*Model form:
*     min cx
* s.t.
*      Ax < b
*      Mx = g

SETS
i rows matrix A /j1*j559/
j columns matrices A & M /j1*j505/
k rows matrix M /k1*k128/
jcon(j) continue columns
jint(j) integer columnas
jbin(j) binary columns;

PARAMETERS
A(i,j) matrix A
M(k,j) matrix M
b(i)   vector b
g(k)   vector g
c(j)   vector c;

$GDXIN GDXfile.gdx
$load jcon
$load jint
$load jbin
$load b
$load M
$load A
$load g
$load c
$GDXIN

DISPLAY A, M, jcon, jint, jbin;


But the display is:

----     33 PARAMETER A  matrix A

                      ( ALL       0.000 )


----     33 PARAMETER M  matrix M

              j2          j3          j4          j5          j6          j7

k17        1.000
k18                    1.000
k19                                1.000
k20                                            1.000
k21                                                        1.000
k22                                                                    1.000

I don't know why this is happening. Anyone can advice me?

Thanks!

Fabián
GDXfile.gdx
Import.gms

Dol, Wietse

unread,
Apr 17, 2012, 2:32:26 AM4/17/12
to gams...@googlegroups.com

Hi Fabian,

 

When you try to  read from GDX and you get an empty parameter it simply means that you have used wrong indices (sets), i.e. this can happen because you swapped two indices/sets in the parameter declaration (in your case this is not true). The second reason is that you have wrong elements. In your case you define the set i:

i rows matrix A /j1*j559/

but when you look at your GDXfile you will see

i rows matrix A /i1*i559/

So correct this and it should work

 

Wietse

--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Steven Dirkse

unread,
Apr 17, 2012, 9:32:14 AM4/17/12
to gams...@googlegroups.com
If you expect all of the elements in the GDX data to be loaded, you
can also use $loaddc (load with Domain Check), e.g.

$loaddc M
$loaddc A

$load and $load dc are similar. The difference is that $load ignores
elements that don't fit into the declared domain of the data, while
$loaddc flags them as errors.

-Steve

2012/4/16 Fabián Mancilla <mancill...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "gamsworld" group.
> To post to this group, send email to gams...@googlegroups.com.
> To unsubscribe from this group, send email to
> gamsworld+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/gamsworld?hl=en.

--
Steven Dirkse, Ph.D.
GAMS Development Corp.,  Washington DC
Voice: (202)342-0180     Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com

imo

unread,
Apr 17, 2012, 11:39:22 AM4/17/12
to gamsworld
Many thanks to Steven.
I used to have the exact same problem and with $load dc the error was
evident. It took me a while to figure it out, so I will always use
domain checking from now on.

Cheers.
+i

On Apr 17, 2:32 pm, Steven Dirkse <sdir...@gams.com> wrote:
> If you expect all of the elements in the GDX data to be loaded, you
> can also use $loaddc (load with Domain Check), e.g.
>
> $loaddc M
> $loaddc A
>
> $load and $load dc are similar.  The difference is that $load ignores
> elements that don't fit into the declared domain of the data, while
> $loaddc flags them as errors.
>
> -Steve
>
> 2012/4/16 Fabián Mancilla <mancilla.fab...@gmail.com>:
> sdir...@gams.comhttp://www.gams.com

Fabián Mancilla

unread,
Apr 17, 2012, 12:49:13 PM4/17/12
to gams...@googlegroups.com
I didn't see my mistake in the indices set. The load with Domain Check is very useful!

Thanks to both!
Reply all
Reply to author
Forward
0 new messages