MOAB: Mesh Oriented datABase  (version 5.3.1)
ObjectiveFunctionTest Class Reference
+ Inheritance diagram for ObjectiveFunctionTest:
+ Collaboration diagram for ObjectiveFunctionTest:

Public Member Functions

 ObjectiveFunctionTest ()
void setUp ()
void test_eval_OF_value_LPtoP_L1 ()
void test_grad_OF_value_LPtoP_L1 ()
void test_diag_OF_value_LPtoP_L1 ()
void test_hess_OF_value_LPtoP_L1 ()
void test_eval_OF_value_LPtoP_L2 ()
void test_grad_OF_value_LPtoP_L2 ()
void test_diag_OF_value_LPtoP_L2 ()
void test_hess_OF_value_LPtoP_L2 ()
void test_eval_OF_value_LPtoP_scaled ()
void test_grad_OF_value_LPtoP_scaled ()
void test_diag_OF_value_LPtoP_scaled ()
void test_hess_OF_value_LPtoP_scaled ()
void test_eval_OF_value_LInf ()
void test_eval_OF_value_max ()
void test_compute_gradient_LPtoPTemplate_L1 ()
void test_compute_gradient_LPtoPTemplate_L2 ()
void test_compute_gradient_LPtoPTemplate_L2_scaled ()
void test_hessian_gradient_LPtoPTemplate_L1 ()
void test_hessian_gradient_LPtoPTemplate_L2 ()
void test_hessian_gradient_LPtoPTemplate_L2_scaled ()
void test_diagonal_gradient_LPtoPTemplate_L1 ()
void test_diagonal_gradient_LPtoPTemplate_L2 ()
void test_diagonal_gradient_LPtoPTemplate_L2_scaled ()
void test_hessian_diagonal_LPtoPTemplate_L1 ()
void test_hessian_diagonal_LPtoPTemplate_L2 ()
void test_hessian_diagonal_LPtoPTemplate_L2_scaled ()
void test_compute_ana_hessian_tet ()
void test_compute_ana_hessian_tet_scaled ()
void test_LPtoP_invalid_qm_eval ()
void test_LPtoP_invalid_qm_grad ()
void test_LPtoP_invalid_qm_diag ()
void test_LPtoP_invalid_qm_hess ()
void test_LInf_invalid_qm_eval ()
void test_max_invalid_qm_eval ()
void test_LPtoP_qm_error_eval ()
void test_LPtoP_qm_error_grad ()
void test_LPtoP_qm_error_diag ()
void test_LPtoP_qm_error_hess ()
void test_LInf_qm_error_eval ()
void test_max_qm_error_eval ()
void test_LPtoP_eval_calc ()
void test_LPtoP_eval_accum ()
void test_LPtoP_eval_save ()
void test_LPtoP_eval_update ()
void test_LPtoP_eval_temp ()
void test_LPtoP_grad_calc ()
void test_LPtoP_grad_save ()
void test_LPtoP_grad_update ()
void test_LPtoP_grad_temp ()
void test_LPtoP_diag_calc ()
void test_LPtoP_diag_save ()
void test_LPtoP_diag_update ()
void test_LPtoP_diag_temp ()
void test_LPtoP_hess_calc ()
void test_LPtoP_hess_save ()
void test_LPtoP_hess_update ()
void test_LPtoP_hess_temp ()
void test_LPtoP_clone_L1 ()
void test_LPtoP_clone_L2 ()
void test_LInf_clone ()
void test_max_clone ()
void test_LPtoP_negate_flag_eval ()
void test_LPtoP_negate_flag_grad ()
void test_LPtoP_negate_flag_diag ()
void test_LPtoP_negate_flag_hess ()
void test_LInf_negate_flag_eval ()
void test_max_negate_flag_eval ()

