MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Definition at line 106 of file CompositeOFTest.cpp.
CompositeOFTest::CompositeOFTest | ( | ) | [inline] |
CompositeOFTest::CPPUNIT_TEST | ( | test_add_value | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_multiply_value | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_add_value | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_multiply_value | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_add_gradient | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_multiply_gradient | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_add_gradient | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_multiply_gradient | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_add_hess_diagonal | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_multiply_hess_diagonal | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_add_hess_diagonal | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_add_hessian | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_multiply_hessian | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_add_hessian | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_multiply_hessian | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_clone_add | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_clone_multiply | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_clone_scalar_add | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_clone_scalar_multiply | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_add_invalid | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_multiply_invalid | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_add_invalid | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_multiply_invalid | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_add_error | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_multiply_error | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_add_error | ) | [private] |
CompositeOFTest::CPPUNIT_TEST | ( | test_scalar_multiply_error | ) | [private] |
CompositeOFTest::CPPUNIT_TEST_SUITE | ( | CompositeOFTest | ) | [private] |
CompositeOFTest::CPPUNIT_TEST_SUITE_END | ( | ) | [private] |
void CompositeOFTest::get_hessians | ( | MsqHessian & | LP1_hess, |
MsqHessian & | LP2_hess, | ||
ObjectiveFunction & | OF, | ||
MsqHessian & | OF_hess | ||
) |
Definition at line 271 of file CompositeOFTest.cpp.
References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, MBMesquite::create_twelve_hex_patch(), MBMesquite::ObjectiveFunction::evaluate_with_Hessian(), MBMesquite::grad(), MBMesquite::MsqHessian::initialize(), and value().
{ MsqPrintError err( cout ); PatchData pd; create_twelve_hex_patch( pd, err ); ASSERT_NO_ERROR( err ); LP1_hess.initialize( pd, err ); ASSERT_NO_ERROR( err ); LP2_hess.initialize( pd, err ); ASSERT_NO_ERROR( err ); OF_hess.initialize( pd, err ); ASSERT_NO_ERROR( err ); std::vector< Vector3D > grad; bool rval; double value; rval = LP1.evaluate_with_Hessian( ObjectiveFunction::CALCULATE, pd, value, grad, LP1_hess, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); rval = LP2.evaluate_with_Hessian( ObjectiveFunction::CALCULATE, pd, value, grad, LP2_hess, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); rval = OF.evaluate_with_Hessian( ObjectiveFunction::CALCULATE, pd, value, grad, OF_hess, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); }
void CompositeOFTest::test_add_error | ( | ) |
Definition at line 557 of file CompositeOFTest.cpp.
{ CompositeOFAdd add1( &OF1, &errorOF ); test_eval_fails( add1 ); CompositeOFAdd add2( &errorOF, &OF3 ); test_eval_fails( add2 ); }
void CompositeOFTest::test_add_gradient | ( | ) |
Definition at line 250 of file CompositeOFTest.cpp.
{ CompositeOFAdd OF( &LP1, &LP2 ); compare_numerical_gradient( &OF ); }
Definition at line 302 of file CompositeOFTest.cpp.
{ CompositeOFAdd OF( &LP1, &LP2 ); compare_hessian_diagonal( &OF ); }
void CompositeOFTest::test_add_hessian | ( | ) |
Definition at line 368 of file CompositeOFTest.cpp.
References b, b1, b2, CPPUNIT_ASSERT_MATRICES_EQUAL, MBMesquite::MsqHessian::get_block(), MBMesquite::hess(), and MBMesquite::MsqHessian::size().
{ // test value and gradient CompositeOFAdd OF( &LP1, &LP2 ); compare_hessian_gradient( &OF ); // test actual hessian values MsqHessian hess1, hess2, hess; get_hessians( hess1, hess2, OF, hess ); Matrix3D *b1, *b2, *b; for( unsigned r = 0; r < hess.size(); ++r ) { for( unsigned c = r; c < hess.size(); ++c ) { b1 = hess1.get_block( r, c ); b2 = hess2.get_block( r, c ); b = hess.get_block( r, c ); if( b ) { CPPUNIT_ASSERT_MATRICES_EQUAL( *b1 + *b2, *b, 1e-6 ); } } } }
void CompositeOFTest::test_add_invalid | ( | ) |
Definition at line 527 of file CompositeOFTest.cpp.
{ CompositeOFAdd add1( &OF1, &invalidOF ); test_invalid_eval( add1 ); CompositeOFAdd add2( &invalidOF, &OF3 ); test_invalid_eval( add2 ); }
void CompositeOFTest::test_add_value | ( | ) |
Definition at line 214 of file CompositeOFTest.cpp.
References test_evaluate().
{ CompositeOFAdd add1( &OF1, &OF2 ); test_evaluate( OF1.get_value() + OF2.get_value(), add1 ); CompositeOFAdd add2( &OF3, &OF4 ); test_evaluate( OF3.get_value() + OF4.get_value(), add2 ); }
void CompositeOFTest::test_clone_add | ( | ) |
Definition at line 488 of file CompositeOFTest.cpp.
{ CompositeOFAdd OF( &OF1, &OF2 ); test_composite_clone( OF ); }
void CompositeOFTest::test_clone_multiply | ( | ) |
Definition at line 493 of file CompositeOFTest.cpp.
{ CompositeOFMultiply OF( &OF1, &OF2 ); test_composite_clone( OF ); }
Definition at line 498 of file CompositeOFTest.cpp.
{ CompositeOFScalarAdd OF( 2.1, &OF2 ); test_composite_clone( OF ); }
Definition at line 503 of file CompositeOFTest.cpp.
{ CompositeOFScalarMultiply OF( 0.333, &OF2 ); test_composite_clone( OF ); }
void CompositeOFTest::test_composite_clone | ( | ObjectiveFunction & | of | ) |
Definition at line 460 of file CompositeOFTest.cpp.
References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, MBMesquite::ObjectiveFunction::clone(), CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_EQUAL, MBMesquite::ObjectiveFunction::evaluate(), and FauxObjectiveFunction::get_instance_count().
{ // save current count of instances of underlying OFs for later const int init_count = FauxObjectiveFunction::get_instance_count(); // clone the objective function ObjectiveFunction* clone = OF.clone(); // check that the underlying OFs were also cloned CPPUNIT_ASSERT( init_count < FauxObjectiveFunction::get_instance_count() ); // check that the value is the same MsqPrintError err( cout ); double orig_val, clone_val; bool rval; rval = OF.evaluate( ObjectiveFunction::CALCULATE, patch(), orig_val, false, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); rval = clone->evaluate( ObjectiveFunction::CALCULATE, patch(), clone_val, false, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( orig_val, clone_val, 1e-6 ); // check that cloned instances of underlying OFs are deleted delete clone; CPPUNIT_ASSERT_EQUAL( init_count, FauxObjectiveFunction::get_instance_count() ); }
void CompositeOFTest::test_eval_fails | ( | ObjectiveFunction & | of | ) |
Definition at line 519 of file CompositeOFTest.cpp.
References MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT_EQUAL, MBMesquite::MsqError::error_code(), MBMesquite::ObjectiveFunction::evaluate(), MBMesquite::MsqError::INTERNAL_ERROR, and value().
{ MsqError err; double value; OF.evaluate( ObjectiveFunction::CALCULATE, patch(), value, false, err ); CPPUNIT_ASSERT_EQUAL( MsqError::INTERNAL_ERROR, err.error_code() ); }
void CompositeOFTest::test_evaluate | ( | double | expected_value, |
ObjectiveFunction & | of | ||
) |
Definition at line 204 of file CompositeOFTest.cpp.
References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, MBMesquite::ObjectiveFunction::evaluate(), and value().
{ MsqPrintError err( cout ); double value; bool rval = OF.evaluate( ObjectiveFunction::CALCULATE, patch(), value, false, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( expected, value, 1e-6 ); }
void CompositeOFTest::test_invalid_eval | ( | ObjectiveFunction & | of | ) |
Definition at line 509 of file CompositeOFTest.cpp.
References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, MBMesquite::ObjectiveFunction::evaluate(), and value().
{ MsqPrintError err( cout ); bool rval; double value; rval = OF.evaluate( ObjectiveFunction::CALCULATE, patch(), value, false, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval == false ); }
void CompositeOFTest::test_multiply_error | ( | ) |
Definition at line 566 of file CompositeOFTest.cpp.
{ CompositeOFMultiply mult1( &OF1, &errorOF ); test_eval_fails( mult1 ); CompositeOFMultiply mult2( &errorOF, &OF3 ); test_eval_fails( mult2 ); }
Definition at line 255 of file CompositeOFTest.cpp.
{ CompositeOFMultiply OF( &LP1, &LP2 ); compare_numerical_gradient( &OF ); }
Definition at line 308 of file CompositeOFTest.cpp.
References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_EQUAL, CPPUNIT_ASSERT_MATRICES_EQUAL, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::create_twelve_hex_patch(), MBMesquite::CompositeOFMultiply::evaluate_with_Hessian_diagonal(), MBMesquite::grad(), MBMesquite::hess(), MBMesquite::PatchData::num_free_vertices(), MBMesquite::Matrix3D::outer_product(), MBMesquite::transpose(), and value().
{ CompositeOFMultiply OF( &LP1, &LP2 ); std::vector< SymMatrix3D > hess1, hess2, hess; MsqPrintError err( cout ); PatchData pd; create_twelve_hex_patch( pd, err ); ASSERT_NO_ERROR( err ); std::vector< Vector3D > grad1, grad2, grad; bool rval; double value1, value2, value; rval = LP1.evaluate_with_Hessian_diagonal( ObjectiveFunction::CALCULATE, pd, value1, grad1, hess1, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); rval = LP2.evaluate_with_Hessian_diagonal( ObjectiveFunction::CALCULATE, pd, value2, grad2, hess2, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); rval = OF.evaluate_with_Hessian_diagonal( ObjectiveFunction::CALCULATE, pd, value, grad, hess, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_EQUAL( pd.num_free_vertices(), grad1.size() ); CPPUNIT_ASSERT_EQUAL( pd.num_free_vertices(), grad2.size() ); CPPUNIT_ASSERT_EQUAL( pd.num_free_vertices(), grad.size() ); CPPUNIT_ASSERT_EQUAL( pd.num_free_vertices(), hess1.size() ); CPPUNIT_ASSERT_EQUAL( pd.num_free_vertices(), hess2.size() ); CPPUNIT_ASSERT_EQUAL( pd.num_free_vertices(), hess.size() ); CPPUNIT_ASSERT_DOUBLES_EQUAL( value1 * value2, value, 1e-6 ); for( size_t i = 0; i < pd.num_free_vertices(); ++i ) { const Vector3D expected_grad = value2 * grad1[i] + value1 * grad2[i]; CPPUNIT_ASSERT_VECTORS_EQUAL( expected_grad, grad[i], 1e-6 ); Matrix3D o; o.outer_product( grad1[i], grad2[i] ); Matrix3D expect = o + transpose( o ); expect += value2 * hess1[i]; expect += value1 * hess2[i]; CPPUNIT_ASSERT_MATRICES_EQUAL( expect, Matrix3D( hess[i] ), 1e-6 ); } }
Definition at line 393 of file CompositeOFTest.cpp.
References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, MBMesquite::create_twelve_hex_patch(), MBMesquite::CompositeOFMultiply::evaluate_with_Hessian(), MBMesquite::grad(), MBMesquite::hess(), MBMesquite::MsqHessian::initialize(), and value().
{ MsqError err; PatchData pd; create_twelve_hex_patch( pd, err ); ASSERT_NO_ERROR( err ); // this should always fail because the Hessian is not sparse CompositeOFMultiply OF( &LP1, &LP2 ); double value; MsqHessian hess; hess.initialize( pd, err ); ASSERT_NO_ERROR( err ); std::vector< Vector3D > grad; OF.evaluate_with_Hessian( ObjectiveFunction::CALCULATE, pd, value, grad, hess, err ); CPPUNIT_ASSERT( err ); }
Definition at line 536 of file CompositeOFTest.cpp.
{ CompositeOFMultiply mult1( &OF1, &invalidOF ); test_invalid_eval( mult1 ); CompositeOFMultiply mult2( &invalidOF, &OF3 ); test_invalid_eval( mult2 ); }
void CompositeOFTest::test_multiply_value | ( | ) |
Definition at line 223 of file CompositeOFTest.cpp.
References test_evaluate().
{ CompositeOFMultiply mult1( &OF1, &OF2 ); test_evaluate( OF1.get_value() * OF2.get_value(), mult1 ); CompositeOFMultiply mult2( &OF3, &OF4 ); test_evaluate( OF3.get_value() * OF4.get_value(), mult2 ); }
Definition at line 575 of file CompositeOFTest.cpp.
{ CompositeOFScalarAdd OF( 2.0, &errorOF ); test_eval_fails( OF ); }
Definition at line 260 of file CompositeOFTest.cpp.
{ CompositeOFScalarAdd OF( M_PI, &LP1 ); compare_numerical_gradient( &OF ); }
Definition at line 355 of file CompositeOFTest.cpp.
{ CompositeOFScalarAdd OF( 1111.1, &LP1 ); compare_hessian_diagonal( &OF ); }
Definition at line 411 of file CompositeOFTest.cpp.
References b, b1, CPPUNIT_ASSERT_MATRICES_EQUAL, MBMesquite::MsqHessian::get_block(), MBMesquite::hess(), and MBMesquite::MsqHessian::size().
{ // test value and gradient CompositeOFScalarAdd OF( 1111.1, &LP1 ); compare_hessian_gradient( &OF ); // test actual hessian values MsqHessian hess1, hess2, hess; get_hessians( hess1, hess2, OF, hess ); Matrix3D *b1, *b; for( unsigned r = 0; r < hess.size(); ++r ) { for( unsigned c = r; c < hess.size(); ++c ) { b1 = hess1.get_block( r, c ); b = hess.get_block( r, c ); if( b ) { CPPUNIT_ASSERT_MATRICES_EQUAL( *b1, *b, 1e-6 ); } } } }
Definition at line 545 of file CompositeOFTest.cpp.
{ CompositeOFScalarAdd OF( 2.0, &invalidOF ); test_invalid_eval( OF ); }
Definition at line 232 of file CompositeOFTest.cpp.
References test_evaluate().
{ CompositeOFScalarAdd add1( sqrt( 2.0 ), &OF1 ); test_evaluate( OF1.get_value() + sqrt( 2.0 ), add1 ); CompositeOFScalarAdd add2( -1.0, &OF4 ); test_evaluate( OF4.get_value() - 1, add2 ); }
Definition at line 581 of file CompositeOFTest.cpp.
{ CompositeOFScalarMultiply OF( 2.0, &errorOF ); test_eval_fails( OF ); }
Definition at line 265 of file CompositeOFTest.cpp.
{ CompositeOFScalarMultiply OF( M_PI, &LP1 ); compare_numerical_gradient( &OF ); }
Definition at line 361 of file CompositeOFTest.cpp.
References scale().
{ const double scale = 2.5; CompositeOFScalarMultiply OF( scale, &LP1 ); compare_hessian_diagonal( &OF ); }
Definition at line 435 of file CompositeOFTest.cpp.
References b, b1, CPPUNIT_ASSERT_MATRICES_EQUAL, MBMesquite::MsqHessian::get_block(), MBMesquite::hess(), scale(), and MBMesquite::MsqHessian::size().
{ // test value and gradient const double scale = 2.5; CompositeOFScalarMultiply OF( scale, &LP1 ); compare_hessian_gradient( &OF ); // test actual hessian values MsqHessian hess1, hess2, hess; get_hessians( hess1, hess2, OF, hess ); Matrix3D *b1, *b; for( unsigned r = 0; r < hess.size(); ++r ) { for( unsigned c = r; c < hess.size(); ++c ) { b1 = hess1.get_block( r, c ); b = hess.get_block( r, c ); if( b ) { CPPUNIT_ASSERT_MATRICES_EQUAL( scale * *b1, *b, 1e-6 ); } } } }
Definition at line 551 of file CompositeOFTest.cpp.
{ CompositeOFScalarMultiply OF( 2.0, &invalidOF ); test_invalid_eval( OF ); }
Definition at line 241 of file CompositeOFTest.cpp.
References test_evaluate().
{ CompositeOFScalarMultiply mult1( sqrt( 2.0 ), &OF1 ); test_evaluate( OF1.get_value() * sqrt( 2.0 ), mult1 ); CompositeOFScalarMultiply mult2( -1.0, &OF4 ); test_evaluate( -OF4.get_value(), mult2 ); }
Definition at line 148 of file CompositeOFTest.cpp.
Definition at line 148 of file CompositeOFTest.cpp.
LPtoPTemplate CompositeOFTest::LP1 [private] |
Definition at line 150 of file CompositeOFTest.cpp.
LPtoPTemplate CompositeOFTest::LP2 [private] |
Definition at line 150 of file CompositeOFTest.cpp.
Definition at line 149 of file CompositeOFTest.cpp.
FauxObjectiveFunction CompositeOFTest::OF1 [private] |
Definition at line 148 of file CompositeOFTest.cpp.
FauxObjectiveFunction CompositeOFTest::OF2 [private] |
Definition at line 148 of file CompositeOFTest.cpp.
FauxObjectiveFunction CompositeOFTest::OF3 [private] |
Definition at line 148 of file CompositeOFTest.cpp.
FauxObjectiveFunction CompositeOFTest::OF4 [private] |
Definition at line 148 of file CompositeOFTest.cpp.