[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Import data from Matlab variables to GLPK/GMPL

From: Reginald Beardsley
Subject: Re: [Help-glpk] Import data from Matlab variables to GLPK/GMPL
Date: Sun, 29 Dec 2013 08:58:11 -0800 (PST)

The .mat files are a binary format which would require writing a C program to 
read and convert them which is considerably more.  For awk you need an ASCII  
text format file which is most easily produced using MATLAB. 

On Sun, 12/29/13, Nazmul Islam <address@hidden> wrote:

 Subject: Re: [Help-glpk] Import data from Matlab variables to GLPK/GMPL
 To: "Reginald Beardsley" <address@hidden>
 Cc: "glpk" <address@hidden>
 Date: Sunday, December 29, 2013, 2:45 AM
 Hello Reg (&
 Thanks a lot for your email. 
 As a fast step, I want to solve a mixed integer
 linear program like follows 
 min c'x
 s.t. Ax <= b, lb <= x <=
 ubSome variables of x are binary
 I have generated A, b, c, lb, ub in Matlab and
 stored them in .mat format. I have to convert them to GMPL
 readable format so that I can solve this code using GLPK. I
 have attached a sample of those files with my email. I will
 really appreciate if you could tell me how I can convert
 them using AWK. Please let me know if you want me to send a
 .mat file with smaller size.
 Your help will be very appreciated.
 On Fri, Dec 27, 2013 at
 3:30 PM, Reginald Beardsley <address@hidden>
 I suggest you consider using  awk to generate data files in
 GMPL format from ASCII text (.txt) files if you have very
 many instances to solve.  You put the problem formulation
 in one file and the data for each instance in  another file
 and execute "gplsol -m model.dat -d data.dat".
  I've found this works very well solving large numbers
 of problem instances.  In particular, it makes changing the
 model very simple.  I can't find out anything about the
 Guesk editor so I can't comment on setting up GMPL
 notation data files using that.
 I tried using the CSV import facility in GMPL, but found it
 not very convenient because of restrictions on the CSV
 format glpk accepts. 
 There is a MATLAB binding for GLPK, but I don't know how
 usable it is.  The MATLAB clone, Octave, also has a
 built-in binding to GLPK.
 There is a Gnu implementation of awk, gawk, which is
 standard on Linux systems.  It's also available on
 If you need help with writing an awk script to convert the
 MATLAB .txt files to GMPL notation send me a small example
 of the MATLAB .txt file and I'll add an example to the
 GLPK wiki.
 You'll need to figure out how to write a basic GMPL
 problem first.  A good place to look is in the examples
 directory at cf12a.mod which implements an L1 line fit.  I
 solve physics inverse  problems by basis pursuit using GMPL
 notation so I can probably offer some help.  I do problems
 with 30,000 columns by 50-300 rows.  The resulting files
 are huge, so you want to get everything working using a
 small example before doing something that large.  I did
 some little 10x10 problems to figure out how to set it up.
 On Thu, 12/26/13, Nazmul Islam <address@hidden>
  Subject: [Help-glpk] Import data from Matlab variables to
  To: address@hidden
  Date: Thursday, December 26, 2013, 8:49 PM
  I want to write my GLPK code through the Guesk
  editor and I am very new to the GNU Math Programming
  I want to import some data from Matlab to my GLPK
  code. I want to run the code with these imported data.
  data is currently in some variables of Matlab and I can
  store them in some .mat files. Do I need to save all
  Matlab variables in a single .dat file (or .txt file?)
  then import to GNU Math Prog language?
  Is there any example that I can
  -----Inline Attachment Follows-----
  Help-glpk mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]