Private Member Functions

 CPPUNIT_TEST_SUITE (ObjectiveFunctionTest)
 CPPUNIT_TEST (test_eval_OF_value_LPtoP_L1)
 CPPUNIT_TEST (test_grad_OF_value_LPtoP_L1)
 CPPUNIT_TEST (test_diag_OF_value_LPtoP_L1)
 CPPUNIT_TEST (test_hess_OF_value_LPtoP_L1)
 CPPUNIT_TEST (test_eval_OF_value_LPtoP_L2)
 CPPUNIT_TEST (test_grad_OF_value_LPtoP_L2)
 CPPUNIT_TEST (test_diag_OF_value_LPtoP_L2)
 CPPUNIT_TEST (test_hess_OF_value_LPtoP_L2)
 CPPUNIT_TEST (test_eval_OF_value_LPtoP_scaled)
 CPPUNIT_TEST (test_grad_OF_value_LPtoP_scaled)
 CPPUNIT_TEST (test_diag_OF_value_LPtoP_scaled)
 CPPUNIT_TEST (test_hess_OF_value_LPtoP_scaled)
 CPPUNIT_TEST (test_eval_OF_value_LInf)
 CPPUNIT_TEST (test_eval_OF_value_max)
 CPPUNIT_TEST (test_compute_gradient_LPtoPTemplate_L1)
 CPPUNIT_TEST (test_compute_gradient_LPtoPTemplate_L2)
 CPPUNIT_TEST (test_compute_gradient_LPtoPTemplate_L2_scaled)
 CPPUNIT_TEST (test_hessian_gradient_LPtoPTemplate_L1)
 CPPUNIT_TEST (test_hessian_gradient_LPtoPTemplate_L2)
 CPPUNIT_TEST (test_hessian_gradient_LPtoPTemplate_L2_scaled)
 CPPUNIT_TEST (test_diagonal_gradient_LPtoPTemplate_L1)
 CPPUNIT_TEST (test_diagonal_gradient_LPtoPTemplate_L2)
 CPPUNIT_TEST (test_diagonal_gradient_LPtoPTemplate_L2_scaled)
 CPPUNIT_TEST (test_hessian_diagonal_LPtoPTemplate_L1)
 CPPUNIT_TEST (test_hessian_diagonal_LPtoPTemplate_L2)
 CPPUNIT_TEST (test_hessian_diagonal_LPtoPTemplate_L2_scaled)
 CPPUNIT_TEST (test_compute_ana_hessian_tet)
 CPPUNIT_TEST (test_compute_ana_hessian_tet_scaled)
 CPPUNIT_TEST (test_LPtoP_invalid_qm_eval)
 CPPUNIT_TEST (test_LPtoP_invalid_qm_grad)
 CPPUNIT_TEST (test_LPtoP_invalid_qm_diag)
 CPPUNIT_TEST (test_LPtoP_invalid_qm_hess)
 CPPUNIT_TEST (test_LInf_invalid_qm_eval)
 CPPUNIT_TEST (test_max_invalid_qm_eval)
 CPPUNIT_TEST (test_LPtoP_qm_error_eval)
 CPPUNIT_TEST (test_LPtoP_qm_error_grad)
 CPPUNIT_TEST (test_LPtoP_qm_error_diag)
 CPPUNIT_TEST (test_LPtoP_qm_error_hess)
 CPPUNIT_TEST (test_LInf_qm_error_eval)
 CPPUNIT_TEST (test_max_qm_error_eval)
 CPPUNIT_TEST (test_LPtoP_eval_calc)
 CPPUNIT_TEST (test_LPtoP_eval_accum)
 CPPUNIT_TEST (test_LPtoP_eval_save)
 CPPUNIT_TEST (test_LPtoP_eval_update)
 CPPUNIT_TEST (test_LPtoP_eval_temp)
 CPPUNIT_TEST (test_LPtoP_grad_calc)
 CPPUNIT_TEST (test_LPtoP_grad_save)
 CPPUNIT_TEST (test_LPtoP_grad_update)
 CPPUNIT_TEST (test_LPtoP_grad_temp)
 CPPUNIT_TEST (test_LPtoP_diag_calc)
 CPPUNIT_TEST (test_LPtoP_diag_save)
 CPPUNIT_TEST (test_LPtoP_diag_update)
 CPPUNIT_TEST (test_LPtoP_diag_temp)
 CPPUNIT_TEST (test_LPtoP_hess_calc)
 CPPUNIT_TEST (test_LPtoP_hess_save)
 CPPUNIT_TEST (test_LPtoP_hess_update)
 CPPUNIT_TEST (test_LPtoP_hess_temp)
 CPPUNIT_TEST (test_LPtoP_clone_L1)
 CPPUNIT_TEST (test_LPtoP_clone_L2)
 CPPUNIT_TEST (test_LInf_clone)
 CPPUNIT_TEST (test_max_clone)
 CPPUNIT_TEST (test_LPtoP_negate_flag_eval)
 CPPUNIT_TEST (test_LPtoP_negate_flag_grad)
 CPPUNIT_TEST (test_LPtoP_negate_flag_diag)
 CPPUNIT_TEST (test_LPtoP_negate_flag_hess)
 CPPUNIT_TEST (test_LInf_negate_flag_eval)
 CPPUNIT_TEST (test_max_negate_flag_eval)
 CPPUNIT_TEST_SUITE_END ()
