This repository was archived by the owner on Jun 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpot_func.java
More file actions
71 lines (63 loc) · 1.51 KB
/
Copy pathpot_func.java
File metadata and controls
71 lines (63 loc) · 1.51 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
public class pot_func {
//===== GENERAL POTENTIAL FUNCTIONS =====
//----- general potential function (this is for cliques)
public static abstract class abstract_pot{
//tunable parameter for this potential function
public double THETA[];
public abstract_pot(double theta[]){
THETA = (double[])theta.clone();
}
public abstract_pot(){
THETA = new double[1];
}
//potential function
abstract public double U(int[] node_values);
abstract public double alpha(int[] node_values);
}
//===== POTENTIAL FUNCTION CLASS DEFINITIONS =====
//----- n_ising
public static class node_ising_pot extends abstract_pot{
public node_ising_pot(double theta){
THETA[0] = theta;
}
public double U(int[] v){
if(v[0]==0)
v[0]=-1;
return Math.exp(THETA[0]*v[0]);
}
public double alpha(int[] v){
if(v[0]==0)
v[0]=-1;
return v[0];
}
}
//----- e_ising
public static class edge_ising_pot extends abstract_pot{
public edge_ising_pot(double theta){
THETA[0] = theta;
}
public double U(int[] v){
for(int i=0; i<v.length; i++)
if(v[i]==0)
v[i]=-1;
return Math.exp(THETA[0]*((double)v[0])*((double)v[1]));
}
public double alpha(int[] v){
for(int i=0; i<v.length; i++)
if(v[i]==0)
v[i]=-1;
return ((double)v[0])*((double)v[1]);
}
}
//----- square potential
public static class square_pot extends abstract_pot{
public square_pot(double theta){
}
public double U(int[] v){
return 0.0;
}
public double alpha(int[] v){
return 0.0;
}
}
}