[Coin-discuss] bringing a matrix into block angular form
Leo Lopes
leo at sie.arizona.edu
Sun Sep 27 21:06:02 EDT 2009
On Fri, Sep 25, 2009 at 4:35 AM, Matthew Galati <Matthew.Galati at sas.com> wrote:
> FYI. The following seems to work. Feel free to add to some CoinUtils code or
> maybe there should be a repository for "scripts"?
>
The above is a fantastic idea. A coin-hacks, analogous to trac-hacks,
will do everyone a lot of good.
>
>
>
>
> // to build:
>
> // g++ main.cpp -L ~/COIN/coin-Decomp/build-g/lib -I
> ~/COIN/coin-Decomp/build-g\
>
> /include/coin -lCoinUtils
>
>
>
> // mps to matrix-market format
>
> // http://math.nist.gov/MatrixMarket/formats.html#mtx
>
>
>
>
>
> #include "CoinMpsIO.hpp"
>
> #include "CoinPackedMatrix.hpp"
>
>
>
> #include <string>
>
> #include <fstream>
>
> #include <iomanip>
>
> using namespace std;
>
>
>
> int main(int argc, char ** argv){
>
>
>
> CoinMpsIO mps;
>
> mps.readMps(argv[1]);
>
>
>
> const CoinPackedMatrix * mat = mps.getMatrixByCol();
>
> const int nCols = mat->getNumCols();
>
> const int nRows = mat->getNumRows();
>
> const int nEls = mat->getNumElements();
>
> const double * els = mat->getElements();
>
> const int * ind = mat->getIndices();
>
> const int * beg = mat->getVectorStarts();
>
> const int * len = mat->getVectorLengths();
>
>
>
> string mmName = (string)(argv[1]) + ".mtx";
>
> ofstream os(mmName.c_str());
>
>
>
> os << "%%MatrixMarket matrix coordinate real general" << endl;
>
> os << "%From mps file: " << argv[1] << endl;
>
> os << nRows << " " << nCols << " " << nEls << endl;
>
>
>
> int lenI = 0;
>
> const int * indI = NULL;
>
> const double * elsI = NULL;
>
>
>
> os << setiosflags(ios::fixed|ios::showpoint);
>
> os << setprecision(7);
>
>
>
> int i,k;
>
> for(i = 0; i < nCols; i++){
>
> lenI = len[i];
>
> indI = ind + beg[i];
>
> elsI = els + beg[i];
>
> for(k = 0; k < lenI; k++){
>
> os << indI[k]+1 << " " << i+1 << " " << elsI[k] << endl;
>
> }
>
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> From: coin-discuss-bounces at list.coin-or.org
> [mailto:coin-discuss-bounces at list.coin-or.org] On Behalf Of magh
> Sent: Thursday, September 24, 2009 11:40 AM
> To: coin-discuss at list.coin-or.org
> Subject: Re: [Coin-discuss] bringing a matrix into block angular form
>
>
>
> This looks fairly easy to use so I was going to try it:
> http://www.math.uu.nl/people/bisseling/Mondriaan/
>
> It wants this format:
> http://math.nist.gov/MatrixMarket/formats.html#mtx
>
> Has anyone written a MPS to MatrixMarket format convertor? I just figured
> I'd ask before I write it - I think it will be easy.
>
> Thanks,
> Matt
>
>
>
>
> Has anyone used COIN together with some package (MeTiS? or any other?) to
> bring a matrix into block angular form? I am looking to read in an MPS file
> - into OSI or CoinMpsIO or something like this, run one of these heuristic
> methods and then return the rows/cols in each block.
>
> Thanks,
> Matt
>
>
>
> _______________________________________________
> Coin-discuss mailing list
> Coin-discuss at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/coin-discuss
>
>
--
========================================================================
Leonardo B. Lopes
Assistant Professor SIE -
University of Arizona
(520)621-2342
leo at sie.arizona.edu
http://www.sie.arizona.edu/faculty/leolopes
More information about the Coin-discuss
mailing list