Skip to content

Commit

Permalink
[ctc] CtcDeriv: restoring performances of V2 (polygons)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRohou committed Jun 16, 2020
1 parent 64116b0 commit e19f459
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure $(ARGS)
DEPENDS tubex COMMENT "Running the tests")

#add_subdirectory(tests)
add_subdirectory(tests)
endif()

option(TEST_EXAMPLES "Testing examples" OFF)
Expand Down
1 change: 1 addition & 0 deletions src/core/arithmetic/tubex_polygon_arithmetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace tubex
vector<Point> v_result_thick_pts = Point::to_Points(x.vertices());
for(auto& pt : v_result_thick_pts)
pt = Point(pt.box() + v);
// ^ The operation may transform a degenerate point-box into a large box

return ConvexPolygon(v_result_thick_pts);
}
Expand Down
49 changes: 37 additions & 12 deletions src/core/dynamics/slice/tubex_Slice_polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ namespace tubex

else
{
vector<Point> v_pts;
v_pts.push_back(Point(t.lb(), input_gate().lb()));
vector<Vector> v_pts;
v_pts.push_back(Vector({t.lb(), input_gate().lb()}));

// Lower bounds

Expand All @@ -126,23 +126,35 @@ namespace tubex
y_inter_lb = yolb(t_inter_lb, *this, v) | yilb(t_inter_lb, *this, v);

if(y_inter_lb.ub() >= codomain().lb())
v_pts.push_back(Point(t_inter_lb, y_inter_lb));
{
if(t_inter_lb.is_degenerated())
v_pts.push_back(Vector({t_inter_lb.ub(), y_inter_lb.lb()}));

else
{
// The following transforms the line intersection result into
// two floating 2d vectors. This creates an additional point,
// but maintains reliability.
v_pts.push_back(Vector({t_inter_lb.lb(), y_inter_lb.lb()}));
v_pts.push_back(Vector({t_inter_lb.ub(), y_inter_lb.lb()}));
}
}

else
{
Interval t_a = yilb_inv(codomain().lb(), *this, v);
v_pts.push_back(Point(t_a.lb(), codomain().lb()));
v_pts.push_back(Vector({t_a.lb(), codomain().lb()}));
Interval t_b = yolb_inv(codomain().lb(), *this, v);
v_pts.push_back(Point(t_b.ub(), codomain().lb()));
v_pts.push_back(Vector({t_b.ub(), codomain().lb()}));
}
}
}

v_pts.push_back(Point(t.ub(), output_gate().lb()));
v_pts.push_back(Vector({t.ub(), output_gate().lb()}));

// Upper bounds

v_pts.push_back(Point(t.ub(), output_gate().ub()));
v_pts.push_back(Vector({t.ub(), output_gate().ub()}));

if(!v.codomain().is_degenerated())
{
Expand All @@ -162,20 +174,33 @@ namespace tubex
y_inter_ub = youb(t_inter_ub, *this, v) | yiub(t_inter_ub, *this, v);

if(y_inter_ub.lb() <= codomain().ub())
v_pts.push_back(Point(t_inter_ub, y_inter_ub));
{
if(t_inter_ub.is_degenerated())
v_pts.push_back(Vector({t_inter_ub.ub(), y_inter_ub.ub()}));

else
{
// The following transforms the line intersection result into
// two floating 2d vectors. This creates an additional point,
// but maintains reliability.
v_pts.push_back(Vector({t_inter_ub.ub(), y_inter_ub.ub()}));
v_pts.push_back(Vector({t_inter_ub.lb(), y_inter_ub.ub()}));
}
}

else
{
Interval t_b = youb_inv(codomain().ub(), *this, v);
v_pts.push_back(Point(t_b.ub(), codomain().ub()));
v_pts.push_back(Vector({t_b.ub(), codomain().ub()}));
Interval t_a = yiub_inv(codomain().ub(), *this, v);
v_pts.push_back(Point(t_a.lb(), codomain().ub()));
v_pts.push_back(Vector({t_a.lb(), codomain().ub()}));
}
}
}

v_pts.push_back(Point(t.lb(), input_gate().ub()));
return ConvexPolygon(v_pts);
v_pts.push_back(Vector({t.lb(), input_gate().ub()}));
v_pts = Point::remove_identical_pts(v_pts);
return ConvexPolygon(v_pts, true);
}
}
}

0 comments on commit e19f459

Please sign in to comment.