void test_LPtoP_value (short P, bool scale, const std::vector< double > &values, OFTestMode mode)
void test_LInf_value (const std::vector< double > &values)
void test_max_value (const std::vector< double > &values)
void test_max_negate_flag (ObjectiveFunctionTemplate &OF)

Private Attributes

std::vector< double > values1
std::vector< double > values2

Detailed Description

Definition at line 68 of file ObjectiveFunctionTest.cpp.


Constructor & Destructor Documentation

Definition at line 163 of file ObjectiveFunctionTest.cpp.

{}

Member Function Documentation

void ObjectiveFunctionTest::setUp ( ) [inline]

Definition at line 165 of file ObjectiveFunctionTest.cpp.

    {
        const double v1[] = { 0, 1, 2, 3, 4, 5 };
        const double v2[] = { -2.5, 0.5, 3.0, M_PI, -25.0, 1.0 };
        std::copy( v1, v1 + sizeof( v1 ) / sizeof( v1[0] ), std::back_inserter( values1 ) );
        std::copy( v2, v2 + sizeof( v2 ) / sizeof( v2[0] ), std::back_inserter( values2 ) );
    }

Definition at line 551 of file ObjectiveFunctionTest.cpp.

References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, CPPUNIT_ASSERT_EQUAL, CPPUNIT_ASSERT_MATRICES_EQUAL, MBMesquite::create_qm_two_tet_patch(), MBMesquite::LPtoPTemplate::evaluate_with_Hessian(), MBMesquite::MsqHessian::get_block(), MBMesquite::MsqHessian::initialize(), MBMesquite::PatchData::num_free_vertices(), MBMesquite::AveragingQM::set_averaging_method(), and MBMesquite::QualityMetric::SUM.

{
    MsqPrintError err( cout );
    PatchData tetPatch;
    create_qm_two_tet_patch( tetPatch, err );
    ASSERT_NO_ERROR( err );

    // creates a mean ratio quality metric ...
    IdealWeightInverseMeanRatio* mean_ratio = new IdealWeightInverseMeanRatio( err );
    CPPUNIT_ASSERT( !err );
    mean_ratio->set_averaging_method( QualityMetric::SUM );

    // ... and builds an objective function with it
    LPtoPTemplate LP2( mean_ratio, 2, err );

    MsqHessian H;
    std::vector< Vector3D > g;
    double dummy;
    H.initialize( tetPatch, err );
    CPPUNIT_ASSERT( !err );
    LP2.evaluate_with_Hessian( ObjectiveFunction::CALCULATE, tetPatch, dummy, g, H, err );
    CPPUNIT_ASSERT( !err );
    CPPUNIT_ASSERT_EQUAL( tetPatch.num_free_vertices(), g.size() );

    Matrix3D mat00( " 2.44444  0.2566   0.181444 "
                    " 0.2566   2.14815  0.104757 "
                    " 0.181444 0.104757 2.07407 " );

    Matrix3D mat13( " 5.47514 3.16659    9.83479 "
                    " -1.11704 -5.29718 -3.67406 "
                    " 10.3635 -13.5358  -15.5638 " );

    CPPUNIT_ASSERT_MATRICES_EQUAL( mat00, *H.get_block( 0, 0 ), 1e-4 );
    CPPUNIT_ASSERT_MATRICES_EQUAL( mat13, *H.get_block( 1, 3 ), 1e-4 );

    delete mean_ratio;
}

Definition at line 589 of file ObjectiveFunctionTest.cpp.

References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, CPPUNIT_ASSERT_EQUAL, CPPUNIT_ASSERT_MATRICES_EQUAL, MBMesquite::create_qm_two_tet_patch(), MBMesquite::LPtoPTemplate::evaluate_with_Hessian(), MBMesquite::MsqHessian::get_block(), MBMesquite::MsqHessian::initialize(), MBMesquite::PatchData::num_free_vertices(), MBMesquite::AveragingQM::set_averaging_method(), MBMesquite::LPtoPTemplate::set_dividing_by_n(), and MBMesquite::QualityMetric::SUM.

