Changeset 19 for branches/devel-1/Test


Ignore:
Timestamp:
Sep 16, 2002 1:54:29 AM (18 years ago)
Author:
ladanyi
Message:

reordering Clp

Location:
branches/devel-1/Test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-1/Test/ClpMain.cpp

    r18 r19  
    77
    88#include <cassert>
     9#include <cstdio>
     10#include <cmath>
     11#include <cfloat>
     12#include <string>
     13#include <iostream>
     14
     15#include <time.h>
     16#include <sys/times.h>
     17#include <sys/resource.h>
     18#include <unistd.h>
     19
    920#define CLPVERSION "0.92"
    1021
     22//#include "CoinPackedMatrix.hpp"
     23//#include "CoinPackedVector.hpp"
     24#include "CoinWarmStartBasis.hpp"
     25#include "CoinMpsIO.hpp"
     26
    1127#include "ClpFactorization.hpp"
    12 #include "OsiMpsReader.hpp"
    1328#include "ClpSimplex.hpp"
    1429#include "ClpDualRowSteepest.hpp"
     
    1631#include "ClpPrimalColumnSteepest.hpp"
    1732#include "ClpPrimalColumnDantzig.hpp"
    18 #include "OsiPackedMatrix.hpp"
    19 #include "OsiPackedVector.hpp"
    20 #include "OsiWarmStartBasis.hpp"
    2133// For Branch and bound
    22 #include "OsiClpSolverInterface.hpp"
    23 #include "OsiCuts.hpp"
    24 #include "OsiRowCut.hpp"
    25 #include "OsiColCut.hpp"
    26 #include "OsiOsiMessage.hpp"
    27 
    28 #include <stdio.h>
    29 
    30 #include <cmath>
    31 #include <cfloat>
    32 
    33 #include <string>
    34 #include <iostream>
    35 #include  <time.h>
    36 #include <sys/times.h>
    37 #include <sys/resource.h>
    38 #include <unistd.h>
     34//  #include "OsiClpSolverInterface.hpp"
     35//  #include "OsiCuts.hpp"
     36//  #include "OsiRowCut.hpp"
     37//  #include "OsiColCut.hpp"
     38
    3939#ifdef DMALLOC
    4040#include "dmalloc.h"
     
    11571157                if (!status||(status>0&&allowImportErrors)) {
    11581158                  // I don't think there is any need for this but ..
    1159                   OsiWarmStartBasis allSlack;
     1159                  CoinWarmStartBasis allSlack;
    11601160                  goodModels[iModel]=true;
    11611161                  models[iModel].setBasis(allSlack);
     
    11901190              }
    11911191              if (canOpen) {
    1192                 // get OsiClp stuff
    1193                 OsiClpSolverInterface m(models+iModel);
    11941192                // Convert names
    11951193                int iRow;
     
    12091207                    strdup(models[iModel].columnName(iColumn).c_str());
    12101208                }
    1211                 m.writeMps(fileName.c_str(),
    1212                            (const char **) rowNames,
    1213                            (const char **) columnNames);
     1209
     1210                ClpSimplex& m = models[iModel];
     1211                CoinMpsIO writer;
     1212                writer.setMpsData(*m.matrix(), CLP_INFINITY,
     1213                                  m.getColLower(), m.getColUpper(),
     1214                                  m.getObjCoefficients(),
     1215                                  (const char*) 0 /*integrality*/,
     1216                                  m.getRowLower(), m.getRowUpper(),
     1217                                  columnNames, rowNames);
     1218                writer.writeMps(fileName.c_str());
    12141219                for (iRow=0;iRow<numberRows;iRow++) {
    12151220                  free(rowNames[iRow]);
     
    12201225                }
    12211226                delete [] columnNames;
    1222                 m.releaseClp();
    12231227                time2 = cpuTime();
    12241228                totalTime += time2-time1;
  • branches/devel-1/Test/Makefile

    r18 r19  
    88##############################################################################
    99# The location of the customized Makefiles
    10 export MakefileDir := $(CoinDir)/Common/make
     10# also inherited from the parent Makefile
     11export CoinDir = $(shell cd ../..; pwd)
     12export MakefileDir := $(CoinDir)/Makefiles
    1113include ${MakefileDir}/Makefile.coin
    1214include ${MakefileDir}/Makefile.location
    1315
    14 IncDir :=
    15 IncDir += ${OsiSolverIncDir}
    16 IncDir += ${OsiIncDir}
    17 IncDir += ${ClpIncDir}
    18 IncDir += ${zlibIncDir}
    19 IncDir += ${bzlibIncDir}
    20 
    21 LibDir :=
    22 LibDir += ${OsiLibDir}
    23 LibDir += ${ClpLibDir}
    24 LibDir += ${zlibLibDir}
    25 LibDir += ${bzlibLibDir}
    26 
    27 LibName :=
    28 LibName += ${OsiLibName}
    29 LibName += ${ClpLibName}
    30 LibName += ${zlibLibName}
    31 LibName += ${bzlibLibName}
    32 
    33 Define :=
    34 Define += ${ClpDefine}
    35 Define += ${OsiDefine}
    36 Define += ${zlibDefine}
    37 Define += ${bzlibDefine}
     16IncDir := ${ClpIncDir} ${CoinIncDir} ${bzlibIncDir} ${zlibIncDir}
     17LibDir := ${ClpLibDir} ${CoinLibDir} ${bzlibLibDir} ${zlibLibDir}
     18LibName := ${ClpLibName} ${CoinLibName} ${bzlibLibName} ${zlibLibName}
     19Define := ${ClpDefine} ${CoinDefine} ${bzlibDefine} ${zlibDefine}
    3820
    3921##############################################################################
     
    4527    CXXFLAGS += -DOSI_DEBUG
    4628endif
     29
     30TESTSRC := ClpMain.cpp
     31TESTSRC += unitTest.cpp
    4732
    4833###############################################################################
     
    6348LIBDIRS := ${LibDir}
    6449LIBS    := ${LibName}
    65 LIBS    += libOsiClp
    6650
    6751LDFLAGS := $(addprefix -L,$(LIBDIRS))
     
    7660###############################################################################
    7761
    78 TESTSRC := ClpMain.cpp
    79 TESTSRC += unitTest.cpp
    8062TESTOBJ := $(addprefix $(TARGETDIR)/, $(TESTSRC:.cpp=.o))
    8163TESTDEP := $(addprefix $(DEPDIR)/, $(TESTSRC:.cpp=.d))
  • branches/devel-1/Test/unitTest.cpp

    r2 r19  
    77
    88#include <cassert>
     9#include <cstdio>
     10#include <cmath>
     11#include <cfloat>
     12#include <string>
     13#include <iostream>
     14
     15#include <time.h>
     16#include <sys/times.h>
     17#include <sys/resource.h>
     18#include <unistd.h>
     19
     20#include "CoinMpsIO.hpp"
     21#include "CoinPackedMatrix.hpp"
     22#include "CoinPackedVector.hpp"
     23#include "CoinWarmStartBasis.hpp"
    924
    1025#include "ClpFactorization.hpp"
    11 #include "OsiMpsReader.hpp"
    1226#include "ClpSimplex.hpp"
    1327#include "ClpDualRowSteepest.hpp"
     
    1529#include "ClpPrimalColumnSteepest.hpp"
    1630#include "ClpPrimalColumnDantzig.hpp"
    17 #include "OsiPackedMatrix.hpp"
    18 #include "OsiPackedVector.hpp"
    19 #include "OsiWarmStartBasis.hpp"
    20 #include <stdio.h>
    21 
    22 #include <cmath>
    23 #include <cfloat>
    24 
    25 #include <string>
    26 #include <iostream>
    27 #include  <time.h>
    28 #include <sys/times.h>
    29 #include <sys/resource.h>
    30 #include <unistd.h>
     31#include "ClpParameters.hpp"
    3132
    3233//#############################################################################
     
    243244      // Read data mps file,
    244245      std::string fn = netlibDir+mpsName[m];
    245       OsiMpsReader mps;
     246      CoinMpsIO mps;
    246247      mps.readMps(fn.c_str(),"mps");
    247248      ClpSimplex solution=empty;
     
    264265        solution.setDualRowPivotAlgorithm(steep);
    265266#endif
    266         solution.setDblParam(OsiObjOffset,mps.objectiveOffset());
     267        solution.setDblParam(ClpObjOffset,mps.objectiveOffset());
    267268        solution.dual();
    268269      } else {
     
    279280        solution.setInfeasibilityCost(1.0e6);
    280281#endif
    281         solution.setDblParam(OsiObjOffset,mps.objectiveOffset());
     282        solution.setDblParam(ClpObjOffset,mps.objectiveOffset());
    282283        solution.primal();
    283284      }
     
    285286      {
    286287        double soln = solution.objectiveValue();
    287         OsiRelFltEq eq(objValueTol[m]);
     288        CoinRelFltEq eq(objValueTol[m]);
    288289        std::cerr <<soln <<",  " <<objValue[m] <<" diff "<<
    289290          soln-objValue[m]<<std::endl;
     
    319320{
    320321 
    321   OsiRelFltEq eq(0.000001);
     322  CoinRelFltEq eq(0.000001);
    322323
    323324  {
     
    330331    int rows[11]={0,2,-1,-1,0,1,2,0,1,2};
    331332    double elements[11]={7.0,2.0,1.0e10,1.0e10,-2.0,1.0,-2.0,1,1,1};
    332     OsiPackedMatrix matrix(true,3,5,8,elements,rows,start,length);
     333    CoinPackedMatrix matrix(true,3,5,8,elements,rows,start,length);
    333334   
    334335    // rim data
     
    343344    int colBasis1[5]={1,1,-1,-1,1};
    344345    int i;
    345     OsiWarmStartBasis warm;
     346    CoinWarmStartBasis warm;
    346347    warm.setSize(5,3);
    347348    for (i=0;i<3;i++) {
    348349      if (rowBasis1[i]<0) {
    349         warm.setArtifStatus(i,OsiWarmStartBasis::atLowerBound);
     350        warm.setArtifStatus(i,CoinWarmStartBasis::atLowerBound);
    350351      } else {
    351         warm.setArtifStatus(i,OsiWarmStartBasis::basic);
     352        warm.setArtifStatus(i,CoinWarmStartBasis::basic);
    352353      }
    353354    }
    354355    for (i=0;i<5;i++) {
    355356      if (colBasis1[i]<0) {
    356         warm.setStructStatus(i,OsiWarmStartBasis::atLowerBound);
     357        warm.setStructStatus(i,CoinWarmStartBasis::atLowerBound);
    357358      } else {
    358         warm.setStructStatus(i,OsiWarmStartBasis::basic);
     359        warm.setStructStatus(i,CoinWarmStartBasis::basic);
    359360      }
    360361    }
     
    401402  }
    402403  {   
    403     OsiMpsReader m;
     404    CoinMpsIO m;
    404405    std::string fn = mpsDir+"exmip1";
    405406    m.readMps(fn.c_str(),"mps");
     
    412413  // test steepest edge
    413414  {   
    414     OsiMpsReader m;
     415    CoinMpsIO m;
    415416    std::string fn = netlibDir+"finnis";
    416417    m.readMps(fn.c_str(),"mps");
     
    430431    ClpDualRowSteepest steep;
    431432    solution.setDualRowPivotAlgorithm(steep);
    432     solution.setDblParam(OsiObjOffset,m.objectiveOffset());
     433    solution.setDblParam(ClpObjOffset,m.objectiveOffset());
    433434    solution.dual();
    434435  }
    435436  // test normal solution
    436437  {   
    437     OsiMpsReader m;
     438    CoinMpsIO m;
    438439    std::string fn = netlibDir+"afiro";
    439440    m.readMps(fn.c_str(),"mps");
     
    461462      int numberColumns = solution.numberColumns();
    462463      int numberRows = solution.numberRows();
    463       OsiPackedVector colsol(numberColumns,solution.primalColumnSolution());
     464      CoinPackedVector colsol(numberColumns,solution.primalColumnSolution());
    464465      double * objective = solution.objective();
    465466      double objValue = colsol.dotProduct(objective);
    466       OsiRelFltEq eq(1.0e-8);
     467      CoinRelFltEq eq(1.0e-8);
    467468      assert(eq(objValue,-4.6475314286e+02));
    468469      double * lower = solution.columnLower();
     
    501502      CoinDisjointCopyN(solution.dualRowSolution(),numberRows,rowObjective);
    502503      CoinDisjointCopyN(solution.dualColumnSolution(),numberColumns,objective);
    503       OsiWarmStartBasis basis;
     504      CoinWarmStartBasis basis;
    504505      solution.setBasis(basis);
    505506      solution.dual();
     
    511512  // test unbounded
    512513  {   
    513     OsiMpsReader m;
     514    CoinMpsIO m;
    514515    std::string fn = netlibDir+"brandy";
    515516    m.readMps(fn.c_str(),"mps");
     
    583584  // test infeasible
    584585  {   
    585     OsiMpsReader m;
     586    CoinMpsIO m;
    586587    std::string fn = netlibDir+"brandy";
    587588    m.readMps(fn.c_str(),"mps");
Note: See TracChangeset for help on using the changeset viewer.