Skip to content

Commit

Permalink
Merge pull request #23 from Argonne-National-Laboratory/test-cases
Browse files Browse the repository at this point in the history
Test cases
  • Loading branch information
cnpetra committed Jun 6, 2016
2 parents c8a43dd + 6048ba1 commit 7c3b34c
Show file tree
Hide file tree
Showing 48 changed files with 29,626 additions and 200 deletions.
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ message(STATUS "BUILD_PIPS_S=${BUILD_PIPS_S}")
message(STATUS "BUILD_PIPS_IPM=${BUILD_PIPS_IPM}")
message(STATUS "BUILD_PIPS_NLP=${BUILD_PIPS_NLP}")

#with testing of (selected) executables
option(WITH_MAKETEST "Enable 'make test'" ON)

#with NLP profile metric
option(WITH_NLPTIMING "Build with timing for PIPS-NLP" OFF)
option(WITH_VERBOSE "Build with extra verbosity level" OFF)
Expand Down Expand Up @@ -432,6 +435,26 @@ endif(BUILD_PIPS_NLP)
#add_subdirectory(src/SMPS)
#endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "BlueGeneP-static")

##########################################################
# CMake Tests
##########################################################
if (WITH_MAKETEST)
enable_testing()

if(BUILD_PIPS_IPM)
add_test(NAME PIPS-IPM-multipleTests COMMAND sh ${PROJECT_SOURCE_DIR}/PIPS-IPM/Test/pipsipmMultiTests.sh $<TARGET_FILE:pipsipmFromRaw> ${PROJECT_SOURCE_DIR}/PIPS-S/Test/rawInput)
endif(BUILD_PIPS_IPM)

if(BUILD_PIPS_S)
add_test(NAME PIPS-S-multipleTests COMMAND sh ${PROJECT_SOURCE_DIR}/PIPS-S/Test/pipssMultiTests.sh $<TARGET_FILE:pipssFromRaw> ${PROJECT_SOURCE_DIR}/PIPS-S/Test/rawInput)
endif(BUILD_PIPS_S)

if(BUILD_PIPS_NLP)
add_test(NAME PIPS-NLP-simpleTest1 COMMAND $<TARGET_FILE:parmodel2> -objcheck)
add_test(NAME PIPS-NLP-simpleTest2 COMMAND $<TARGET_FILE:parmodel3> -objcheck)
endif(BUILD_PIPS_NLP)

endif(WITH_MAKETEST)

message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
Expand Down
37 changes: 23 additions & 14 deletions PIPS-IPM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ if (HAVE_PARDISO)
# ${MA57_LIBRARY} ${METIS_LIBRARY} ${PARDISO_LIBRARY32} ${MATH_LIBS})

if(HAVE_MA27)
add_executable(pipsipmFromRaw Drivers/pipsipmFromRaw.cpp)
target_link_libraries(pipsipmFromRaw
stochInput ${COIN_LIBS}
ooqpstoch ooqpstochla ooqpmehrotrastoch
ooqpgensparse ooqpbase ooqpsparse ooqpdense
${MA27_LIBRARY} ${MA57_LIBRARY} ${METIS_LIBRARY} ${PARDISO_LIBRARY} ${MATH_LIBS})
# add_executable(pipsipmFromRaw Drivers/pipsipmFromRaw.cpp)
# target_link_libraries(pipsipmFromRaw
# stochInput ${COIN_LIBS}
# ooqpstoch ooqpstochla ooqpmehrotrastoch
# ooqpgensparse ooqpbase ooqpsparse ooqpdense
# ${MA27_LIBRARY} ${MA57_LIBRARY} ${METIS_LIBRARY} ${PARDISO_LIBRARY} ${MATH_LIBS})