{
    MsqPrintError err( cout );
    PatchData tetPatch;
    create_qm_two_tet_patch( tetPatch, err );
    ASSERT_NO_ERROR( err );

    // creates a mean ratio quality metric ...
    IdealWeightInverseMeanRatio* mean_ratio = new IdealWeightInverseMeanRatio( err );
    CPPUNIT_ASSERT( !err );
    mean_ratio->set_averaging_method( QualityMetric::SUM );

    // ... and builds an objective function with it
    LPtoPTemplate LP2( mean_ratio, 2, err );
    LP2.set_dividing_by_n( true );

    MsqHessian H;
    std::vector< Vector3D > g;
    double dummy;
    H.initialize( tetPatch, err );
    CPPUNIT_ASSERT( !err );
    LP2.evaluate_with_Hessian( ObjectiveFunction::CALCULATE, tetPatch, dummy, g, H, err );
    CPPUNIT_ASSERT( !err );
    CPPUNIT_ASSERT_EQUAL( tetPatch.num_free_vertices(), g.size() );

    Matrix3D mat00( " 2.44444  0.2566   0.181444 "
                    " 0.2566   2.14815  0.104757 "
                    " 0.181444 0.104757 2.07407 " );

    mat00 *= .5;

    Matrix3D mat13( " 5.47514 3.16659    9.83479 "
                    " -1.11704 -5.29718 -3.67406 "
                    " 10.3635 -13.5358  -15.5638 " );

    mat13 *= .5;

    CPPUNIT_ASSERT_MATRICES_EQUAL( mat00, *H.get_block( 0, 0 ), 1e-4 );
    CPPUNIT_ASSERT_MATRICES_EQUAL( mat13, *H.get_block( 1, 3 ), 1e-4 );

    //    cout << H <<endl;
    delete mean_ratio;
}

Definition at line 269 of file ObjectiveFunctionTest.cpp.

References MBMesquite::LPtoPTemplate::set_dividing_by_n().

    {
        LPtoPTemplate LP1( 2, NULL );
        LP1.set_dividing_by_n( true );
        compare_numerical_gradient( &LP1 );
    }

Definition at line 185 of file ObjectiveFunctionTest.cpp.

    {
        test_LPtoP_value( 1, false, values1, DIAG );
        test_LPtoP_value( 1, false, values2, DIAG );
    }

Definition at line 209 of file ObjectiveFunctionTest.cpp.

    {
        test_LPtoP_value( 2, false, values1, DIAG );
        test_LPtoP_value( 2, false, values2, DIAG );
    }

Definition at line 307 of file ObjectiveFunctionTest.cpp.

References MBMesquite::LPtoPTemplate::set_dividing_by_n().

    {
        LPtoPTemplate LP1( 2, NULL );
        LP1.set_dividing_by_n( true );
        compare_diagonal_gradient( &LP1 );
    }

Definition at line 173 of file ObjectiveFunctionTest.cpp.

    {
        test_LPtoP_value( 1, false, values1, EVAL );
        test_LPtoP_value( 1, false, values2, EVAL );
    }

Definition at line 197 of file ObjectiveFunctionTest.cpp.

    {
        test_LPtoP_value( 2, false, values1, EVAL );
        test_LPtoP_value( 2, false, values2, EVAL );
    }

Definition at line 179 of file ObjectiveFunctionTest.cpp.

    {
        test_LPtoP_value( 1, false, values1, GRAD );
        test_LPtoP_value( 1, false, values2, GRAD );
    }

Definition at line 203 of file ObjectiveFunctionTest.cpp.

    {
        test_LPtoP_value( 2, false, values1, GRAD );
        test_LPtoP_value( 2, false, values2, GRAD );
    }

Definition at line 191 of file ObjectiveFunctionTest.cpp.

    {
        test_LPtoP_value( 1, false, values1, HESS );
        test_LPtoP_value( 1, false, values2, HESS );
    }

Definition at line 215 of file ObjectiveFunctionTest.cpp.

    {
        test_LPtoP_value( 2, false, values1, HESS );
        test_LPtoP_value( 2, false, values2, HESS );
    }

