A Simple Example

mangosteen.cs.ttu.edu$ csp.out -f 3 3 3 3 1 3 1
The parameters of the random instances
  (n=3, d=3, e=3 , f=3 , t=1, # of instances=1, seed=3)
 
Instance 0:
The cn address is 0x960f0c8
nt=9  ft=3
——-all possible constraints——–
0 1
0 2
1 2
——–C/e constraints————–
1 2
0 1
0 2
——–2*C constraints———–
1 2
2 1
0 1
1 0
0 2
2 0
———F constraints————–
0 1
2 1
1 0
functional: 2 1
 
0 : 2
1 : 0
2 : 0
 
 
 Transpose:1 2:
before cn
I am after cn
0 : 2 1
1 :
2 : 0
 
 
 
 
Bijection: 0 1
 
0 1:
<0,1>   <2,0>   <1,2>   
Bijection Transpose:1 0:
<1,0>   <0,2>   <2,1>   
 
nonfunctional: 0 2
 
before cn
I am after cn
0 : 1 0 2
1 : 1 0 2
2 : 1 0 2
 
before cn
I am after cn
 
nonfuntional Traspose:2 0
0 : 2 0 1
1 : 0 2 1
2 : 2 0 1
 
 
 
 
adjGF:
0 : 1
1 : 0
2 : 1
 
 
funcross_link_list:
0 : 1 2
1 : 0 2
2 : 0 1
 
 
————CSP:cn———
 
0,2:
(0,0)(0,1)(0,2)
(1,0)(1,1)(1,2)
(2,0)(2,1)(2,2)
 
——-
 
1,2:
(0,1)(0,2)
 
(2,0)
 
——-
 
2,0:
(0,0)(0,1)(0,2)
(1,0)(1,1)(1,2)
(2,0)(2,1)(2,2)
 
——-
 
————CSP:fCN———
 
0,1:
(0,1)  (1,2)  (2,0)  
——-
 
1,0:
(0,2)  (1,0)  (2,1)  
——-
 
2,1:
(0,2)  (1,0)  (2,0)  
——-
n:3
 
adjGF:
0 : 1
1 : 0
2 : 1
 
 
adjTGF:
0 : 1
1 : 0 2
2 :
 
finished u=1
finished u=0
finished u=2
 
———-HERE DFS() done—————-
u=2 numComp=0
u=0 numComp=1
Components graph:
0 : 2
1 : 0 1
2 :
 
numComp=2
 
 Node2Component:
Node:0 , Component:1
Node:1 , Component:1
Node:2 , Component:0
 
 
———-HERE DFST() done—————
adjSCC:
0 : 1
1 :
 
 
———-HERE findSCCGF() done———-
finished u: 1
finished u: 0
 
———-HERE DFSSCC() done————-
 
Component:0
order[0] = 2
 
Component:1
order[1] = 0
order[2] = 1
 
———-HERE finalOrder() done———
O.Qlength=3
head=2
adjGF[i]: 1
O print:
0->1->NULL
end: O print
L print:
1->NULL
end: L print
 J : 1
————after array—————-
————after array set up—————-
————as previous link list—————-
i=2  j=1 k=0
functional[j*n+k] && (!wasIn[k])1—1
++++6+++++++++++++++++++++++++K 0
0->NULL
+++++7+++++++  k +++++++++++++++++0
————Origin cij:———
cij[0]2
cij[1]0
cij[2]0
————Origin cik:———
cjk[0]2
cjk[1]0
cjk[2]1
————Newcomposed CSP begin:———
v:0
c_{2,1}[0]2
cjk[v]2
cjk[cij[v]]1
c_ik[v]1
————Newcomposed CSP begin:———
v:1
c_{2,1}[1]0
cjk[v]0
cjk[cij[v]]2
c_ik[v]2
————Newcomposed CSP begin:———
v:2
c_{2,1}[2]0
cjk[v]1
cjk[cij[v]]2
c_ik[v]2
fCN[i*n+k][v]   :: 1
fCN[i*n+k][v]   :: 2
fCN[i*n+k][v]   :: 2
c_{2,0}: [ 0 1]
c_{2,0}: [ 1 2]
c_{2,0}: [ 2 2]
++++++++++++++++++
here we go: cik=fCN[i*n+k]
reviseDomain(i,k);
 
adjGF:
0 :
1 :
2 : 1 0
 
 
funcross_link_list:
0 : 2
1 : 2
2 : 0 1
 
 
————CSP:cn———
 
0,2:
(0,1)
(1,2)
(2,2)
 
——-
 
1,2:
(0,1)(0,2)
 
(2,0)
 
——-
 
————CSP:fCN———
 
2,0:
(0,1)  (1,2)  (2,2)  
——-
 
2,1:
(0,2)  (1,0)  (2,0)  
——-
————as previous link list—————-
i=2  j=1 k=2
functional[j*n+k] && (!wasIn[k])0—1
L.QLength() : 1
Queue is empty.
++++++8+++++++++++++++++++++++
O.Qlength=2
head=0
adjGF[i]: 0
O print:
1->NULL
end: O print
L print:
Queue is empty.
end: L print
++++++8+++++++++++++++++++++++
O.Qlength=1
head=1
adjGF[i]: 0
O print:
Queue is empty.
end: O print
L print:
Queue is empty.
end: L print
++++++8+++++++++++++++++++++++
start: translation
end: translation
delete:fCN
 
————CSP:cn———
 
0,2:
(0,1)
(1,2)
(2,2)
 
——-
 
1,2:
(0,1)(0,2)
 
(2,0)
 
——-
 
2,0:
 
(1,0)
(2,1)(2,2)
 
——-
 
2,1:
(0,2)
(1,0)
(2,0)
 
——-
 
————CSP:fCN———
Checking Solution Against Constraint Graph
Solution Acceptable.
# of values removed before search:# of values removed:# of constraint checks:# of domain checks
2:6:39:0
[BT::statistics()] #backtracks=0 maxPhase=3
number of failed assignments:0
number of pruned values:0
:Time used:0.0s
average cchecks+dchecks+ochecks: average backtracks: average search depth
39+0+0:0:3
the consistent instances are (%d)
1
 %d0
the inconsistent instances are (%d)
0
 
Total time:0.0s
mangosteen.cs.ttu.edu$ csp.out -f 3 3 3 3 1 3 1

adjGF

adjGF:
0 : 8
1 :
2 : 5
3 : 4
4 : 3 6
5 : 7 8
6 :
7 :
8 : 3  
funcross_link_list:
0 : 8
1 : 6
2 : 4 5
3 : 4 8
4 : 2 3 6
5 : 2 7 8
6 : 1 4
7 : 5
8 : 0 3 5
—————————fc(0,8,3)
adjGF:
0 : 8 3
1 :
2 : 5
3 : 4
4 : 3 6
5 : 7 8
6 :
7 :
8 :   
funcross_link_list:
0 : 8 3
1 : 6
2 : 4 5
3 : 4 0
4 : 2 3 6
5 : 2 7 8
6 : 1 4
7 : 5
8 : 0 5
============================nfc(0,8,5)
adjGF:
0 : 8 3
1 :
2 : 5
3 : 4
4 : 3 6
5 : 7 8
6 :
7 :
8 :

funcross_link_list:
0 : 8 3 5
1 : 6
2 : 4 5
3 : 4 0
4 : 2 3 6
5 : 2 7 0
6 : 1 4
7 : 5
8 : 0

segmentation debug

————Newcomposed CSP begin:——— v:8 c_{3,4}[8]-1 cjk[v]-1 cjk[cij[v]]41 c_ik[v]-1 c_{3,6}: [ 0 8] c_{3,6}: [ 1 1] c_{3,6}: [ 2 3] c_{3,6}: [ 3 -1] c_{3,6}: [ 4 -1] c_{3,6}: [ 5 3] c_{3,6}: [ 6 4] c_{3,6}: [ 7 -1] c_{3,6}: [ 8 -1] ++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++ typecons=:2 removed v : 0 reviseDomain(i,k); L.QLength() : 1 Queue is empty. ++++++8+++++++++++++++++++++++ O.Qlength=6 head=4 adjGF[i]: 2 O print: 7->8->6->5->2->NULL end: O print L print: 3->6->NULL end: L print starting L.QLength() : 1 i=4 j=3 k=4 functional[j*n+k] && (wasIn[k])1—1 ++++6+++++++++++++++++++++++++K 4 i=4 j=3 k=8 functional[j*n+k] && (wasIn[k])0—1 +++++7+++++++ k +++++++++++++++++8 L.QLength() : 2 4->NULL starting L.QLength() : 0 i=4 j=4 k=2 functional[j*n+k] && (wasIn[k])0—1 i=4 j=4 k=3 functional[j*n+k] && (wasIn[k])1—0 i=4 j=4 k=6 functional[j*n+k] && (wasIn[k])1—0 L.QLength() : 0 Queue already empty. Queue is empty. ++++++8+++++++++++++++++++++++ O.Qlength=5 head=7 adjGF[i]: 0 O print: 8->6->5->2->NULL end: O print L print: Queue is empty. end: L print ++++++8+++++++++++++++++++++++ O.Qlength=4 head=8 adjGF[i]: 1 O print: 6->5->2->NULL end: O print L print: 3->NULL end: L print starting L.QLength() : 0 i=8 j=3 k=4 functional[j*n+k] && (wasIn[k])1—0 +++++7+++++++ k +++++++++++++++++4 ————Origin cij:———

Neural network -matlab implement

function sigmoid = sigmoid(var)
   sigmoid = 2/(1+exp(-var)) - 1;
end
function dsigmoid = dsigmoid(var)
   dsigmoid = 0.5 * (1 + sigmoid(var)) * (1 - sigmoid(var));
end

[x,y,t] = textread(’hw3data.txt’,'%f %f %f’);
m=1;n=1;
for i =1 : length(t)
    if t(i) == 1
        x1(m) = x(i);
        y1(m) = y(i);
        m = m + 1;
    else
        x2(n) = x(i);
        y2(n) = y(i);
        n = n + 1;
    end
end

 P1 = 5;
 P2 = 5;
 U = rand(3,5);
 V = rand(6,5);
 W = rand(6,1);
 dU = rand(3,5);
 dV = rand(6,5);
 dW = rand(6,1);
 alpha = 0.4;
 epach = 0;
 i = 1;
 max=10000;
 
 while(i<max) && stopping_cond < 30
     E(i) = 0;
     epach = epach + 1;
     for i = 1 : 600
         %feed forward: set p1=5 p2=5
         for j1 = 1 : P1
             z_in(j1) = sum(x(i)*U(i))
             z(j1) = 2/(1+exp(-z_in(j1))) - 1;
             for j2 = 1 : P2
                 zz_in(j2) = sum(z(j1)* V(j1,j2));
                 %when should I add ";" after finishing a line
                 zz(j2) = 2/(1 + exp(- z_in(j2)) - 1;
                 y_in = sum(zz(j2)*W(j2,1));
                 y = 2/(1 + exp(- y_in)) - 1;
             end
         end
         
         %error
         E(i) = E(i) + (t(i) - y(i))^2;
         stopping_cond=E(i);
         %—————-BP
         %1. set up delta
         for k = 1 : 600
             delta(k) = (t(k)-y(k)) * dsigmoid(y_in(k));
             k = k + 1;
         end         
         
         dW(0,1) = alpha * delta(0);
         for j2 = 1 : P2
             dW(j2,1) = alpha * delta(zz(j2));
             delta(zz_in(j2))= delta(j2)*W(j2,1);
             %???delta(zz(j2)) or delta(j2)
             delta(zz(j2))=delta(zz_in(j2))*dsigmoid(zz_in(j2));
             dV(0,j2)=alpha*delta(zz(j2))
             for j1 = 1 : P1
                 dV(j1,j2)=alpha*delta(zz(j2))*z(j1);                 
             end      
         end         
         %——
         for j1=1:P1
             for j2=1:P2
                 delta(z_in(j1))=delta(z_in(j1))+delta(zz(j2))*V(j1,j2);
             end
             delta(z(j1))=delta(z_in(j1))*dsigmoid(z_in(j1));
             dU(0,j1)=alpha*delta(z(j1));
             dU(i,j1)=alpha*delta(z(j1))*x(i);
         end         
         
         %—update weight and bias:U = U + DU;…
         for j1=1:P1
             for j2=1:P2
                 W(j2,1)=W(j2,1)+dW(j2,1);
                 V(j1,j2)=V(j1,j2)+dV(j1,j2);
             end
             U(i,j1)=U(i,j1)+dU(i,j1);
         end
                  
         U
         V
         W
     end
     i = i + 1;
 end
 
 scatter(x1,y1,’+b’)
 hold on
 scatter(x2,y2,’+r’)
 axis([-0.5,1.5,-0.5,1.5])
 x = -0.5 : 0.005 : 1.5
 y = -0.5 : 0.005 : 1.5
 [ X, Y ] = meshgrid(x, y);
 
 %how to make the following?
 %newx = [x’ size(y)];
 %newy = [y’ size(y)];
 k = 1;
 for i = 1 : 401
     for j = 1 : 401
         newx(k) = X(i,j);
         newy(k) = Y(i,j);
         k = k + 1;
     end
 end
 
 for i= 1 : length(newx)
     %feed forward: set p1=5 p2=5
         for j1 = 1 : P1
             z_in(j1) = sum(x(i)*U(i))
             z(j1) = 2/(1+exp(-z_in(j1))) - 1;
             for j2 = 1 : P2
                 z_in(j2) = sum(z(j1)* V(j1,j2));
                 %when should I add ";" after finishing a line
                 zz(j2) = 2/(1 + exp(- z_in(j2)) - 1;
                 y_in = sum(zz(j2)*W(j2,1));
                 y(i) = 2/(1 + exp(- y_in(i))) - 1;
             end
         end
 end
 Z = y;
 contour(newx,newy,Z)
 
 hold off    
 legend(’data +1′, ‘data -1′)
 title(’HW3:NN’)