File: from_formula_threshold_profile.cpp

package info (click to toggle)
isospec 2.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,472 kB
  • sloc: cpp: 9,530; python: 2,095; makefile: 180; ansic: 100; sh: 88
file content (42 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include "isoSpec++.h"
#include <cassert>

using namespace IsoSpec;

#ifndef ISOSPEC_TESTS_SKIP_MAIN

size_t test_threshold_simple(const char* formula, double threshold);

int main(int argc, char** argv)
{
	if(argc < 3)
	{
		std::cout << "Proper usage (for example): ./from_formula_threshold C10000H1000O1000N1000 0.01" << std::endl;
		std::cout << "...will the configurations with probability above 0.01 for the above molecule" << std::endl;
		return -1;
	}
        size_t v = 0;
        for (int ii=0; ii<10000; ii++)
	    v += test_threshold_simple(argv[1], atof(argv[2]));

	std::cout << "The number of visited configurations is:" << v << std::endl;

}
#endif /* ISOSPEC_TESTS_SKIP_MAIN */


size_t test_threshold_simple(const char* formula, double threshold)
{

	IsoThresholdGenerator i(formula, threshold, true, 100, 100, true);
    int no_visited = 0;
    [[maybe_unused]] double total_prob = 0.0;
	while(i.advanceToNextConfiguration())
	{
		no_visited += 1;
                total_prob += i.prob();
	}
	return no_visited;

}