Closed daneelsan closed 3 years ago
@maxitg Right now I covert "TimeConstraint" -> Infinity
to maxdouble
before passing in to cpp$setReplace
.
Inside replace
I'm doing this:
time_t startTime = time(0);
while (true) {
if (replaceOnce(shouldAbort)) {
++count;
} else {
return count;
}
// Custom TimeConstraint function
double secondsElapsed = difftime(time(0), startTime);
if (secondsElapsed > timeConstraint) {
terminationReason_ = TerminationReason::TimeConstrained;
return count;
}
}
So even if I pass Infinity
, it still computes time(0)
and difftime
. Do you think it would be better to do something like:
time_t startTime = time(0);
auto timeConstrainted = []() { return false; };
if (timeConstraint > 0) {
timeConstrained = []() { return difftime(time(0), startTime) > timeConstraint; }
}
...
if (timeConstrained()) {
terminationReason_ = TerminationReason::TimeConstrained;
return count;
}
(don't know how lambdas work but that's the idea)
Changes
TimeConstrained[...]
fromsetSubstitutionSystem$cpp[...]
to insideHypergraphSubstitutionSystem.cpp
inlibSetReplace
.TerminationReasonCode
:8 -> "TimeConstrained"
.Comments
AbsoluteTiming
doesn't really match the time constraint:Examples
This change is