naushad-rahman / ellipsoids

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

Provide a dense coverage of distance method of ellipsoid class with the unit tests AND optimize calculation of point2ellipsoid distance #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
You should crete elltool.solvers.grad.test.mlunit package, 
it would be located in 
<YourWorkingCopy>\products\+elltool\+solvers+\+grad\+test\+mlunit. 

In this package you should create GradNonLynDescTestCase MLUNITEXT test class, 
the name of the file would 
be  
<YourWorkingCopy>\products\+elltool\+solvers+\grad\+test\+mlunit\GradNonLynDescT
estCase.m

Along with this class you should 
 # create run_tests function in <YourWorkingCopy>\products\+elltool\+solvers\+grad\+test folder which 
would put it into elltool.solvers.grad.test package
 # Modify elltool.test.run_tests function so that it calls 
your newly created elltool.solvers.grad.test.run_tests function in the way 
described in 
item 3 on 

http://code.google.com/p/ellipsoids/wiki/MLUNITEXT_unit_testing_framework_descri
ption 

Wiki page

Once all this is done you need to write unit tests for 

products/ elltoolboxcore/ solvers/ gradient/ ell_nlfnlc.m 

function.

Original issue reported on code.google.com by heartofm...@gmail.com on 19 Oct 2012 at 6:30

GoogleCodeExporter commented 9 years ago

Original comment by vetba...@gmail.com on 21 Oct 2012 at 9:06

GoogleCodeExporter commented 9 years ago
I few things to make a picture clear:

1. What is item 3 (in Wiki):
"mlunit_test - contains the tests for ..."
or
Structuring the tests into packages

2. Why do I need to create run_tests function in 
<YourWorkingCopy>\products\+elltool\+solvers\+grad\+test and what should it do?

3. Where shall I write unit tests? (guess in GradNonLynDescTestCase.m as 
methods)

4. Can you explain once more what these unit tests should check?

Original comment by vetba...@gmail.com on 22 Oct 2012 at 9:16

GoogleCodeExporter commented 9 years ago
1) I was referring to "Structuring the tests into packages"
2) The idea is that each package with tests should have a separate run_tests 
function to run them. The higher-level run_tests function for a package would 
then call run_tests functions of sub-packages. The function you create should 
exactly what is shown in 
http://code.google.com/p/ellipsoids/wiki/MLUNITEXT_unit_testing_framework_descri
ption, typical usecase for mlunit, item 2 i.e. run all tests from 
GradNonLynDescTestCase class
3) Yes, in GradNonLynDescTestCase class as methods.

4) Example: let us suppose that we want to test a gradient descend minimization 
for a function of 1 variable. To do that we can consider a sample function 
f(x)=x^2 and make sure that our method returns 0. Then we take f(x)=(x-a)^2 +b 
and make sure that the method returns b. The more complex the test is - the 
better.

In your case you need to compose an analytical function that has a minimum 
value and minimizer that can be calculated analyrically. Then you call the 
ell_nlfnlc and make sure that it returns a value that is sufficiently close to 
the expected value. A level of proximity should be based on ellOptions.abs_tol 
specified upon the ellipsodi toolbox configuration.

Original comment by heartofm...@gmail.com on 22 Oct 2012 at 9:27

GoogleCodeExporter commented 9 years ago
And please note that just one sample function is not enough, you need to come 
up with a few sophisticated examples that would provide a dense coverage. And 
of course it is not just about the function, you also have the non-linear 
constraints to keep in mind.

Original comment by heartofm...@gmail.com on 22 Oct 2012 at 9:31

GoogleCodeExporter commented 9 years ago
Minimaztion function often gives not exact result but with some predifined 
tolerance. What tolerance should I use to compare the result of funtion with 
ectual analitical answer? 

Original comment by vetba...@gmail.com on 23 Oct 2012 at 12:25

GoogleCodeExporter commented 9 years ago
And I cannont (always recieve an error) call ell_nlfnlc(fun,x0,nlcf) function 
with anonymous or inline function that return vector [A,B] as a result. This is 
because feval applied to anonymous or inline function cannot return x,y: 
[x,y]=feval().
So I have to write constraint functions in file where my test class is 
described and pass handles to ell_nlfnlc, but its not very conveniet. 
Is there any other way to pass parameter nlcf?

Original comment by vetba...@gmail.com on 23 Oct 2012 at 12:41

GoogleCodeExporter commented 9 years ago
And recieving multiple outputs in matlab is not possible at all:
http://www.mathworks.com/support/solutions/en/data/1-2QPNT6/?product=ML&solution
=1-2QPNT6
while in ell_nlfnlc.m it's written: "NLCF (inline or function handler)" and 
then used  [ctmp,ceqtmp] = feval(confcn{3}, X, varargin{:}); in line 151, that 
lead to an error. 

Original comment by vetba...@gmail.com on 23 Oct 2012 at 12:45

GoogleCodeExporter commented 9 years ago
Changing an assignment. 

Original comment by heartofm...@gmail.com on 23 Oct 2012 at 3:11

GoogleCodeExporter commented 9 years ago
1) distance is a function in elltoolboxcore\@ellipsoid?
2) where should I put run_tests file?

