xjiang4 / ellipsoids

Automatically exported from code.google.com/p/ellipsoids
Other
0 stars 1 forks source link

Cover intersection_ia/ea for everything but ellipsoid and polytope with unit tests #119

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Currently we have tests only for intersections of ellipsoid and polytope

Original issue reported on code.google.com by heartofm...@gmail.com on 16 May 2013 at 10:32

GoogleCodeExporter commented 8 years ago
The goal of this task is to cover intersection_ia and intersection_ea methods 
of ellipsoid class with unit tests for all the cases but the case when the 
first input is ellipsoid and the second is polytope. 

The tests should be placed into elltool.core.test.mlunit.MPTIntegrationTestCase 

This test case already contains a few tests that call these methods but they 
only cover an intersection of ellipsoid and polytope. You can use these tests 
as an example. The tests you write should verify that intersection 
approximation is performed correctly using a set of simple examples for which 
the expected results are easy to verify analytically. Also, you can approximate 
a geometrical body represented by the second input with a polytope, then 
calculate an approximation intersection with this polytope (this functionality 
is already tested) and then compare the expected output with real output of 
intersection_ea/ia functions

Original comment by heartofm...@gmail.com on 19 Sep 2013 at 8:19

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
1) What did you change the existing test for? (I mean replacing 
ellipsoid([-0.362623; -0.362623],[0.375307 -0.13955;-0.13955 0.375307]); with 
ellipsoid(1/16*eye(2))?

2) Unless you had a strong reason for 1) please revert the changes for already 
existing tests and write your tests in a separate method 
"testIntersectionForHyper" and "testIntersectionForEll"

3) Fix variable names in your tests
4) As far as I remember you mentioned that in certain cases intersection 
methods return ellipsoids with zero configuration matrices instead of empty 
ones. If this is the case please fix the intersection methods and write the 
proper tests.
5) Please use 

[isOk,reportStr]=ell1.isEqual(ell2);
mlunitext.assert(isOk,reportStr);

instead of

mlunitext.assert(eq(ell1,ell2)); 

Report str contains the description of object differences

 Also please always use method-like calls ell1.eq(ell2) instead of function-like calls eq(ell1,ell2)

6) Please include objects of higher dimensions and multi-dimensional arrays of 
objects (hyperplanes, polytopes and ellipsoids) in your tests.

Original comment by heartofm...@gmail.com on 30 Oct 2013 at 2:02

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
You may not use Russian, please write all the comments in English

Original comment by heartofm...@gmail.com on 5 Nov 2013 at 3:13

GoogleCodeExporter commented 8 years ago

Original comment by vs.roz...@gmail.com on 23 Nov 2013 at 10:00

GoogleCodeExporter commented 8 years ago
6) - is not done.  There are still no tests for multi-dimensional (2,3,5) 
arrays of ellipsoids, only for vector of ellipsoid. You need to create tests 
for arrays with sizes. Also, when you create tests for different dimensions 
please try to avoid copy-pasting, instead create a nested/sub function (named 
"check" for instance) parameterized with a dimensionality and call it like this:
check([2,1,4,1]);
check([2,3,1,5]);

3) - you introduced incorrect names again (i - bad name, variable names cannot 
start with capital letters etc). 

Original comment by heartofm...@gmail.com on 25 Nov 2013 at 2:15

GoogleCodeExporter commented 8 years ago
To be sure, you want me to create several sub functions, each for each
case, which use dimension of an ellipsoid (not of an array of ellipsoids)
as parametr? Could you explain me what does "check([2,3,1,5]" exactly mean,
for which case it can be used?

And about multi-dimensional arrays of ellipsoids (for example for 3) should
I use 3-dimensional matrix consists of matrises of 9 ellipsoids? Or  should
I just create a 3x3 matrix from 9 defined ellipsoids and MatLab will solve
this problem for me?

Original comment by vs.roz...@gmail.com on 25 Nov 2013 at 11:38

GoogleCodeExporter commented 8 years ago
"you want me to create several... " - yes, that's correct. Input vector 
"[2,3,1,5]" for a hypothetical "check" subfunction would define a 
dimensionality of ellipsoidal array for which the testing is performed. The 
whole code of the subfunction would be generic and would work for any 
dimensionality.

As for multi-dimensional arrays - you need to use ellipsoid constructor for 
that, see the help header:

ellMat = ellipsoid(centVecArray, shMatArray,

where centVecArray and shMatArray are multi-dimensional arrays containing 
centers and matrices for all elements of ellipsoidal array.

If you want to create 3x5x2 array of 7 dimensional ellipsoids then 
shMatArray would be of size 7x7x3x5x2

Original comment by heartofm...@gmail.com on 29 Nov 2013 at 12:43

GoogleCodeExporter commented 8 years ago
So, I create a multi-dimensional array 4x3 of 2 dimensional ellipsoids (shMat 
size: 2x2x4x3):
myEll = ellipsoid(shMat);
plot(myEll);
Is it normal that Matlab plots the line? And as internal approx of intersection 
with a single ellipsoid I get the part of this line? 

And I can't get the difference between a vector of 30 ellipsoids and an array 
of dimensions [2,3,1,5] which, as far as I understand, contains 30 ellipsoids. 
Moreover, the intersection between an array of ellipsoids and a single 
ellipsoid (or hyperplane) is an array of the same size, is it right?

���������� � iPhone

Original comment by vs.roz...@gmail.com on 1 Dec 2013 at 1:15

GoogleCodeExporter commented 8 years ago
1) (shMat size: 2x2x4x3): - shMat would be an incorrect name in this case
2) This depends, please provide a self-contained example
3) What do you mean by "I can't get"? What kind of difference are you talking 
about?
4)  "(or hyperplane) is an array of the same size, is it right?" - that is 
correct.

Original comment by heartofm...@gmail.com on 4 Dec 2013 at 2:42

GoogleCodeExporter commented 8 years ago

Original comment by vs.roz...@gmail.com on 15 Dec 2013 at 11:39

GoogleCodeExporter commented 8 years ago

Original comment by heartofm...@gmail.com on 17 Dec 2013 at 1:07

GoogleCodeExporter commented 8 years ago

Original comment by vs.roz...@gmail.com on 17 Dec 2013 at 8:39

GoogleCodeExporter commented 8 years ago
The review results were sent via email

Original comment by heartofm...@gmail.com on 23 Dec 2013 at 3:00

GoogleCodeExporter commented 8 years ago
I found a few bugs in intersection_ia/ea which means that the test coverage is 
not dense enough (see below). Please 

1) write tests that include both empty ellipsoids and ellipsoid of zero 
diameter (points)

2) Make sure that these tests reproduce both problems show below and then fix 
them. Please note that 

Data: 
   |    
   |-- centerVec : [0 0]
   |               -------------
   |--- shapeMat : |1e-07|0    |
   |               |0    |1e-07|
   |               -------------

as a result also doesn't seem to be correct. 

>> ellipsoid(zeros(2)).intersection_ia(ellipsoid(eye(2)))
Warning: Matrix is singular to working precision. 
> In ellipsoid.ellintersection_ia at 84
  In ellipsoid.intersection_ia>l_intersection_ia at 173
  In ellipsoid.intersection_ia>fChoose at 135
  In ellipsoid.intersection_ia>@(x)fChoose(x,1) at 124
  In ellipsoid.intersection_ia at 124 
Warning: Matrix is singular to working precision. 
> In ellipsoid.ellintersection_ia at 84
  In ellipsoid.intersection_ia>l_intersection_ia at 173
  In ellipsoid.intersection_ia>fChoose at 135
  In ellipsoid.intersection_ia>@(x)fChoose(x,1) at 124
  In ellipsoid.intersection_ia at 124 
Error using eig
Input to EIG must not contain NaN or Inf.

Error in ellipsoid/ellintersection_ia (line 87)
    [vSecMat dSecMat] = eig(intermSecEllShMat);

Error in ellipsoid/intersection_ia>l_intersection_ia (line 173)
        outEll = ellintersection_ia([fstEll secObj]);

Error in ellipsoid/intersection_ia/fChoose (line 135)
            outEllArr(index) = l_intersection_ia(singEll, obj);

Error in ellipsoid/intersection_ia>@(x)fChoose(x,1) (line 124)
    arrayfun(@(x) fChoose(x, 1),indexVec);

Error in ellipsoid/intersection_ia (line 124)
    arrayfun(@(x) fChoose(x, 1),indexVec);

>> ellipsoid(zeros(2)).intersection_ea(ellipsoid(eye(2)))

-------ellipsoid object-------
Properties:
   |    
   |-- actualClass : 'ellipsoid'
   |--------- size : [1 1]

Fields (name, type, description):
    Q    double    Ellipsoid shape matrix.
    q    double    Ellipsoid center vector.

Data: 
   |    
   |-- centerVec : [0 0]
   |               -------------
   |--- shapeMat : |1e-07|0    |
   |               |0    |1e-07|
   |               -------------
>>

Original comment by heartofm...@gmail.com on 24 Dec 2013 at 12:00

GoogleCodeExporter commented 8 years ago
3) Also, please include tests for empty/dot-valued ellipsoids and hyperplanes

Original comment by heartofm...@gmail.com on 24 Dec 2013 at 12:32

GoogleCodeExporter commented 8 years ago

Original comment by vs.roz...@gmail.com on 13 Jan 2014 at 9:37

GoogleCodeExporter commented 8 years ago
You need to make all the tests pass - right now they do not pass (see the 
automated reports, error_fail_list.txt attachement)

Original comment by heartofm...@gmail.com on 14 Jan 2014 at 5:53