Definition at line 326 of file ObjectiveFunctionTest.cpp.

References MBMesquite::LPtoPTemplate::set_dividing_by_n().

    {
        LPtoPTemplate LP1( 2, NULL );
        LP1.set_dividing_by_n( true );
        compare_hessian_diagonal( &LP1 );
    }

Definition at line 288 of file ObjectiveFunctionTest.cpp.

References MBMesquite::LPtoPTemplate::set_dividing_by_n().

    {
        LPtoPTemplate LP1( 2, NULL );
        LP1.set_dividing_by_n( true );
        compare_hessian_gradient( &LP1 );
    }

Definition at line 498 of file ObjectiveFunctionTest.cpp.

    {
        LInfTemplate OF( NULL );
        test_clone( &OF );
    }

Definition at line 357 of file ObjectiveFunctionTest.cpp.

    {
        LInfTemplate OF( NULL );
        test_handles_invalid_qm( EVAL, &OF );
    }

Definition at line 536 of file ObjectiveFunctionTest.cpp.

    {
        LInfTemplate OF( NULL );
        test_max_negate_flag( OF );
    }

Definition at line 388 of file ObjectiveFunctionTest.cpp.

    {
        LInfTemplate OF( NULL );
        test_handles_qm_error( EVAL, &OF );
    }
void ObjectiveFunctionTest::test_LInf_value ( const std::vector< double > &  values) [private]

Definition at line 649 of file ObjectiveFunctionTest.cpp.

References MBMesquite::arrptr(), CPPUNIT_ASSERT, and test_value().

{
    CPPUNIT_ASSERT( !values.empty() );

    LInfTemplate OF( NULL );

    double expected = fabs( values[0] );
    for( unsigned i = 1; i < values.size(); ++i )
        if( fabs( values[i] ) > expected ) expected = fabs( values[i] );

    test_value( arrptr( values ), values.size(), expected, EVAL, &OF );
}

Definition at line 488 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate OF( 1, NULL );
        test_clone( &OF );
    }

Definition at line 493 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate OF( 2, NULL );
        test_clone( &OF );
    }

Definition at line 446 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::CALCULATE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::CALCULATE, DIAG, &OF );
    }

Definition at line 451 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::SAVE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::SAVE, DIAG, &OF );
    }

Definition at line 461 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::TEMPORARY.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::TEMPORARY, DIAG, &OF );
    }

Definition at line 456 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::UPDATE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::UPDATE, DIAG, &OF );
    }

Definition at line 404 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::ACCUMULATE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::ACCUMULATE, EVAL, &OF );
    }

Definition at line 399 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::CALCULATE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::CALCULATE, EVAL, &OF );
    }

Definition at line 409 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::SAVE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::SAVE, EVAL, &OF );
    }

Definition at line 419 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::TEMPORARY.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::TEMPORARY, EVAL, &OF );
    }

Definition at line 414 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::UPDATE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::UPDATE, EVAL, &OF );
    }

Definition at line 425 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::CALCULATE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::CALCULATE, GRAD, &OF );
    }

Definition at line 430 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::SAVE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::SAVE, GRAD, &OF );
    }

Definition at line 440 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::TEMPORARY.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::TEMPORARY, GRAD, &OF );
    }

Definition at line 435 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::UPDATE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::UPDATE, GRAD, &OF );
    }

Definition at line 467 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::CALCULATE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::CALCULATE, HESS, &OF );
    }

Definition at line 472 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::SAVE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::SAVE, HESS, &OF );
    }

Definition at line 482 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::TEMPORARY.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::TEMPORARY, HESS, &OF );
    }

Definition at line 477 of file ObjectiveFunctionTest.cpp.

References MBMesquite::ObjectiveFunction::UPDATE.

    {
        LPtoPTemplate OF( 1, NULL );
        test_eval_type( ObjectiveFunction::UPDATE, HESS, &OF );
    }

Definition at line 347 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP1( 1, NULL );
        test_handles_invalid_qm( DIAG, &LP1 );
    }

Definition at line 337 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP1( 1, NULL );
        test_handles_invalid_qm( EVAL, &LP1 );
    }

Definition at line 342 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP1( 1, NULL );
        test_handles_invalid_qm( GRAD, &LP1 );
    }

Definition at line 352 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP1( 1, NULL );
        test_handles_invalid_qm( HESS, &LP1 );
    }

