QHV
Compute HyperVolumes sequentially
 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 "Quick
8  * HyperVolume, Luís M. S. Russo, Alexandre P. Francisco IEEE Trans.
9  * Evolutionary Computation 18(4): 481-502(2014)".
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 
28 #include "naiverandom.h"
29 
30 /*** global variables *************************************/
31 
32 /*** file scope macro definitions *************************/
33 
34 /*** file scope type declarations *************************/
35 
36 /*** file scope variables *********************************/
37 
38 /*** file scope functions declarations ********************/
39 
40 /*** public functions declarations ************************/
41 
42 /*** file scope functions *********************************/
43 
44 /* ------------------------------------------------------ */
45 
46 /*** public functions *************************************/
47 
48 double randomVolume(int n, point* PS)
49 {
50  point p;
51  int i, j;
52  int d;
53  unsigned int t;
55  /* i = n; */
56  /* while(i > 0) */
57  /* { */
58  /* i--; */
59  /* t = classify(&PS[i], &cOne); */
60  /* if(t != 0) */
61  /* printf("Not in [0,1]^2\n"); */
62  /* } */
63 
64  i = 1<<20;
65  d = 0;
66  while(i > 0)
67  {
68  randomPoint(&p);
69 
70  t = 1;
71  j = n;
72  while(j > 0 && t != 0)
73  {
74  j--;
75  t = classify(&PS[j], &p);
76  }
77  d += (t == 0);
78 
79  i--;
80  }
81 
82  return (double)d/(double)(1<<20);
83 }
void randomPoint(point *p)
Definition: point.c:75
double randomVolume(int n, point *PS)
Definition: naiverandom.c:48
Point is an array of coordinates, in a struct for simple and fast copy.
Definition: pointStruct.h:47
Header: copy naiverandom.