Exemplo n.º 1
0
 static void WriteData(string s, double V)
 {
     string[] Indx   = new string[gamsglobals.maxdim];
     double[] Values = new double[gamsglobals.val_max];
     Indx[0] = s;
     Values[gamsglobals.val_level] = V;
     gdx.gdxDataWriteStr(Indx, Values);
 }
Exemplo n.º 2
0
        static bool WriteModelData(string fnGDXFile)
        {
            int    status = 0;
            string msg    = string.Empty;

            string[] Indx   = new string[gamsglobals.maxdim];
            double[] Values = new double[gamsglobals.val_max];

            gdx.gdxOpenWrite(fnGDXFile, "XP_Example2", ref status);

            if (status != 0)
            {
                return(GDXError(status, "gdxOpenWrite"));
            }

            if (0 == gdx.gdxDataWriteStrStart("Demand", "Demand Data", 1, gamsglobals.dt_par, 0))
            {
                return(GDXError(gdx.gdxGetLastError(), "gdxDataWriteStrStart"));
            }

            Indx[0] = "New-York"; Values[gamsglobals.val_level] = 324.0; gdx.gdxDataWriteStr(Indx, Values);
            Indx[0] = "Chicago"; Values[gamsglobals.val_level] = 299.0; gdx.gdxDataWriteStr(Indx, Values);
            Indx[0] = "Topeka"; Values[gamsglobals.val_level] = 274.0; gdx.gdxDataWriteStr(Indx, Values);

            if (0 == gdx.gdxDataWriteDone())
            {
                return(GDXError(gdx.gdxGetLastError(), "gdxDataWriteDone"));
            }

            if (gdx.gdxClose() != 0)
            {
                return(GDXError(gdx.gdxGetLastError(), "gdxClose"));
            }

            return(true);
        }