Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to prevent cycles (a numerical stability issue) #57

Merged
merged 1 commit into from
May 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/engine/Tableau.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,8 @@ void Tableau::dumpAssignment()
for ( unsigned i = 0; i < _n; ++i )
{
bool basic = _basicVariables.exists( i );
printf( "\tx%u --> %.5lf [%s]. ", i, getValue( i ), basic ? "B" : "NB" );
printf( "\tx%u (index: %u) --> %.5lf [%s]. ", i, _variableToIndex[i],
getValue( i ), basic ? "B" : "NB" );
if ( _lowerBounds[i] != FloatUtils::negativeInfinity() )
printf( "Range: [ %.5lf, ", _lowerBounds[i] );
else
Expand Down Expand Up @@ -1688,6 +1689,17 @@ void Tableau::updateAssignmentForPivot()

_basicAssignmentStatus = ITableau::BASIC_ASSIGNMENT_UPDATED;

// If the change ratio is 0, just maintain the current assignment
if ( FloatUtils::isZero( _changeRatio ) )
{
double basicAssignment = _basicAssignment[_leavingVariable];
double nonBasicAssignment = _nonBasicAssignment[_enteringVariable];

_basicAssignment[_leavingVariable] = nonBasicAssignment;
_nonBasicAssignment[_enteringVariable] = basicAssignment;
return;
}

if ( performingFakePivot() )
{
// A non-basic is hopping from one bound to the other.
Expand Down Expand Up @@ -1759,7 +1771,7 @@ void Tableau::updateAssignmentForPivot()
continue;

if ( FloatUtils::isZero( _changeColumn[i] ) )
continue;
continue;

_basicAssignment[i] -= _changeColumn[i] * nonBasicDelta;
notifyVariableValue( _basicIndexToVariable[i], _basicAssignment[i] );
Expand Down
3 changes: 2 additions & 1 deletion src/engine/tests/Test_Tableau.h
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,8 @@ class TableauTestSuite : public CxxTest::TestSuite
tableau->setEnteringVariableIndex( 3u );
tableau->computeChangeColumn();

tableau->setLeavingVariableIndex( 3u );
tableau->pickLeavingVariable();

TS_ASSERT_EQUALS( tableau->getEnteringVariable(), 3u );
TS_ASSERT_EQUALS( tableau->getLeavingVariable(), 3u );

Expand Down