parQHV
Compute HyperVolumes using threads
 All Data Structures Files Functions Variables Macros
naiverandom.c
1 /*
2  *
3  * Copyright (c) Year(s), 2013, Luis M. S. Russo and Alexandre
4  * P. Francisco / KDBIO / INESC-ID, <qhv@kdbio.inesc-id.pt>
5  *
6  * Any published media that is related with to use of the distributed
7  * software, or derived software, must contain a reference to "Extending
8  * quick hypervolume. Luís M. S. Russo, Alexandre P. Francisco:
9  * J. Heuristics 22(3): 245-271 (2016)".
10  *
11  * Permission to use, copy, modify, and/or distribute this software for
12  * any purpose with or without fee is hereby granted, provided that the
13  * above copyright notice and this permission notice appear in all
14  * copies.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
17  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
19  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
20  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
21  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23  * PERFORMANCE OF THIS SOFTWARE.
24  *
25  */
26 
27 #include "naiverandom.h"
28 
29 /*** global variables *************************************/
30 
31 /*** file scope macro definitions *************************/
32 
33 /*** file scope type declarations *************************/
34 
35 /*** file scope variables *********************************/
36 
37 /*** file scope functions declarations ********************/
38 
39 /*** public functions declarations ************************/
40 
41 /*** file scope functions *********************************/
42 
43 /* ------------------------------------------------------ */
44 
45 /*** public functions *************************************/
46 
47 double randomVolume(int n, point* PS)
48 {
49  point p;
50  int i, j;
51  int d;
52  unsigned int t;
54  /* i = n; */
55  /* while(i > 0) */
56  /* { */
57  /* i--; */
58  /* t = classify(&PS[i], &cOne); */
59  /* if(t != 0) */
60  /* printf("Not in [0,1]^2\n"); */
61  /* } */
62 
63  i = 1<<20;
64  d = 0;
65  while(i > 0)
66  {
67  randomPoint(&p);
68 
69  t = 1;
70  j = n;
71  while(j > 0 && t != 0)
72  {
73  j--;
74  t = classify(&PS[j], &p);
75  }
76  d += (t == 0);
77 
78  i--;
79  }
80 
81  return (double)d/(double)(1<<20);
82 }
void randomPoint(point *p)
Definition: point.c:74
double randomVolume(int n, point *PS)
Definition: naiverandom.c:47
Point is an array of coordinates, in a struct for simple and fast copy.
Definition: pointStruct.h:47
Header: copy naiverandom.