Skip to content

Commit

Permalink
preparing 0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rcabanasdepaz committed Jul 20, 2020
1 parent 42afdff commit d932805
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 29 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.1.4
===========

- Common interface for inference algorithms.
- Solved bugs at renaming and sort parents.
- Bug at LP #23.
- Documentation available.



0.1.3
===========

Expand Down
62 changes: 35 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,49 @@ learning and inference algorithms for credal models.

An example of exact inference in a credal network is given below.

```
```java
import ch.idsia.crema.factor.credal.vertex.VertexFactor;
import ch.idsia.crema.inference.ve.CredalVariableElimination;
import ch.idsia.crema.model.ObservationBuilder;
import ch.idsia.crema.model.Strides;
import ch.idsia.crema.model.graphical.SparseModel;

double p = 0.2;
double eps = 0.0001;
public class Starting {
public static void main(String[] args) {
double p = 0.2;
double eps = 0.0001;

/* CN defined with vertex Factor */
/* CN defined with vertex Factor */

// Define the model (with vertex factors)
SparseModel model = new SparseModel();
int u = model.addVariable(3);
int x = model.addVariable(2);
model.addParent(x,u);
// Define the model (with vertex factors)
SparseModel model = new SparseModel();
int A = model.addVariable(3);
int B = model.addVariable(2);
model.addParent(B,A);

// Define a credal set of the partent node
VertexFactor fu = new VertexFactor(model.getDomain(u), Strides.empty());
fu.addVertex(new double[]{0., 1-p, p});
fu.addVertex(new double[]{1-p, 0., p});
model.setFactor(u,fu);
// Define a credal set of the partent node
VertexFactor fu = new VertexFactor(model.getDomain(A), Strides.empty());
fu.addVertex(new double[]{0., 1-p, p});
fu.addVertex(new double[]{1-p, 0., p});
model.setFactor(A,fu);


System.out.println(p+" "+(1-p));
// Define the credal set of the child
VertexFactor fx = new VertexFactor(model.getDomain(B), model.getDomain(A));

// Define the credal set of the child
VertexFactor fx = new VertexFactor(model.getDomain(x), model.getDomain(u));
fx.addVertex(new double[]{1., 0.,}, 0);
fx.addVertex(new double[]{1., 0.,}, 1);
fx.addVertex(new double[]{0., 1.,}, 2);

fx.addVertex(new double[]{1., 0.,}, 0);
fx.addVertex(new double[]{1., 0.,}, 1);
fx.addVertex(new double[]{0., 1.,}, 2);
model.setFactor(B,fx);

model.setFactor(x,fx);
// Run exact inference
CredalVariableElimination inf = new CredalVariableElimination(model);
inf.query(A, ObservationBuilder.observe(B,0));

}
}

// Run exact inference inference
VariableElimination ve = new FactorVariableElimination(model.getVariables());
ve.setFactors(model.getFactors());
System.out.println(ve.run(x));


```
Expand All @@ -52,7 +60,7 @@ System.out.println(ve.run(x));

Add the following code in the pom.xml of your project:

```
```xml
<repositories>
<repository>
<id>cremaRepo</id>
Expand All @@ -64,7 +72,7 @@ Add the following code in the pom.xml of your project:
<dependency>
<groupId>ch.idsia</groupId>
<artifactId>crema</artifactId>
<version>0.1.3</version>
<version>0.1.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion docs/notes/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Crema can be easily included at any maven project. For this, add the following c
<dependency>
<groupId>ch.idsia</groupId>
<artifactId>Crema</artifactId>
<version>0.1.3</version>
<version>0.1.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.idsia</groupId>
<artifactId>crema</artifactId>
<version>0.1.4-SNAPSHOT</version>
<version>0.1.4</version>

<name>Credal Model Algorithms</name>

Expand Down

0 comments on commit d932805

Please sign in to comment.