comments only
							parent
							
								
									485f8d003b
								
							
						
					
					
						commit
						0d66ee8f72
					
				
							
								
								
									
										18
									
								
								.cproject
								
								
								
								
							
							
						
						
									
										18
									
								
								.cproject
								
								
								
								
							|  | @ -395,14 +395,6 @@ | |||
| <useDefaultCommand>true</useDefaultCommand> | ||||
| <runAllBuilders>true</runAllBuilders> | ||||
| </target> | ||||
| <target name="testLinearConstraint.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> | ||||
| <buildCommand>make</buildCommand> | ||||
| <buildArguments/> | ||||
| <buildTarget>testLinearConstraint.run</buildTarget> | ||||
| <stopOnError>true</stopOnError> | ||||
| <useDefaultCommand>true</useDefaultCommand> | ||||
| <runAllBuilders>true</runAllBuilders> | ||||
| </target> | ||||
| <target name="testNonlinearFactorGraph.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> | ||||
| <buildCommand>make</buildCommand> | ||||
| <buildArguments/> | ||||
|  | @ -418,14 +410,6 @@ | |||
| <useDefaultCommand>true</useDefaultCommand> | ||||
| <runAllBuilders>true</runAllBuilders> | ||||
| </target> | ||||
| <target name="testConstrainedConditionalGaussian.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> | ||||
| <buildCommand>make</buildCommand> | ||||
| <buildArguments/> | ||||
| <buildTarget>testConstrainedConditionalGaussian.run</buildTarget> | ||||
| <stopOnError>true</stopOnError> | ||||
| <useDefaultCommand>true</useDefaultCommand> | ||||
| <runAllBuilders>true</runAllBuilders> | ||||
| </target> | ||||
| <target name="testConstrainedLinearFactorGraph.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> | ||||
| <buildCommand>make</buildCommand> | ||||
| <buildArguments/> | ||||
|  | @ -436,6 +420,7 @@ | |||
| </target> | ||||
| <target name="install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> | ||||
| <buildCommand>make</buildCommand> | ||||
| <buildArguments/> | ||||
| <buildTarget>install</buildTarget> | ||||
| <stopOnError>true</stopOnError> | ||||
| <useDefaultCommand>true</useDefaultCommand> | ||||
|  | @ -443,6 +428,7 @@ | |||
| </target> | ||||
| <target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> | ||||
| <buildCommand>make</buildCommand> | ||||
| <buildArguments/> | ||||
| <buildTarget>clean</buildTarget> | ||||
| <stopOnError>true</stopOnError> | ||||
| <useDefaultCommand>true</useDefaultCommand> | ||||
|  |  | |||
|  | @ -241,6 +241,7 @@ ExampleNonlinearFactorGraph createReallyNonlinearFactorGraph() { | |||
| /* ************************************************************************* */ | ||||
| ConstrainedLinearFactorGraph createSingleConstraintGraph() { | ||||
| 	// create unary factor
 | ||||
| 	// prior on "x", mean = [1,-1], sigma=0.1
 | ||||
| 	double sigma = 0.1; | ||||
| 	Matrix Ax = eye(2) / sigma; | ||||
| 	Vector b1(2); | ||||
|  | @ -249,6 +250,9 @@ ConstrainedLinearFactorGraph createSingleConstraintGraph() { | |||
| 	LinearFactor::shared_ptr f1(new LinearFactor("x", Ax, b1 / sigma)); | ||||
| 
 | ||||
| 	// create binary constraint factor
 | ||||
| 	// between "x" and "y", that is going to be the only factor on "y"
 | ||||
| 	// |1 2||x_1| + |10 0||y_1| = |1|
 | ||||
| 	// |2 1||x_2|   |0 10||y_2|   |2|
 | ||||
| 	Matrix Ax1(2, 2); | ||||
| 	Ax1(0, 0) = 1.0; Ax1(0, 1) = 2.0; | ||||
| 	Ax1(1, 0) = 2.0; Ax1(1, 1) = 1.0; | ||||
|  |  | |||
|  | @ -16,6 +16,7 @@ using namespace std; | |||
| TEST( ConstrainedLinearFactorGraph, elimination1 ) | ||||
| { | ||||
| 	// get the graph
 | ||||
| 	// *-X-x-Y
 | ||||
| 	ConstrainedLinearFactorGraph fg = createSingleConstraintGraph(); | ||||
| 
 | ||||
| 	// verify construction of the graph
 | ||||
|  | @ -26,9 +27,14 @@ TEST( ConstrainedLinearFactorGraph, elimination1 ) | |||
| 	ord.push_back("x"); | ||||
| 	ChordalBayesNet::shared_ptr cbn = fg.eliminate(ord); | ||||
| 
 | ||||
| 	//verify changes and output
 | ||||
| 	// verify result of elimination
 | ||||
| 	// CBN of size 1, as we only eliminated X now
 | ||||
| 	CHECK(fg.size() == 1); | ||||
| 	CHECK(cbn->size() == 1); | ||||
| 
 | ||||
| 	// We will have a "delta function" on X as a function of Y
 | ||||
| 	// |1 2||x_1| = |1| - |10 0||y_1|
 | ||||
| 	// |2 1||x_2|   |2|   |0 10||y_2|
 | ||||
| 	Matrix Ax1(2, 2); | ||||
| 	Ax1(0, 0) = 1.0; Ax1(0, 1) = 2.0; | ||||
| 	Ax1(1, 0) = 2.0; Ax1(1, 1) = 1.0; | ||||
|  | @ -36,6 +42,9 @@ TEST( ConstrainedLinearFactorGraph, elimination1 ) | |||
| 	Vector b2 = Vector_(2, 1.0, 2.0); | ||||
| 	ConstrainedConditionalGaussian expectedCCG1(b2, Ax1, "y", Ay1); | ||||
| 	CHECK(expectedCCG1.equals(*(cbn->get("x")))); | ||||
| 
 | ||||
| 	// verify remaining factor on y
 | ||||
| 	// Gaussian factor on X becomes different Gaussian factor on Y
 | ||||
| 	Matrix Ap(2,2); | ||||
| 	Ap(0, 0) =  1.0; Ap(0, 1) = -2.0; | ||||
| 	Ap(1, 0) = -2.0; Ap(1, 1) =  1.0; | ||||
|  | @ -48,12 +57,14 @@ TEST( ConstrainedLinearFactorGraph, elimination1 ) | |||
| 	Ordering ord2; | ||||
| 	ord2.push_back("y"); | ||||
| 	cbn = fg.eliminate(ord2); | ||||
| 
 | ||||
| 	// Check result
 | ||||
| 	CHECK(fg.size() == 0); | ||||
| 	Matrix Ar(2,2); | ||||
| 	Ar(0, 0) = 74.5356; Ar(0, 1) = -59.6285; | ||||
| 	Ar(1, 0) = 0.0;     Ar(1, 1) = 44.7214; | ||||
| 	Matrix R(2,2); | ||||
| 	R(0, 0) = 74.5356; R(0, 1) = -59.6285; | ||||
| 	R(1, 0) = 0.0;     R(1, 1) = 44.7214; | ||||
| 	Vector br = Vector_(2, 8.9443, 4.4721); | ||||
| 	ConditionalGaussian expected2(br, Ar); | ||||
| 	ConditionalGaussian expected2(br, R); | ||||
| 	CHECK(expected2.equals(*(cbn->get("y")))); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue