Skip to content

Commit

Permalink
Incorrect variable untagging in Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
spond committed Oct 30, 2020
1 parent 89c6820 commit 0ff20b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/core/include/variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class _Variable : public _Constant {
virtual bool CheckFForDependence (_AVLList const&, bool = false);
virtual bool HasBeenInitialized (void) const {return !(varFlags & HY_VARIABLE_NOTSET);}
virtual void MarkModified (void) {varFlags = varFlags | HY_VARIABLE_CHANGED;}
virtual bool IsModified (void) const {return varFlags & HY_VARIABLE_CHANGED;}
virtual void ClearModified (void) {if (varFlags & HY_VARIABLE_CHANGED) varFlags -= HY_VARIABLE_CHANGED;}

_String const ContextFreeName (void) const;
Expand Down
15 changes: 9 additions & 6 deletions src/core/likefunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4126,11 +4126,16 @@ _Matrix* _LikelihoodFunction::Optimize (_AssociativeList const * options)
}
}


_SimpleList untag;
if (keepStartingPoint) {
indexInd.Each ([this] (long v, unsigned long i) -> void {
indexInd.Each ([this, &untag] (long v, unsigned long i) -> void {
_Variable *iv = GetIthIndependentVar (i);
if (iv->HasBeenInitialized()) {
iv->MarkModified();
if (!iv->IsModified()) {
iv->MarkModified();
untag << i;
}
}
});
}
Expand All @@ -4140,11 +4145,9 @@ _Matrix* _LikelihoodFunction::Optimize (_AssociativeList const * options)
}

if (keepStartingPoint) {
indexInd.Each ([this] (long v, unsigned long i) -> void {
untag.Each ([this] (long v, unsigned long i) -> void {
_Variable *iv = GetIthIndependentVar (i);
if (iv->HasBeenInitialized()) {
iv->ClearModified();
}
iv->ClearModified();
});
}

Expand Down

0 comments on commit 0ff20b1

Please sign in to comment.