Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-haoze committed Aug 12, 2024
1 parent 1905555 commit 19fec6a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/engine/SumOfInfeasibilitiesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ void SumOfInfeasibilitiesManager::setPhaseStatusInCurrentPhasePattern(
_currentPhasePattern[constraint] = phase;
}

void SumOfInfeasibilitiesManager::setPLConstraintsInCurrentPhasePattern(
const Vector<PiecewiseLinearConstraint *> &constraints )
{
_plConstraintsInCurrentPhasePattern = constraints;
}

void SumOfInfeasibilitiesManager::getCostReduction( PiecewiseLinearConstraint *plConstraint,
double &reducedCost,
PhaseStatus &phaseOfReducedCost ) const
Expand Down
2 changes: 2 additions & 0 deletions src/engine/SumOfInfeasibilitiesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class SumOfInfeasibilitiesManager
void setPhaseStatusInCurrentPhasePattern( PiecewiseLinearConstraint *constraint,
PhaseStatus phase );

void
setPLConstraintsInCurrentPhasePattern( const Vector<PiecewiseLinearConstraint *> &constraints );

private:
const List<PiecewiseLinearConstraint *> &_plConstraints;
Expand Down
3 changes: 3 additions & 0 deletions src/engine/tests/Test_SumOfInfeasibilitiesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ class SumOfInfeasibilitiesManagerTestSuite : public CxxTest::TestSuite
new SumOfInfeasibilitiesManager( ipq, tableau ) ) );

TS_ASSERT_THROWS_NOTHING( soiManager->initializePhasePattern() );
TS_ASSERT_THROWS_NOTHING(
soiManager->setPLConstraintsInCurrentPhasePattern( plConstraints ) );

for ( const auto &plConstraint : plConstraints )
{
Expand All @@ -313,6 +315,7 @@ class SumOfInfeasibilitiesManagerTestSuite : public CxxTest::TestSuite
TS_ASSERT_THROWS_NOTHING( plConstraints[3]->getCostFunctionComponent(
cost1, *( plConstraints[3]->getAllCases().begin() ) ) );


TS_ASSERT_EQUALS( soiManager->getConstraintsUpdatedInLastProposal().size(), 1u );
TS_ASSERT_EQUALS( *soiManager->getConstraintsUpdatedInLastProposal().begin(),
plConstraints[1] );
Expand Down

0 comments on commit 19fec6a

Please sign in to comment.