Skip to content

Commit

Permalink
Add tests for getting ranges of imagestar
Browse files Browse the repository at this point in the history
  • Loading branch information
mldiego committed Aug 28, 2024
1 parent 3eda77b commit 1e8437e
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions code/nnv/tests/set/image_star/test_ImageStar_getRange.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,53 @@
UB(:,:,2) = [0.1 0.15 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 0];
UB(:,:,3) = UB(:,:,2);

%% 1) Get Range
image = ImageStar(IM, LB, UB);
tic;
[xmin, xmax] = image.getRange(1,1,1);
toc;
display(xmin);
display(xmax);
display(xmax);

%% 2) Get Ranges
image = ImageStar(IM, LB, UB);
[xmin, xmax] = image.getRanges;

%% 3) Estimate Ranges
image = ImageStar(IM, LB, UB);
[xmin, xmax] = image.estimateRanges;

%% 4) Compare ranges (estimate >= get)
image1 = ImageStar(IM, LB, UB);
t = tic;
[xmin1, xmax1] = image1.estimateRanges;
t1 = toc(t);

% estimate ranges should be faster, but an overapproximation of getRanges
image2 = ImageStar(IM, LB, UB);
t = tic;
[xmin2, xmax2] = image2.getRanges;
t2 = toc(t);

disp("Estimate took " + string(t1) +" seconds vs getRanges, that run on " +string(t2) +"seconds");

assert(all(xmin1 - xmin2 <= eps, 'all'));
assert(all(xmax1 - xmax2 >= -eps, 'all'));

%% 5) Test from issues

V(1,1,1,1) = 0;
V(1,1,1,2) = -1;
V(1,1,1,3) = 1;
C = [0 0];
d = 0;
ub = [1; 1];
lb = -ub;

I1 = ImageStar(V, C, d, lb, ub);
I2 = ImageStar(V, C, d, lb, ub);

[xmin1, xmax1] = I1.estimateRanges;
[xmin2, xmax2] = I2.getRanges;


assert(all(xmin1 - xmin2 <= eps, 'all'));
assert(all(xmax1 - xmax2 >= -eps, 'all'));

0 comments on commit 1e8437e

Please sign in to comment.