int main() { /* Important! initialise rng */ ghmm_rng_init(); return my_model(); }
int main(){ ghmm_rng_init(); testBaumwelch(); return 0; }
/*============================================================================*/ int main(int argc, char* argv[]) { #define CUR_PROC "smix_hmm_main" #ifdef GHMM_OBSOLETE int exitcode = -1; if (argc != 4 && argc != 5) { printf("Insufficient arguments. Usage: \n"); printf("mix_hmm [Seq.File] [InitModel File] [Out File] <seed>\n"); goto STOP; } ghmm_rng_init(); if (argc == 5) GHMM_RNG_SET(RNG,atoi(argv[4])); else { ghmm_rng_timeseed(RNG); } exitcode = smix_hmm_run(argc, argv); /*------------------------------------------------------------------------*/ STOP: ighmm_mes(MES_WIN, "\n(%2.2T): Program finished with exitcode %d.\n", exitcode ); ighmm_mes_exit(); return(exitcode); #else /* GHMM_OBSOLETE */ fprintf (stderr, "cluster is obsolete. If you need it rebuild the GHMM with \"GHMM_OBSOLETE\"\n"); return 0; #endif /* GHMM_OBSOLETE */ # undef CUR_PROC } /* main */
int main(void) { int nf; //Suite *s = smodel_suite(); Suite *s = pmodel_suite(); SRunner *sr = srunner_create(s); ghmm_rng_init(); /* Important! initialise rng XXX UNTESTED*/ srunner_run_all(sr, CK_NORMAL); nf = srunner_ntests_failed(sr); srunner_free(sr); return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
int main() { int result; /* Important! initialise rng */ ghmm_rng_init(); if (single_state_coin_toss() || two_states_coin_toss()) result = 1; else result = 0; #ifdef WIN32 printf("\nPress ENTER\n"); fgetc(stdin); #endif return result; }
ghmm_cseq *ghmm_sgenerate_extensions (ghmm_cmodel * smo, ghmm_cseq * sqd_short, int seed, int global_len, sgeneration_mode_t mode) { #define CUR_PROC "ghmm_sgenerate_extensions" ghmm_cseq *sq = NULL; int i, j, t, n, m, len = global_len, short_len, max_short_len = 0, up = 0; #ifdef bausparkasse int tilgphase = 0; #endif /* int *v_path = NULL; */ double log_p, *initial_distribution, **alpha, *scale, p, sum; /* aicj */ int class = -1; int pos; /* TEMP */ if (mode == all_viterbi || mode == viterbi_viterbi || mode == viterbi_all) { GHMM_LOG(LCONVERTED, "Error: mode not implemented yet\n"); goto STOP; } if (len <= 0) /* no global length; model should have a final state */ len = (int) GHMM_MAX_SEQ_LEN; max_short_len = ghmm_cseq_max_len (sqd_short); /*---------------alloc-------------------------------------------------*/ sq = ghmm_cseq_calloc (sqd_short->seq_number); if (!sq) { GHMM_LOG_QUEUED(LCONVERTED); goto STOP; } ARRAY_CALLOC (initial_distribution, smo->N); /* is needed in cfoba_forward() */ alpha = ighmm_cmatrix_alloc (max_short_len, smo->N); if (!alpha) { GHMM_LOG_QUEUED(LCONVERTED); goto STOP; } ARRAY_CALLOC (scale, max_short_len); ghmm_rng_init (); GHMM_RNG_SET (RNG, seed); /*---------------main loop over all seqs-------------------------------*/ for (n = 0; n < sqd_short->seq_number; n++) { ARRAY_CALLOC (sq->seq[n], len*(smo->dim)); short_len = sqd_short->seq_len[n]; if (len < short_len) { GHMM_LOG(LCONVERTED, "Error: given sequence is too long\n"); goto STOP; } ghmm_cseq_copy (sq->seq[n], sqd_short->seq[n], short_len); #ifdef GHMM_OBSOLETE sq->seq_label[n] = sqd_short->seq_label[n]; #endif /* GHMM_OBSOLETE */ /* Initial distribution */ /* 1. Viterbi-state */ #if 0 /* wieder aktivieren, wenn ghmm_cmodel_viterbi realisiert */ if (mode == viterbi_all || mode == viterbi_viterbi) { v_path = cviterbi (smo, sqd_short->seq[n], short_len, &log_p); if (v_path[short_len - 1] < 0 || v_path[short_len - 1] >= smo->N) { GHMM_LOG(LCONVERTED, "Warning:Error: from viterbi()\n"); sq->seq_len[n] = short_len; m_realloc (sq->seq[n], short_len); continue; } m_memset (initial_distribution, 0, smo->N); initial_distribution[v_path[short_len - 1]] = 1.0; /* all other 0 */ m_free (v_path); } #endif /* 2. Initial Distribution ??? Pi(i) = alpha_t(i)/P(O|lambda) */ if (mode == all_all || mode == all_viterbi) { if (short_len > 0) { if (ghmm_cmodel_forward (smo, sqd_short->seq[n], short_len, NULL /* ?? */ , alpha, scale, &log_p)) { GHMM_LOG_QUEUED(LCONVERTED); goto STOP; } sum = 0.0; for (i = 0; i < smo->N; i++) { /* alpha ist skaliert! */ initial_distribution[i] = alpha[short_len - 1][i]; sum += initial_distribution[i]; } /* nicht ok.? auf eins skalieren? */ for (i = 0; i < smo->N; i++) initial_distribution[i] /= sum; } else { for (i = 0; i < smo->N; i++) initial_distribution[i] = smo->s[i].pi; } } /* if short_len > 0: Initial state == final state from sqd_short; no output here else choose inittial state according to pi and do output */ p = GHMM_RNG_UNIFORM (RNG); sum = 0.0; for (i = 0; i < smo->N; i++) { sum += initial_distribution[i]; if (sum >= p) break; } /* error due to incorrect normalization ?? */ if (i == smo->N) { i--; while (i > 0 && initial_distribution[i] == 0.0) i--; } t = 0; pos = t * smo->dim; if (short_len == 0) { /* Output in state i */ p = GHMM_RNG_UNIFORM (RNG); sum = 0.0; for (m = 0; m < smo->M; m++) { sum += smo->s[i].c[m]; if (sum >= p) break; } /* error due to incorrect normalization ?? */ if (m == smo->M) { m--; while (m > 0 && smo->s[i].c[m] == 0.0) m--; } ghmm_cmodel_get_random_var(smo, i, m, sq->seq[n]+pos); if (smo->cos == 1) { class = 0; } else { if (!smo->class_change->get_class) { printf ("ERROR: get_class not initialized\n"); goto STOP; } /*printf("1: cos = %d, k = %d, t = %d\n",smo->cos,smo->class_change->k,t);*/ class = smo->class_change->get_class (smo, sq->seq[n], n, t); } t++; pos += smo->dim; }
int main(int argc, char* argv[]) { # define CUR_PROC "main" #ifdef GHMM_OBSOLETE int mo_number, smo_number; #ifdef CMODEL_INCLUDED int cmo_number; #endif int discrete = 0, smodelflag = 0; int T, i, j; ghmm_dmodel **mo = NULL; #ifdef CMODEL_INCLUDED cmodel **cmo = NULL; #endif ghmm_cmodel **smo = NULL; double d; /* double dangle, ddiff, s1, s2; */ if (argc != 5) { printf("Usage: main <Model File> <discrete-flag> <T> <smodel flag>\n"); exit(1); } discrete = atoi(argv[2]); T = atoi(argv[3]); smodelflag = atoi(argv[4]); ghmm_rng_init(); if (smodelflag) { smo = ghmm_cmodel_read(argv[1], &smo_number); if (!smo) {GHMM_LOG_QUEUED(LCONVERTED); return -1;} if (smo_number < 2) { printf("Need at least two HMMs to compare (read %d)\n", smo_number); return -1; } for (i = 0; i < smo_number - 1; i++) for (j = i + 1; j < smo_number; j++) { printf("#----- mo[%d], mo[%d] \n", i , j); /* syntax prob_dist: (smo1, smo2, total seqlen., symmetric, verbose) */ d = ghmm_cmodel_prob_distance(smo[i], smo[j], T, 1, 0); printf("probdist = %f\n",d); } } else if (discrete) { mo = ghmm_dmodel_read(argv[1], &mo_number); if (!mo) {GHMM_LOG_QUEUED(LCONVERTED); return -1;} if (mo_number < 2) { printf("Need at least two HMMs to compare\n"); return -1; } printf("#----- mo[0], mo[1] \n"); d = ghmm_dmodel_prob_distance(mo[0],mo[1], T, 0, 1); printf("d=%f\n",d); printf("#----- mo[1], mo[0] \n"); d = ghmm_dmodel_prob_distance(mo[1],mo[0], T, 0, 1); printf("d=%f\n",d); printf("#----- mo[0], mo[1] \n"); d = ghmm_dmodel_prob_distance(mo[0],mo[1], T, 0, 0); printf("d=%f\n",d); printf("#----- mo[1], mo[0] \n"); d = ghmm_dmodel_prob_distance(mo[1],mo[0], T, 0, 0); printf("d=%f\n",d); printf("#----- mo[0], mo[1] \n"); d = ghmm_dmodel_prob_distance(mo[0],mo[1], T, 1, 1); printf("d=%f\n",d); printf("#----- mo[0], mo[1] \n"); d = ghmm_dmodel_prob_distance(mo[0],mo[1], T, 1, 0); printf("d=%f\n",d); } #ifdef CMODEL_INCLUDED else { cmo = cmodel_read(argv[1], &cmo_number); if (!cmo) {GHMM_LOG_QUEUED(LCONVERTED); return -1;} if (cmo_number < 2) { printf("Need at least two CHMMs to compare\n"); return -1; } printf("#----- cmo[0], cmo[1] \n"); d = cmodel_prob_distance(cmo[0], cmo[1], T, 0, 1); printf("d=%f\n",d); printf("#----- cmo[1], cmo[0] \n"); d = cmodel_prob_distance(cmo[1], cmo[0], T, 0, 1); printf("d=%f\n",d); printf("#----- cmo[0], cmo[1] \n"); d = cmodel_prob_distance(cmo[0], cmo[1], T, 0, 0); printf("d=%f\n",d); printf("#----- cmo[1], cmo[0] \n"); d = cmodel_prob_distance(cmo[1], cmo[0], T, 0, 0); printf("d=%f\n",d); printf("#----- cmo[0], cmo[1] \n"); d = cmodel_prob_distance(cmo[0], cmo[1], T, 1, 1); printf("d=%f\n",d); printf("#----- cmo[0], cmo[1] \n"); d = cmodel_prob_distance(cmo[0], cmo[1], T, 1, 0); printf("d=%f\n",d); /* coemission likelihood */ printf("#----- cmo[0]/cmo[1] \n"); if (cmodel_coemission_likelihood(cmo[0], cmo[1], &d) == -1) d = -1; printf("Coemission Likelihood = %e\n",d); printf("#----- cmo[0]/cmo[0] \n"); if (cmodel_coemission_likelihood(cmo[0], cmo[0], &d) == -1) d = -1; printf("Coemission Likelihood = %e\n",d); printf("#----- cmo[1]/cmo[1] \n"); if (cmodel_coemission_likelihood(cmo[1], cmo[1], &d) == -1) d = -1; printf("Coemission Likelihood = %e\n",d); printf("#----- D_angle, D_diff, S1, S2\n"); cmodel_measures(cmo[0], cmo[1], &dangle, &ddiff, &s1, &s2); printf("D_angle = %e\n", dangle); printf("D_diff = %e\n", ddiff); printf("S1 = %e\n", s1); printf("S2 = %e\n", s2); } #endif /* CMODEL_INCLUDED*/ #else /* GHMM_OBSOLETE */ fprintf (stderr, "probdist is obsolete. If you need it rebuild the GHMM with \"GHMM_OBSOLETE\".\n"); #endif /* GHMM_OBSOLETE */ return 0; }