I have written a piece of code, everything is fine until i run it, i get
"Exception in thread "main" java.lang.NullPointerException
at useCADSL.main(useCADSL.java:5)"
i know what it means, i just cant see where to modify [probably the whole you read what you think you've wrote thing]
my first class is
import jp.ac.kobe_u.cs.cream.*;
public class IntFutoSol {
public IntFutoSol with = this;
Network net = new Network();
int n = 4;
IntVariable[][] v = new IntVariable[n][n];
IntVariable[] vs = new IntVariable[n];
String a,b,c,d,e,f,g,h,i,j,k,l,m,nn,o,p = null;
public IntFutoSol() {
net = new Network();
}
public static IntFutoSol CryptArith() {
return null;
}
public IntFutoSol a(String a1) {
a = a1;
return this;
}
public IntFutoSol b(String b1) {
b = b1;
return this;
}
public IntFutoSol c(String c1) {
c = c1;
return this;
}
public IntFutoSol d(String d1) {
d = d1;
return this;
}
public IntFutoSol e(String e1) {
e = e1;
return this;
}
public IntFutoSol f(String f1) {
f = f1;
return this;
}
public IntFutoSol g(String g1) {
g = g1;
return this;
}
public IntFutoSol h(String h1) {
h = h1;
return this;
}
public IntFutoSol i(String i1) {
i = i1;
return this;
}
public IntFutoSol j(String j1) {
j = j1;
return this;
}
public IntFutoSol k(String k1) {
k = k1;
return this;
}
public IntFutoSol l(String l1) {
l = l1;
return this;
}
public IntFutoSol m(String m1) {
m = m1;
return this;
}
public IntFutoSol nn(String nn1) {
nn = nn1;
return this;
}
public IntFutoSol o(String o1) {
o = o1;
return this;
}
public IntFutoSol p(String p1) {
p = p1;
return this;
}
int z = Integer.parseInt(a);
int y = Integer.parseInt(b);
int x = Integer.parseInt(c);
int w = Integer.parseInt(d);
int vv = Integer.parseInt(e);
int u = Integer.parseInt(f);
int t = Integer.parseInt(g);
int s = Integer.parseInt(h);
int r = Integer.parseInt(i);
int q = Integer.parseInt(j);
int aa = Integer.parseInt(k);
int bb = Integer.parseInt(l);
int cc = Integer.parseInt(m);
int dd = Integer.parseInt(nn);
int ee = Integer.parseInt(o);
int ff = Integer.parseInt(p);
int[][] puzzle =
{{z,y,x,w},
{vv,u,t,s},
{r,q,aa,bb},
{cc,dd,ee,ff}};{
// Create constraint-variables
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (puzzle[i][j] == 0){
// A zero in the matrix represents and empty cell
v[i][j] = new IntVariable(net, 1, n);
}else
v[i][j] = new IntVariable(net, puzzle[i][j]);
}
}
//Fixed-value constraints
/*v[0][0].equals(z);
v[0][1].equals(y);
v[0][2].equals(x);
v[0][3].equals(w);
//System.out.printf("\n\n %s %s %s %s\n", z, y, x, w);
v[1][0].equals(vv);
v[1][1].equals(u);
v[1][2].equals(t);
v[1][3].equals(s);
//System.out.printf("%s %s %s %s\n", vv, u, t, s);
v[2][0].equals(r);
v[2][1].equals(q);
v[2][2].equals(aa);
v[2][3].equals(bb);
//System.out.printf("%s %s %s %s\n", r, q, aa, bb);
v[3][0].equals(cc);
v[3][1].equals(dd);
v[3][2].equals(ee);
v[3][3].equals(ff);
//System.out.printf("%s %s %s %s\n", cc, dd, ee, ff);
v[0][1].equals(2);
v[0][3].equals(4);
v[1][2].equals(3);
v[2][1].equals(3);
v[3][0].equals(4);
v[3][3].ge(v[2][3]);
// Equation
//v[1][1].ge(v[0][1]);
//v[3][3].ge(v[3][2]);
//v[2][3].ge(v[2][2]);
//v[0][3].ge(v[0][2]);
//v[0][1].ge(v[1][3]);
//v[3][2].ge(v[3][1]);*/
// Each row must contain distinct values
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
vs[j] = v[i][j];
}
new NotEquals(net, vs);
}
//Each column must contain distinct values
for (int j = 0; j < n; j++) {
for (int i = 0; i < n; i++) {
vs[i] = v[i][j];
}
new NotEquals(net, vs);
}
//Each box must contain distinct values
for (int i0 = 0; i0 < n; i0 += 2) {
for (int j0 = 0; j0 < n; j0 += 2) {
int k = 0;
for (int i = i0; i < i0+2; i++) {
for (int j = j0; j < j0+2; j++) {
vs[k++] = v[i][j];
}
}
new NotEquals(net, vs);
}
}
Solver solver = new DefaultSolver(net);
for (solver.start(); solver.waitNext(); solver.resume()) {
Solution solution = solver.getSolution();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
System.out.print(solution.getIntValue(v[i][j]) + " ");
System.out.println();
}
System.out.println();
}
solver.stop();
}
}
and the second
public class useCADSL {
public static void main(String[] args) {
IntFutoSol.CryptArith()
.a("0")
.b("0")
.c("0")
.d("0")
.e("0")
.f("0")
.g("0")
.h("0")
.i("0")
.j("0")
.k("0")
.l("0")
.m("0")
.nn("0")
.o("0")
.p("0");
}
}