add_executable(ooqpFromRaw Drivers/ooqpFromRaw.cpp)
target_link_libraries(ooqpFromRaw
Expand All @@ -116,13 +116,22 @@ if (HAVE_PARDISO)

endif(HAVE_MA27)

if(HAVE_AMPL)
add_executable(pipsipmPyomo_schur Drivers/pipsipmPyomo_schur.cpp)
target_link_libraries(pipsipmPyomo_schur
pyomoStochInput stochInput ${COIN_LIBS}
ooqpstoch ooqpstochla ooqpmehrotrastoch
ooqpgensparse ooqpbase ooqpsparse ooqpdense
${AMPL_LIBRARY} ${MA57_LIBRARY} ${METIS_LIBRARY} ${PARDISO_LIBRARY} ${MATH_LIBS})
endif(HAVE_AMPL)
# if(HAVE_AMPL)
# add_executable(pipsipmPyomo_schur Drivers/pipsipmPyomo_schur.cpp)
# target_link_libraries(pipsipmPyomo_schur
# pyomoStochInput stochInput ${COIN_LIBS}
# ooqpstoch ooqpstochla ooqpmehrotrastoch
# ooqpgensparse ooqpbase ooqpsparse ooqpdense
# ${AMPL_LIBRARY} ${MA57_LIBRARY} ${METIS_LIBRARY} ${PARDISO_LIBRARY} ${MATH_LIBS})
# endif(HAVE_AMPL)
endif(HAVE_MA57 AND HAVE_METIS)
endif(HAVE_PARDISO)

#MA27 or MA57 and METIS are prerequisites, this should be fine without additional checks.
#It still works if only one of MA27 or MA57 is available.
add_executable(pipsipmFromRaw Drivers/pipsipmFromRaw.cpp)
target_link_libraries(pipsipmFromRaw
stochInput ${COIN_LIBS}
ooqpstoch ooqpstochla ooqpmehrotrastoch
ooqpgensparse ooqpbase ooqpsparse ooqpdense
${MA27_LIBRARY} ${MA57_LIBRARY} ${METIS_LIBRARY} ${MATH_LIBS})
2 changes: 1 addition & 1 deletion PIPS-IPM/Core/QpStoch/sTreeCallbacks.C
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ StochVector* sTreeCallbacks::createc() const
double* vData = ((SimpleVector*)c->vec)->elements();
if (!fakedata) {
// populate the node's data with data from user.
if(children.size()>0) RESCALE=0.001/1000;//children.size();
//if(children.size()>0) RESCALE=0.001/1000;//children.size();
if(0==rankMe)
cout << "RESCALE set to " << RESCALE << endl;

Expand Down
4 changes: 1 addition & 3 deletions PIPS-IPM/Core/QpStoch/sTreeImpl.C
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ StochSymMatrix* sTreeImpl::createQ() const
return NULL;
}

//#define RESCALE 200

static double RESCALE=1.0;
StochVector* sTreeImpl::createc() const
{
Expand All @@ -135,7 +133,7 @@ StochVector* sTreeImpl::createc() const
double* vec = ((SimpleVector*)svec->vec)->elements();

if(m_id==0) {
RESCALE=1.0/children.size();
//RESCALE=1.0/children.size();
cout << "RESCALE set to " << RESCALE << endl;
#ifdef TIMING
//RESCALE=1;//0.25*children.size();
Expand Down
9 changes: 6 additions & 3 deletions PIPS-IPM/Drivers/pipsipmFromRaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "sFactoryAug.h"
#include "MehrotraStochSolver.h"

#include <limits>

using namespace std;

// two ways of solving
Expand Down Expand Up @@ -53,11 +55,12 @@ int solve(const string& datarootname, int nscen) {
if (mype == 0) cout << "PIPSIpmInterface created .." << endl;
delete s;
if (mype == 0) cout << "rawInput deleted ... solving" << endl;
pipsIpm.go();



pipsIpm.go();

double obj = pipsIpm.getObjective();
//cout << "PIPS-IPM: optimal objective: " << obj << endl;
printf("PIPS-IPM: optimal objective: %.8f \n", obj);

return 0;
}
Expand Down
60 changes: 60 additions & 0 deletions PIPS-IPM/Test/pipsipmMultiTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#/bin/bash

# Test script called by CMake CTest during 'make test'. Can also be used separately.
# Usage:
# pipsipmMultiTestsScript.sh <pipsipmRawDriver> <rootDirRawInput>
#
#
# The script checks the output of the PIPS-S driver for correctness when applied to a
# a couple of small test problems (in 'raw input' format)

check_output()
{
pipsscmd="$1 $2 8"
output=$($pipsscmd 2>&1 | grep "$3")

if [ "$output" == "" ]
then
return 0 #no match, return false
else
return 1
fi
}

echo "$2/20data/problemdata 8" > log.log

exe=$1

check_output $exe "$2/20data/problemdata 8" 'optimal objective: 250917'
if [ "$?" -eq "0" ]; then
echo '20data not ok'
exit 1
fi

check_output $exe "$2/LandSdata/problemdata 8" 'optimal objective: 224.01'
if [ "$?" -eq "0" ]; then
echo 'LandSdata not ok'
exit 1
fi

check_output $exe "$2/ssndata/problemdata 8" 'optimal objective: 0.00'
if [ "$?" -eq "0" ]; then
echo 'ssndata not ok'
exit 1
fi

#this is valid but slow...
#check_output $exe "$2/stormdata/problemdata 8" 'optimal objective: 1.5500' #1.55008e+07
#if [ "$?" -eq "0" ]; then
# #in case the output is formated differently
# check_output $exe "$2/stormdata/problemdata 8" 'optimal objective: 155007'
# if [ "$?" -eq "0" ]; then
# echo 'stormdata not ok'
# exit 1
# fi
#fi

echo 'all tests passed'
exit 0


11 changes: 5 additions & 6 deletions PIPS-NLP/Core/NlpStoch/NlpPIPSIpmInterface.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* PIPS-IPM *
* Author: Cosmin G. Petra *
* (C) 2012 Argonne National Laboratory. See Copyright Notification. */

/* 2015. Modified by Nai-Yuan Chiang for NLP*/
/* PIPS-IPM *
* Author: Cosmin G. Petra & Nai-Yuan Chiang *
* (C) 2012-2015 Argonne National Laboratory. */

#ifndef NLPPIPSIPM_INTERFACE
#define NLPPIPSIPM_INTERFACE
Expand Down Expand Up @@ -193,7 +191,8 @@ void NlpPIPSIpmInterface<FORMULATION,IPMSOLVER,UPDATENLP>::go(int addSlack) {

template<typename FORMULATION, typename SOLVER, typename UPDATENLP>
double NlpPIPSIpmInterface<FORMULATION,SOLVER,UPDATENLP>::getObjective() const {
return data->objectiveValue(vars);
//return data->objectiveValue(vars);
return updateNlpInfo->ObjValue(vars);
}


Expand Down
Loading

0 comments on commit 7c3b34c

Please sign in to comment.