Definition at line 526 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP( 2, NULL );
        test_negate_flag( DIAG, &LP );
    }

Definition at line 516 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP( 2, NULL );
        test_negate_flag( EVAL, &LP );
    }

Definition at line 521 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP( 2, NULL );
        test_negate_flag( GRAD, &LP );
    }

Definition at line 531 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP( 2, NULL );
        test_negate_flag( HESS, &LP );
    }

Definition at line 378 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP1( 1, NULL );
        test_handles_qm_error( DIAG, &LP1 );
    }

Definition at line 368 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP1( 1, NULL );
        test_handles_qm_error( EVAL, &LP1 );
    }

Definition at line 373 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP1( 1, NULL );
        test_handles_qm_error( GRAD, &LP1 );
    }

Definition at line 383 of file ObjectiveFunctionTest.cpp.

    {
        LPtoPTemplate LP1( 1, NULL );
        test_handles_qm_error( HESS, &LP1 );
    }
void ObjectiveFunctionTest::test_LPtoP_value ( short  P,
bool  scale,
const std::vector< double > &  values,
OFTestMode  mode 
) [private]

Definition at line 633 of file ObjectiveFunctionTest.cpp.

References MBMesquite::arrptr(), CPPUNIT_ASSERT, MBMesquite::P, and test_value().

{
    CPPUNIT_ASSERT( !values.empty() );

    LPtoPTemplate OF( P, NULL );
    OF.set_dividing_by_n( scale );

    double expected = 0.0;
    for( std::vector< double >::const_iterator i = values.begin(); i != values.end(); ++i )
        expected += std::pow( fabs( *i ), P );
    if( scale ) expected /= values.size();

    test_value( arrptr( values ), values.size(), expected, mode, &OF );
}

Definition at line 503 of file ObjectiveFunctionTest.cpp.

    {
        MaxTemplate OF( NULL );
        test_clone( &OF );
    }

Definition at line 362 of file ObjectiveFunctionTest.cpp.

    {
        MaxTemplate OF( NULL );
        test_handles_invalid_qm( EVAL, &OF );
    }

Definition at line 675 of file ObjectiveFunctionTest.cpp.

References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, MBMesquite::ObjectiveFunction::evaluate(), OFTestQM::set_negate_flag(), MBMesquite::ObjectiveFunctionTemplate::set_quality_metric(), and value().

{
    // use only positive values so this test works for both
    // MaxTemplate and LInfTemplate
    const double some_vals[] = { 1, 2, 3, 4, 5, 6, 0.5 };
    const unsigned num_vals  = sizeof( some_vals ) / sizeof( some_vals[0] );
    OFTestQM metric( some_vals, num_vals );
    metric.set_negate_flag( -1 );
    of.set_quality_metric( &metric );

    // get OF value
    MsqPrintError err( cout );
    bool rval;
    double value;
    rval = of.evaluate( ObjectiveFunction::CALCULATE, patch(), value, false, err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT( rval );

    // find min value
    double expected = *std::min_element( some_vals, some_vals + num_vals );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( -expected, value, 1e-6 );
}

Definition at line 541 of file ObjectiveFunctionTest.cpp.

    {
        MaxTemplate OF( NULL );
        test_max_negate_flag( OF );
    }

Definition at line 393 of file ObjectiveFunctionTest.cpp.

    {
        MaxTemplate OF( NULL );
        test_handles_qm_error( EVAL, &OF );
    }
void ObjectiveFunctionTest::test_max_value ( const std::vector< double > &  values) [private]

Definition at line 662 of file ObjectiveFunctionTest.cpp.

References MBMesquite::arrptr(), CPPUNIT_ASSERT, and test_value().

{
    CPPUNIT_ASSERT( !values.empty() );

    MaxTemplate OF( NULL );

    double expected = fabs( values[0] );
    for( unsigned i = 1; i < values.size(); ++i )
        if( values[i] > expected ) expected = values[i];

    test_value( arrptr( values ), values.size(), expected, EVAL, &OF );
}

Member Data Documentation

std::vector< double > ObjectiveFunctionTest::values1 [private]

Definition at line 160 of file ObjectiveFunctionTest.cpp.

std::vector< double > ObjectiveFunctionTest::values2 [private]

Definition at line 160 of file ObjectiveFunctionTest.cpp.

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines