> 2012/5/9 Robbie Morrison <
address@hidden>
>
>> Hello Tony
>>
>> ------------------------------------------------------------
>> To:
address@hidden
>> Subject: [Help-glpk] Generate data section files for model (in GNU
>> MathProg or other languages)
>> From: Tony Khosravi <
address@hidden>
>> Date: Wed, 9 May 2012 17:13:36 +0200
>> ------------------------------------------------------------
>>
>> > Hi,
>> >
>> > I would like to know if it was possible to generate any
>> > data files in the GNU MathProg format with the GLPK
>> > lib.
>> >
>> > When I am talking about data file, I mean the data
>> > section of model data. The aim would be to be able to
>> > generate many text files containing only the data
>> > section so that they can be used later with the solver
>> > and a file containing only the model section. I didn't
>> > find any thing like that.
>> >
>> > My thought is now to try to implement a general lib to
>> > generate sets or parameters in a text file according to
>> > the documentation gmpl, but I was wondering it this had
>> > been done before (which might be probable).
>> >
>> > I also had the idea of using the table statement with
>> > the CSV driver, but apparently, it cannot be used in
>> > the data section, only in the model section, and I
>> > don't want to touch the file with the model. The aim is
>> > to keep the data section separate from the model
>> > section.
>> >
>> > --
>> > *Tony Khosravi Dehkourdi*
>> >
>> > MSc. Student - Computer Systems
>> > *Link?ping University*
>> > El?ve ing?nieur -- G?nie Informatique, Syst?mes et R?seaux
d'Informations
>> > (GI06)*
>> > Universit? de Technologie de Compi?gne*
>> > Tel:
+46 7 60 69 51 57
>>
>> Hello Tony
>>
>> AFAIK, once your high-level MathProg model has been
>> translated into a low-level problem object, it is not
>> possible to detranslate it.
>>
>> So I guess you are talking about doing this processing
>> before your MathProg model + data has been irrevocably
>> translated.
>>
>> You may therefore need to do this work outside of GLPK?
>> That is my best guess anyway.
>>
>> These links might be useful while thinking about your
>> problem:
>>
>>
http://en.wikibooks.org/wiki/GLPK/Steps_of_GMPL_File_Processing
>>
http://en.wikibooks.org/wiki/GLPK/Interoperability
>>
http://en.wikibooks.org/wiki/GLPK/Scripting_plus_MathProg
>>
>> best regards
>> ---
>> Robbie Morrison
>> PhD student -- policy-oriented energy system simulation
>> Technical University of Berlin (TU-Berlin), Germany
>> University email (redirected) :
address@hidden
>> Webmail (preferred) :
address@hidden
>> [from Webmail client]
>
> I would say that the last link is partially the answer
> to my question.
>
> I will try to explain better what I want to do.
>
> So as I said, I would like to generate a file
> containing only data section through a program in a way
> that I can generate many of those data files through a
> program, and then run the GLPK solver on each data file
> according to a model. So you understand that the data
> section and the model section are in two different
> files.
>
> I think I need to say that I program in C++.
>
> Let's say that my program is split into three modules:
>
> - one which generates data (the nature of those data
> are not important) through N iterations
>
> - one which would store those data into N files
> (data section in a text file)
>
> - one which read those data files one by one and run
> the solver (given a file which contains the model
> section)
>
> The first and third modules are implemented, so I am
> interested in implementing the second one.
>
> In fact, the aim is not to have a very flexible program
> since to be able to generate the data files, it (I)
> need to know the model. Let's say that my first module
> generate a matrix. With this matrix, I want to compute
> different things which would corresponds to some
> parameters needed for the model. Therefore, I would
> like to store them in file. In order to have something
> a bit flexible, I was wondering if there was some
> methods available in GLPK or in another library which
> could perform those action like a method called
> "toGMPLParam(name, defaultValue, listOfRecords)" which
> would give in a file in the GMPL format param name
> default defaultValue record1, record2, ..., recordsN
>
> It is still unclear I think so I will try to explain
> with an example as follow:
>
> I have this "program" in whatever-the-language
> /* myprog.cpp */
>
> begin
>
> // Here I generate some data that I store in a matrix
> var myMatrix <- generateData
> // Here I perform some operations on this matrix
> var var1 <- action1(myMatrix)
> var var2 <- action2(myMatrix)
>
> // Here is the part I am interested in
> fileOpen("mydata.dat")
> f <- toGMPLParam("var1", 0, var1)
> f <- toGMPLParam("var2", 0, var2)
>
> // I run this file with the solver and a .mod file
> var optimalSolution <- solve("mydata.dat", "mymodel.mod")
>
> end
>
> /* eof */
>
> I am aware of the fact that I could implement a way of
> just writing those data in a file, trying to respect
> the MathProg format (as long as it is modular, I would
> be satisfied), but maybe GLPK or another lib provides
> such methods that would generate a file with the proper
> syntax used in MathProg given some parameters.
>
> Best regards
>
> --
> *Tony Khosravi Dehkourdi*
>
> MSc. Student - Computer Systems