source: trunk/Clp/test/osiUnitTest.cpp @ 1741

Last change on this file since 1741 was 1741, checked in by stefan, 8 years ago

cutsOnly is ignored

File size: 4.1 KB
Line 
1// $Id$
2// Copyright (C) 2000, International Business Machines
3// Corporation and others.  All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6#include "CoinPragma.hpp"
7#include "OsiConfig.h"
8
9#include <cstdio>
10#include <iostream>
11
12#include "OsiUnitTests.hpp"
13#include "OsiRowCutDebugger.hpp"
14#include "OsiRowCut.hpp"
15#include "OsiColCut.hpp"
16
17#include "CoinError.hpp"
18
19#include "OsiClpSolverInterface.hpp"
20
21using namespace OsiUnitTest;
22
23//----------------------------------------------------------------
24// unitTest [-nobuf] [-mpsDir=V1] [-netlibDir=V2] [-testOsiSolverInterface]
25//
26// where:
27//   -nobuf: remove buffering on cout (stdout); useful to keep cout and cerr
28//   messages synchronised when redirecting output to a file or pipe.
29//   -mpsDir: directory containing mps test files
30//       Default value V1="../../Data/Sample"   
31//   -netlibDir: directory containing netlib files
32//       Default value V2="../../Data/Netlib"
33//   -testOsiSolverInterface
34//       If specified, then OsiSolveInterface::unitTest
35//       is skipped over and not run.
36//
37// All parameters are optional.
38//----------------------------------------------------------------
39
40int main (int argc, const char *argv[])
41{
42  bool exception = false;
43  outcomes.clear();
44
45/*
46  Start off with various bits of initialisation that don't really belong
47  anywhere else.
48
49  First off, synchronise C++ stream i/o with C stdio. This makes debugging
50  output a bit more comprehensible. It still suffers from interleave of cout
51  (stdout) and cerr (stderr), but -nobuf deals with that.
52*/
53  std::ios::sync_with_stdio() ;
54/*
55  Suppress an popup window that Windows shows in response to a crash. See
56  note at head of file.
57*/
58  WindowsErrorPopupBlocker();
59
60/*
61  Process command line parameters.
62*/
63  std::map<std::string,std::string> parms;
64  if (processParameters(argc,argv,parms) == false)
65  { return (1) ; }
66
67  std::string mpsDir = parms["-mpsDir"] ;
68  std::string netlibDir = parms["-netlibDir"] ;
69
70  try {
71    /*
72      Test Osi{Row,Col}Cut routines.
73    */
74    {
75      OsiClpSolverInterface clpSi;
76      testingMessage( "Testing OsiRowCut with OsiClpSolverInterface\n" );
77      OsiRowCutUnitTest(&clpSi,mpsDir);
78    }
79    {
80      OsiClpSolverInterface clpSi;
81      testingMessage( "Testing OsiColCut with OsiClpSolverInterface\n" );
82      OsiColCutUnitTest(&clpSi,mpsDir);
83    }
84    {
85      OsiClpSolverInterface clpSi;
86      testingMessage( "Testing OsiRowCutDebugger with OsiClpSolverInterface\n" );
87      OsiRowCutDebuggerUnitTest(&clpSi,mpsDir);
88    }
89
90    /*
91      Run the OsiXXX class test. It's up to the OsiClp implementor
92      to decide whether or not to run OsiSolverInterfaceCommonUnitTest. Arguably
93      this should be required.
94    */
95    testingMessage( "Testing OsiClpSolverInterface\n" );
96    OsiClpSolverInterfaceUnitTest(mpsDir,netlibDir);
97
98    /*
99      We have run the specialised unit test. Check now to see if we need to
100      run through the Netlib problems.
101    */
102    if (parms.find("-testOsiSolverInterface") != parms.end())
103    {
104      // Create vector of solver interfaces
105      std::vector<OsiSolverInterface*> vecSi(1, new OsiClpSolverInterface);
106
107      testingMessage( "Testing OsiSolverInterface on Netlib problems.\n" );
108      OsiSolverInterfaceMpsUnitTest(vecSi,netlibDir);
109
110      delete vecSi[0];
111    }
112    else {
113      testingMessage( "***Skipped Testing of OsiClpSolverInterface on Netlib problems***\n" );
114      testingMessage( "***use -testOsiSolverInterface to run them.***\n" );
115    }
116  } catch (CoinError& error) {
117    std::cout.flush();
118    std::cerr << "Caught CoinError exception: ";
119    error.print(true);
120    exception = true;
121  }
122
123  /*
124    We're done. Report on the results.
125  */
126  std::cout.flush();
127  outcomes.print();
128
129  int nerrors;
130  int nerrors_expected;
131  outcomes.getCountBySeverity(TestOutcome::ERROR, nerrors, nerrors_expected);
132
133  if (nerrors > nerrors_expected)
134    std::cerr << "Tests completed with " << nerrors - nerrors_expected << " unexpected errors." << std::endl ;
135  else
136    std::cerr << "All tests completed successfully\n";
137
138  return (nerrors - nerrors_expected) + (exception ? 1 : 0);
139}
Note: See TracBrowser for help on using the repository browser.