Skip to content

Commit

Permalink
this and that
Browse files Browse the repository at this point in the history
  • Loading branch information
spond committed Mar 4, 2024
1 parent dae1c96 commit 55e743a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/core/include/global_things.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ namespace hy_global {
Global variables (grouped by type, then alphabetically)
*/

_String* ConstructAnErrorMessage (_String const&);

extern _AVLList _hy_application_globals;

extern _List _hy_standard_library_extensions,
Expand Down
18 changes: 18 additions & 0 deletions src/core/include/likefunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,18 @@ class _LikelihoodFunction: public BaseObj {

#endif
#endif

void ComputeDependencyLists (_List& receptacle, long max_dep = 0x7fffffff) const;
/**
This function computes a mapping from the index of each independent variable to the list of all dependent variables that it affects.
index => {n1,n2,...n3}
special cases:
index => null (no dependencies)
index => {} (all variables, or >max_dep)
@param max_dep the maximum number of dependent variables affected by a paritcular independent to generate an explicit list
*/


bool ProcessPartitionList (_SimpleList&, _Matrix*) const;
// given a matrix argument (argument 2; can be nil to include all)
Expand Down Expand Up @@ -536,6 +548,12 @@ class _LikelihoodFunction: public BaseObj {
void SetupParameterMapping (void);
void CleanupParameterMapping (void);

void ConvertDependenciesToSimpleFormulas ();
/**
Traverse the list of dependent variables and generate simple formulas if they can be created.
*/


_SimpleList theTrees,
theDataFilters,
theProbabilities,
Expand Down
10 changes: 4 additions & 6 deletions src/core/likefunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1932,18 +1932,15 @@ bool _LikelihoodFunction::SendOffToMPI (long index) {

//_______________________________________________________________________________________

bool _LikelihoodFunction::PreCompute (void)
{
bool _LikelihoodFunction::PreCompute (void) {

useGlobalUpdateFlag = true;
// mod 20060125 to only update large globals once
unsigned long i = 0UL;
unsigned long i;

_SimpleList * arrayToCheck = nonConstantDep?nonConstantDep:&indexDep;



for (; i < arrayToCheck->lLength; i++) {
for (i = 0UL; i < arrayToCheck->lLength; i++) {
_Variable* cornholio = LocateVar(arrayToCheck->list_data[i]);
hyFloat tp = cornholio->Compute()->Value();
if (!cornholio->IsValueInBounds(tp)){
Expand Down Expand Up @@ -4252,6 +4249,7 @@ _Matrix* _LikelihoodFunction::Optimize (_AssociativeList const * options)

CheckDependentBounds();


currentPrecision = get_optimization_setting (kStartingPrecision, 0.1);
precision = get_optimization_setting (kOptimizationPrecision, 0.001);
maxItersPerVar = get_optimization_setting (kMaximumIterationsPerVariable, 5000.);
Expand Down
25 changes: 23 additions & 2 deletions src/mains/unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ void mpiOptimizerLoop (int, int);

#ifdef __HYPHY_HANDLE_TERM_SIGNAL__
volatile sig_atomic_t hyphy_sigterm_in_progress = 0;

volatile sig_atomic_t hyphy_sigstop_in_process = 0;

void hyphy_sigterm_handler (int sig) {
if (hyphy_sigterm_in_progress)
raise (sig);
Expand All @@ -202,6 +203,17 @@ void mpiOptimizerLoop (int, int);
signal (sig, SIG_DFL);
raise (sig);
}

void hyphy_sigstop_handler (int sig) {
if (hyphy_sigstop_in_process)
raise (sig);

hyphy_sigstop_in_process = 1;
StringToConsole (new _String (ConstructAnErrorMessage ("HyPhy suspended.")));

signal (sig, SIG_DFL);
raise (sig);
}

#endif

Expand Down Expand Up @@ -660,8 +672,17 @@ int main (int argc, char* argv[]) {
#ifdef __HYPHY_HANDLE_TERM_SIGNAL__
if (signal (SIGTERM, hyphy_sigterm_handler) == SIG_IGN)
signal (SIGTERM, SIG_IGN);
if (signal (SIGINT, hyphy_sigterm_handler) == SIG_IGN)

if (signal (SIGINT, hyphy_sigterm_handler) == SIG_IGN)
signal (SIGINT, SIG_IGN);

if (signal (SIGTSTP, hyphy_sigstop_handler) == SIG_IGN)
signal (SIGTSTP, SIG_IGN);

//if (signal (SIGCONT, hyphy_sigresume_handler) == SIG_IGN)
// signal (SIGCONT, SIG_IGN);


#endif
//printf ("%e\n", mapParameterToInverval (1.322753E-23, 0x2, false));
//exit (0);
Expand Down

0 comments on commit 55e743a

Please sign in to comment.