Original comment by vetba...@gmail.com on 23 Oct 2012 at 3:37

GoogleCodeExporter commented 9 years ago
3) And should I delete all the files created for the previous task?

Original comment by vetba...@gmail.com on 23 Oct 2012 at 3:39

GoogleCodeExporter commented 9 years ago
It is elltool.core.test.mlunit.EllipsoidTestCase class and 
elltool.core.test.run_tests function.

Look at Vadim's branch: 
http://code.google.com/p/ellipsoids/source/browse/branches/issue_13_vkaushanskiy
/products/%2Belltool/%2Bcore/%2Btest/%2Bmlunit/EllipsoidTestCase.m

You should create exactly the same class, just with different methods. 

Yes, please delete them.

Original comment by heartofm...@gmail.com on 23 Oct 2012 at 3:45

GoogleCodeExporter commented 9 years ago
Distance function doesnt work, always ends up with an error:

Undefined function 'sdpvar' for input arguments of type 'double'.

Error in ellipsoid/distance>l_elldist (line 308)
        x      = sdpvar(mx1, 1);

Original comment by vetba...@gmail.com on 23 Oct 2012 at 5:34

GoogleCodeExporter commented 9 years ago
You need to install Yalmip as described on the wiki page 
http://code.google.com/p/ellipsoids/wiki/Toolbox_installation_instructions

Original comment by heartofm...@gmail.com on 23 Oct 2012 at 5:38

GoogleCodeExporter commented 9 years ago
Is it appropriate if a test results in failure because even for simple test 
calculated distance is, for example, 2.0003 while it has to be 2, and since 
0.0003 is more the  ellOptions.abs_tol it results in failure.

Original comment by vetba...@gmail.com on 23 Oct 2012 at 6:09

GoogleCodeExporter commented 9 years ago
No, this is not good and means that there is a bug in distance method as the 
result precision should not be greater than abs_tol. You need to find and fix 
that bug so that the test passes. My guess is that when Yalmip is called from 
distance method it is passed an incorrect level of precision. 

Original comment by heartofm...@gmail.com on 23 Oct 2012 at 6:15

GoogleCodeExporter commented 9 years ago
I've found where an error was! Let me fix it accurately, and then I'll commit. 

Original comment by vetba...@gmail.com on 23 Oct 2012 at 7:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ok, good. Just avoid passing the constants into the solver that are not related 
to abs_tol i.e. something like

solve('precision',1e-17) is no acceptable.

You need to use solve('precision',f(abs_tol)) where f is some function found 
empirically.

Original comment by heartofm...@gmail.com on 23 Oct 2012 at 7:17

GoogleCodeExporter commented 9 years ago
And what if use 'global  ellOptions' in solver? It will be inconvenient to pass 
abs_tol as parameter through many functions, and in only when calling eval from 
function solvsdp option parameters became known depending on the method, which 
is chosen in solvsdp.m. So, the only way is to prescribe tolerance in the last 
function, that is mincx.m. 

Original comment by vetba...@gmail.com on 23 Oct 2012 at 7:33

GoogleCodeExporter commented 9 years ago
Use of global variables is prohibited in any form. The existing places where 
they are used will be refactored. in distance function there is already a 
reference to global variable ellOptions, you can use it for now. The settings 
to the solver are passed via ellOptions.sdpsettings at line 317 for instance. 
You should use this way of transferring the parameters into the solver.

Please commit all you have right now, I want to see at least something.

Original comment by heartofm...@gmail.com on 23 Oct 2012 at 8:11

GoogleCodeExporter commented 9 years ago
An optimal algorithm of calculating the distance between a point and an 
ellipsoid is covered in the following article.

https://ellipsoids.googlecode.com/svn/wiki/attachments/ellipsoiddistance/point2e
llipsoid.pdf

Original comment by heartofm...@gmail.com on 24 Oct 2012 at 6:08

GoogleCodeExporter commented 9 years ago
YOU ARE CLEARED TO REINTEGRATE. Just be very careful, you have only one try. If 
reintegrate fails you would have to delete your branch and create a new one.

Here is the procedure, please follow it to the letter:

1) Update you branch.
2) Merge trunk into your branch.
3) Commit the result of the merge.
4) Checkout latest trunk into a separate folder (or update an existing working 
copy of the trunk).
5) Reintegrate to trunk FROM your branch.
6) Commit to trunk, before committing - verify once more that the tests pass, 
ALL the tests, not just yours. If something wrong - do not commit. 
7) Delete your branch.

The task is considered FIXED only when the automatic tests in the trunk after 
you commit pass. The test currently run every 6 hours and the results are sent 
to the members of the open group 
https://groups.google.com/forum/?fromgroups#!forum/ellipsoids-tests-notification
. I suggest that you subscribe and make sure that the tests pass after your 
reintegration. If not - you would have to create a branch for issue 24 once 
more, fix the bug and reintegrate it into the trunk once more.

Original comment by heartofm...@gmail.com on 28 Oct 2012 at 5:32

GoogleCodeExporter commented 9 years ago

Original comment by vetba...@gmail.com on 29 Oct 2012 at 7:01

GoogleCodeExporter commented 9 years ago

Original comment by heartofm...@gmail.com on 29 Oct 2012 at 7:34