My Project
unitTest.cpp File Reference

This file runs the OS unit test. More...

#include "OSConfig.h"
#include "OSCoinSolver.h"
#include "OSmps2OS.h"
#include "OSResult.h"
#include "OSOption.h"
#include "OSiLReader.h"
#include "OSiLWriter.h"
#include "OSoLReader.h"
#include "OSoLWriter.h"
#include "OSrLReader.h"
#include "OSrLWriter.h"
#include "OSInstance.h"
#include "OSFileUtil.h"
#include "OSOutput.h"
#include "CoinError.hpp"
#include "OSDefaultSolver.h"
#include "OSWSUtil.h"
#include "OSSolverAgent.h"
#include "OShL.h"
#include "OSErrorClass.h"
#include "OSBase64.h"
#include "OSMathUtil.h"
#include <CoinMpsIO.hpp>
#include <CoinPackedMatrix.hpp>
#include "CoinHelperFunctions.hpp"
#include "OsiSolverInterface.hpp"

Go to the source code of this file.

Functions

int main (int argC, char *argV[])
 
double getObjVal (std::string osrl)
 
int getItCount (std::string osrl)
 
void tempPrintArrays (OSResult *os)
 

Detailed Description

This file runs the OS unit test.

Author
Horand Gassmann, Jun Ma, Kipp Martin
Remarks
Copyright (C) 2005-2014, Horand Gassmann, Jun Ma, Kipp Martin, Northwestern University, and the University of Chicago. All Rights Reserved. This software is licensed under the Eclipse Public License. Please see the accompanying LICENSE file in root directory for terms.

This is the OS unit test. It runs a large number of tests of most aspects of the Optimization Services suite. The tests fall into different categories and can be switched on and off selectively by setting appropriate boolean variables from the command line interface.

BASIC_TESTS; // minimal functionality tests SOLVER_TESTS; // at least one problem for each solver THOROUGH; // multiple problems for some solvers PARSER_TESTS; // test parser logic OTHER_TESTS; // other input formats, automatic differentiation, etc.

Specifically, the following tests are run

Basic tests (if BASIC_TESTS == TRUE) File handling: open and read a file Lossless I/O: read/write several floating point numbers and check for equality nonlinear operators and automatic differentiation

Parser tests (if PARSER_TESTS == TRUE) Parse an osil, osol and osrl file Test convenience methods, reader and writer routines

Solver tests (if SOLVER_TESTS == TRUE and the solver in question is available)

COIN-Clp tested on parincLinearByRow.osil parincQuadratic.osil

COIN-Cbc tested on:

  1. p0033.osil
  2. p0033MULT.osil
  3. p0033.osil with a node limit set (solver option)
  4. p0201.osil
  5. parincInteger.osil

    COIN-SYMPHONY tested on p0033.osil

    COIN-DyLP tested on parincLinear.osil

    COIN-Vol tested on volumeTest.osil

    GLPK tested on p0033.osil

    Cplex tested on p0033.osil parincQuadratic.osil

    Gurobi tested on p0033.osil parincQuadratic.osil

    Mosek tested on p0033.osil parincQuadratic.osil

    Soplex tested on p0033.osil

    Xpress tested on p0033.osil parincQuadratic.osil

    COIN-Ipopt tested on:

    1. avion2.osil
    2. HS071_NLPMod.osil
    3. rosenbrockmod.osil
    4. parincQuadratic.osil
    5. parincLinear.osil
    6. callBackTest.osil
    7. callBackTestRowMajor.osil
    8. rosenbrockorig.osil
    9. HS071_feas.osil

    COIN-BONMIN tested on

    1. bonminEx1.osil
    2. wayneQuadratic.osil (two different option settings)
    3. rosenbrockorig.osil
    4. rosenbrockorigInt.osil

      COIN-COUENNE tested on

      1. bonminEx1.osil
      2. bonminEx1_Nonlinear.osil
      3. nonconvex.osil
      4. rosenbrockorig.osil
      5. wayneQuadratic.osil (two different option settings)

        Lindo tested on:

        1. lindoapiaddins.osil
        2. rosenbrockmod.osil
        3. parincquadratic.osil
        4. wayneQuadratic.osil

        Additional tests (if OTHER_TESTS == TRUE)

        We test the mps to osil converter class OSmps2OS on parinc.mps and solve with Cbc. on parincQuadratic.mps and solve with Ipopt.

        We test the AMPL nl file format to osil converter class OSnl2OS on parinc.nl and solve with Cbc.

        We test the base 64 format on problem parinc.
        We first read the parinc.mps file into an osil string and then set m_bWriteBase64 = true. We then write a new instance in base 64 format and solve it with Cbc.

        Finally we test the prefix and postfix routines. For the test problem rosenbrockmod.osil we create an OSExpressionTree from the objective function. Then we invoke the getPostfix() method and get a postfix vector representation of the expression tree. We use createExpressionTreeFromPostfix to create another expression tree, then use getPrefix() to get a prefix vector from this expression tree. Then we use createExpressionTreeFromPrefix to create an expression. We use getPostfix() to get the postfix vector back and compare with the very first postfix vector and make sure they are the same.

Definition in file unitTest.cpp.

Function Documentation

◆ main()

int main ( int argC,
char * argV[] )

define commonly used objects and arrays Unless explicitly stated otherwise, each test is responsible for its own memory management (i.e., new and delete)

in this part of the unitTest we 1) read an OSoL string from a file 2) create an OSOption object from the string 3) add options to various array-valued elements 4) retrieve pieces of the OSOption object with get() methods 5) insert these pieces into a second OSOption object with set() methods 6) compare the two OSOption objects to make sure they are equal 7) write a new OSoL string from the in-memory OSOption object 8) read the string back again into a third OSOption object 9) compare to the original OSOption object 10) read two more OSoL strings from different files 11) test the deep copy

Now test the utility methods for the OSrL parser, in three steps.

The first test just ensures that the set() and IsEqual() methods work correctly. Two OSResult objects are built one element and attribute at a time. After every call to the appropriate set() method the two objects are compared: After the first object has been modified, the objects should compare NOT equal; after the second object has been updated in the same way, the objects should again be equal.

The second test verifies the get() methods. The OSResult object just created is duplicated using get() and set() methods. At the end, the duplicated object is compared to the original. The test requires both to be equal.

in this part of the unitTest we 1) read an OSrL string from a file 2) create an OSResult object from the string 3) write a new OSrL string from the in-memory OSResult object 4) read the string back again to make sure nothing was lost in translation This sequence of steps is repeated for files of different sparsity to make sure empty elements are handled properly.

Definition at line 269 of file unitTest.cpp.

◆ getObjVal()

double getObjVal ( std::string osrl)

Definition at line 10398 of file unitTest.cpp.

◆ getItCount()

int getItCount ( std::string osrl)

Definition at line 10423 of file unitTest.cpp.

◆ tempPrintArrays()

void tempPrintArrays ( OSResult * os)

Definition at line 10450 of file unitTest.cpp.