66 mu_assert(q->
N == 6,
"Incorrect number of queue elements");
69 for (i=0; i<q->
N; i++) {
73 "Incorrect kernel type");
75 "Incorrect train_data");
77 "Incorrect test data")
161 grid->
coefs[0] = 7.0;
162 grid->
coefs[1] = 11.0;
163 grid->
coefs[2] = 13.0;
173 mu_assert(q->
N == 72,
"Incorrect number of queue elements");
176 for (i=0; i<q->
N; i++) {
180 "Incorrect kernel type");
182 "Incorrect train_data");
184 "Incorrect test data");
186 "Incorrect weight idx");
188 "Incorrect epsilon");
267 "Incorrect lambda at task 0");
269 "Incorrect lambda at task 1");
271 "Incorrect lambda at task 2");
273 "Incorrect lambda at task 3");
275 "Incorrect lambda at task 4");
277 "Incorrect lambda at task 5");
279 "Incorrect lambda at task 6");
281 "Incorrect lambda at task 7");
283 "Incorrect lambda at task 8");
285 "Incorrect lambda at task 9");
287 "Incorrect lambda at task 10");
289 "Incorrect lambda at task 11");
291 "Incorrect lambda at task 12");
293 "Incorrect lambda at task 13");
295 "Incorrect lambda at task 14");
297 "Incorrect lambda at task 15");
299 "Incorrect lambda at task 16");
301 "Incorrect lambda at task 17");
303 "Incorrect lambda at task 18");
305 "Incorrect lambda at task 19");
307 "Incorrect lambda at task 20");
309 "Incorrect lambda at task 21");
311 "Incorrect lambda at task 22");
313 "Incorrect lambda at task 23");
315 "Incorrect lambda at task 24");
317 "Incorrect lambda at task 25");
319 "Incorrect lambda at task 26");
321 "Incorrect lambda at task 27");
323 "Incorrect lambda at task 28");
325 "Incorrect lambda at task 29");
327 "Incorrect lambda at task 30");
329 "Incorrect lambda at task 31");
331 "Incorrect lambda at task 32");
333 "Incorrect lambda at task 33");
335 "Incorrect lambda at task 34");
337 "Incorrect lambda at task 35");
339 "Incorrect lambda at task 36");
341 "Incorrect lambda at task 37");
343 "Incorrect lambda at task 38");
345 "Incorrect lambda at task 39");
347 "Incorrect lambda at task 40");
349 "Incorrect lambda at task 41");
351 "Incorrect lambda at task 42");
353 "Incorrect lambda at task 43");
355 "Incorrect lambda at task 44");
357 "Incorrect lambda at task 45");
359 "Incorrect lambda at task 46");
361 "Incorrect lambda at task 47");
363 "Incorrect lambda at task 48");
365 "Incorrect lambda at task 49");
367 "Incorrect lambda at task 50");
369 "Incorrect lambda at task 51");
371 "Incorrect lambda at task 52");
373 "Incorrect lambda at task 53");
375 "Incorrect lambda at task 54");
377 "Incorrect lambda at task 55");
379 "Incorrect lambda at task 56");
381 "Incorrect lambda at task 57");
383 "Incorrect lambda at task 58");
385 "Incorrect lambda at task 59");
387 "Incorrect lambda at task 60");
389 "Incorrect lambda at task 61");
391 "Incorrect lambda at task 62");
393 "Incorrect lambda at task 63");
395 "Incorrect lambda at task 64");
397 "Incorrect lambda at task 65");
399 "Incorrect lambda at task 66");
401 "Incorrect lambda at task 67");
403 "Incorrect lambda at task 68");
405 "Incorrect lambda at task 69");
407 "Incorrect lambda at task 70");
409 "Incorrect lambda at task 71");
412 "Incorrect gamma at task 0");
414 "Incorrect gamma at task 1");
416 "Incorrect gamma at task 2");
418 "Incorrect gamma at task 3");
420 "Incorrect gamma at task 4");
422 "Incorrect gamma at task 5");
424 "Incorrect gamma at task 6");
426 "Incorrect gamma at task 7");
428 "Incorrect gamma at task 8");
430 "Incorrect gamma at task 9");
432 "Incorrect gamma at task 10");
434 "Incorrect gamma at task 11");
436 "Incorrect gamma at task 12");
438 "Incorrect gamma at task 13");
440 "Incorrect gamma at task 14");
442 "Incorrect gamma at task 15");
444 "Incorrect gamma at task 16");
446 "Incorrect gamma at task 17");
448 "Incorrect gamma at task 18");
450 "Incorrect gamma at task 19");
452 "Incorrect gamma at task 20");
454 "Incorrect gamma at task 21");
456 "Incorrect gamma at task 22");
458 "Incorrect gamma at task 23");
460 "Incorrect gamma at task 24");
462 "Incorrect gamma at task 25");
464 "Incorrect gamma at task 26");
466 "Incorrect gamma at task 27");
468 "Incorrect gamma at task 28");
470 "Incorrect gamma at task 29");
472 "Incorrect gamma at task 30");
474 "Incorrect gamma at task 31");
476 "Incorrect gamma at task 32");
478 "Incorrect gamma at task 33");
480 "Incorrect gamma at task 34");
482 "Incorrect gamma at task 35");
484 "Incorrect gamma at task 36");
486 "Incorrect gamma at task 37");
488 "Incorrect gamma at task 38");
490 "Incorrect gamma at task 39");
492 "Incorrect gamma at task 40");
494 "Incorrect gamma at task 41");
496 "Incorrect gamma at task 42");
498 "Incorrect gamma at task 43");
500 "Incorrect gamma at task 44");
502 "Incorrect gamma at task 45");
504 "Incorrect gamma at task 46");
506 "Incorrect gamma at task 47");
508 "Incorrect gamma at task 48");
510 "Incorrect gamma at task 49");
512 "Incorrect gamma at task 50");
514 "Incorrect gamma at task 51");
516 "Incorrect gamma at task 52");
518 "Incorrect gamma at task 53");
520 "Incorrect gamma at task 54");
522 "Incorrect gamma at task 55");
524 "Incorrect gamma at task 56");
526 "Incorrect gamma at task 57");
528 "Incorrect gamma at task 58");
530 "Incorrect gamma at task 59");
532 "Incorrect gamma at task 60");
534 "Incorrect gamma at task 61");
536 "Incorrect gamma at task 62");
538 "Incorrect gamma at task 63");
540 "Incorrect gamma at task 64");
542 "Incorrect gamma at task 65");
544 "Incorrect gamma at task 66");
546 "Incorrect gamma at task 67");
548 "Incorrect gamma at task 68");
550 "Incorrect gamma at task 69");
552 "Incorrect gamma at task 70");
554 "Incorrect gamma at task 71");
557 "Incorrect coef at task 0");
559 "Incorrect coef at task 1");
561 "Incorrect coef at task 2");
563 "Incorrect coef at task 3");
565 "Incorrect coef at task 4");
567 "Incorrect coef at task 5");
569 "Incorrect coef at task 6");
571 "Incorrect coef at task 7");
573 "Incorrect coef at task 8");
575 "Incorrect coef at task 9");
577 "Incorrect coef at task 10");
579 "Incorrect coef at task 11");
581 "Incorrect coef at task 12");
583 "Incorrect coef at task 13");
585 "Incorrect coef at task 14");
587 "Incorrect coef at task 15");
589 "Incorrect coef at task 16");
591 "Incorrect coef at task 17");
593 "Incorrect coef at task 18");
595 "Incorrect coef at task 19");
597 "Incorrect coef at task 20");
599 "Incorrect coef at task 21");
601 "Incorrect coef at task 22");
603 "Incorrect coef at task 23");
605 "Incorrect coef at task 24");
607 "Incorrect coef at task 25");
609 "Incorrect coef at task 26");
611 "Incorrect coef at task 27");
613 "Incorrect coef at task 28");
615 "Incorrect coef at task 29");
617 "Incorrect coef at task 30");
619 "Incorrect coef at task 31");
621 "Incorrect coef at task 32");
623 "Incorrect coef at task 33");
625 "Incorrect coef at task 34");
627 "Incorrect coef at task 35");
629 "Incorrect coef at task 36");
631 "Incorrect coef at task 37");
633 "Incorrect coef at task 38");
635 "Incorrect coef at task 39");
637 "Incorrect coef at task 40");
639 "Incorrect coef at task 41");
641 "Incorrect coef at task 42");
643 "Incorrect coef at task 43");
645 "Incorrect coef at task 44");
647 "Incorrect coef at task 45");
649 "Incorrect coef at task 46");
651 "Incorrect coef at task 47");
653 "Incorrect coef at task 48");
655 "Incorrect coef at task 49");
657 "Incorrect coef at task 50");
659 "Incorrect coef at task 51");
661 "Incorrect coef at task 52");
663 "Incorrect coef at task 53");
665 "Incorrect coef at task 54");
667 "Incorrect coef at task 55");
669 "Incorrect coef at task 56");
671 "Incorrect coef at task 57");
673 "Incorrect coef at task 58");
675 "Incorrect coef at task 59");
677 "Incorrect coef at task 60");
679 "Incorrect coef at task 61");
681 "Incorrect coef at task 62");
683 "Incorrect coef at task 63");
685 "Incorrect coef at task 64");
687 "Incorrect coef at task 65");
689 "Incorrect coef at task 66");
691 "Incorrect coef at task 67");
693 "Incorrect coef at task 68");
695 "Incorrect coef at task 69");
697 "Incorrect coef at task 70");
699 "Incorrect coef at task 71");
702 "Incorrect degree at task 0");
704 "Incorrect degree at task 1");
706 "Incorrect degree at task 2");
708 "Incorrect degree at task 3");
710 "Incorrect degree at task 4");
712 "Incorrect degree at task 5");
714 "Incorrect degree at task 6");
716 "Incorrect degree at task 7");
718 "Incorrect degree at task 8");
720 "Incorrect degree at task 9");
722 "Incorrect degree at task 10");
724 "Incorrect degree at task 11");
726 "Incorrect degree at task 12");
728 "Incorrect degree at task 13");
730 "Incorrect degree at task 14");
732 "Incorrect degree at task 15");
734 "Incorrect degree at task 16");
736 "Incorrect degree at task 17");
738 "Incorrect degree at task 18");
740 "Incorrect degree at task 19");
742 "Incorrect degree at task 20");
744 "Incorrect degree at task 21");
746 "Incorrect degree at task 22");
748 "Incorrect degree at task 23");
750 "Incorrect degree at task 24");
752 "Incorrect degree at task 25");
754 "Incorrect degree at task 26");
756 "Incorrect degree at task 27");
758 "Incorrect degree at task 28");
760 "Incorrect degree at task 29");
762 "Incorrect degree at task 30");
764 "Incorrect degree at task 31");
766 "Incorrect degree at task 32");
768 "Incorrect degree at task 33");
770 "Incorrect degree at task 34");
772 "Incorrect degree at task 35");
774 "Incorrect degree at task 36");
776 "Incorrect degree at task 37");
778 "Incorrect degree at task 38");
780 "Incorrect degree at task 39");
782 "Incorrect degree at task 40");
784 "Incorrect degree at task 41");
786 "Incorrect degree at task 42");
788 "Incorrect degree at task 43");
790 "Incorrect degree at task 44");
792 "Incorrect degree at task 45");
794 "Incorrect degree at task 46");
796 "Incorrect degree at task 47");
798 "Incorrect degree at task 48");
800 "Incorrect degree at task 49");
802 "Incorrect degree at task 50");
804 "Incorrect degree at task 51");
806 "Incorrect degree at task 52");
808 "Incorrect degree at task 53");
810 "Incorrect degree at task 54");
812 "Incorrect degree at task 55");
814 "Incorrect degree at task 56");
816 "Incorrect degree at task 57");
818 "Incorrect degree at task 58");
820 "Incorrect degree at task 59");
822 "Incorrect degree at task 60");
824 "Incorrect degree at task 61");
826 "Incorrect degree at task 62");
828 "Incorrect degree at task 63");
830 "Incorrect degree at task 64");
832 "Incorrect degree at task 65");
834 "Incorrect degree at task 66");
836 "Incorrect degree at task 67");
838 "Incorrect degree at task 68");
840 "Incorrect degree at task 69");
842 "Incorrect degree at task 70");
844 "Incorrect degree at task 71");
863 "Incorrect kernel changed (1)");
866 "Incorrect kernel changed (2)");
868 new->kerneltype =
K_RBF;
870 "Incorrect kernel changed (3)");
877 "Incorrect kernel changed (4)");
880 "Incorrect kernel changed (5)");
893 "Incorrect kernel changed (6)");
896 "Incorrect kernel changed (7)");
907 "Incorrect kernel changed (8)");
910 "Incorrect kernel changed (9)");
936 const char *filename =
"./data/test_progress_string.txt";
947 fid = fopen(filename,
"r");
950 const char *expected = (
"(001/010)\teps = 1e-06\tw = 1\tk = 0.00\t" 951 "l = 1.000000\tp = 1.00\t\t0.500% (0.123s)\t" 952 "(best = 0.700%)\n");
953 mu_assert(strcmp(buffer, expected) == 0,
"Incorrect progress string");
965 const char *filename =
"./data/test_progress_string.txt";
978 fid = fopen(filename,
"r");
981 const char *expected = (
"(001/010)\tg = 3.000\teps = 1e-06\tw = 1\t" 982 "k = 0.00\tl = 1.000000\tp = 1.00\t\t0.500% (0.123s)\t" 983 "(best = 0.700%)\n");
984 mu_assert(strcmp(buffer, expected) == 0,
"Incorrect progress string");
996 const char *filename =
"./data/test_progress_string.txt";
1011 fid = fopen(filename,
"r");
1014 const char *expected = (
"(001/010)\t" 1015 "d = 2.00\tc = 1.00\tg = 3.000\t" 1016 "eps = 1e-06\tw = 1\tk = 0.00\t" 1017 "l = 1.000000\tp = 1.00\t\t0.500% (0.123s)\t" 1018 "(best = 0.700%)\n");
1019 mu_assert(strcmp(buffer, expected) == 0,
"Incorrect progress string");
1031 const char *filename =
"./data/test_progress_string.txt";
1045 fid = fopen(filename,
"r");
1048 const char *expected = (
"(001/010)\t" 1049 "c = 1.00\tg = 3.000\t" 1050 "eps = 1e-06\tw = 1\tk = 0.00\t" 1051 "l = 1.000000\tp = 1.00\t\t0.500% (0.123s)\t" 1052 "(best = 0.700%)\n");
1053 mu_assert(strcmp(buffer, expected) == 0,
"Incorrect progress string");
Minimal unit testing framework for C.
#define Calloc(type, size)
long folds
number of folds in cross validation
Structure for describing the entire grid search.
double * epsilons
array of epsilon values
struct GenQueue * gensvm_init_queue(void)
Initialize a GenQueue structure.
double coef
coef parameter for the GenModel
char * test_fill_queue_nokernel()
long ID
numeric id of the task in the queue
void gensvm_gridsearch_progress(struct GenTask *task, long N, double perf, double duration, double current_max)
Print the description of the current task on screen.
char * test_kernel_folds()
#define mu_assert(test, message)
#define GENSVM_MAX_LINE_LENGTH
long Np
size of the array of p values
long Ne
size of the array of epsilon values
long Nc
size of the array of coef values
double * degrees
array of degree values
long Nk
size of the array of kappa values
long Nw
size of the array of weight_idx values
KernelType kerneltype
type of kernel to use throughout training
struct GenTask * gensvm_init_task(void)
Initialize a GenTask structure.
long i
index used for keeping track of the queue
char * test_gridsearch_progress_rbf()
void gensvm_fill_queue(struct GenGrid *grid, struct GenQueue *queue, struct GenData *train_data, struct GenData *test_data)
Initialize a GenQueue from a Training instance.
#define mu_run_test(test)
char * test_gridsearch_progress_poly()
double gamma
gamma parameter for the GenModel
double * lambdas
array of lambda values
KernelType kerneltype
kerneltype parameter for the GenModel
A structure to represent the data.
struct GenData * test_data
pointer to the test data (if any)
char * test_gridsearch_progress_sigmoid()
#define mu_test_missing()
Header file for gensvm_gridsearch.c.
double degree
degree parameter for the GenModel
char * test_train_queue()
char * test_kernel_changed()
long Nl
size of the array of lambda values
double * kappas
array of kappa values
long Ng
size of the array of gamma values
double lambda
lambda parameter for the GenModel
void gensvm_free_data(struct GenData *data)
Free allocated GenData struct.
void gensvm_free_queue(struct GenQueue *q)
Free the GenQueue struct.
A structure for a single task in the queue.
bool gensvm_kernel_changed(struct GenTask *newtask, struct GenTask *oldtask)
Check if the kernel parameters change between tasks.
void gensvm_free_task(struct GenTask *t)
Free the GenTask struct.
struct GenTask ** tasks
array of pointers to Task structs
int * weight_idxs
array of weight_idxs
double kappa
kappa parameter for the GenModel
double * gammas
array of gamma values
FILE * GENSVM_OUTPUT_FILE
double * coefs
array of coef values
char * test_fill_queue_kernel()
long Nd
size of the array of degree values
char * test_gridsearch_progress_linear()
struct GenData * gensvm_init_data(void)
Initialize a GenData structure.
double epsilon
epsilon parameter for the GenModel
double * ps
array of p values
double p
p parameter for the GenModel
void gensvm_free_grid(struct GenGrid *grid)
Free a GenGrid structure.
struct GenData * train_data
pointer to the training data
int weight_idx
weight_idx parameter for the GenModel
struct GenGrid * gensvm_init_grid(void)
Initialize a GenGrid structure.