Skip to content

Commit

Permalink
Add define lp_solve guards to orderpolytope
Browse files Browse the repository at this point in the history
  • Loading branch information
vissarion committed Feb 9, 2024
1 parent e767f46 commit c9fb177
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion include/convex_bodies/orderpolytope.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,32 @@ class OrderPolytope {
std::pair<Point, NT> ComputeInnerBall()
{
normalize();
return ComputeChebychevBall<NT, Point>(_A, b);
std::pair<Point, NT> inner_ball;
#ifndef DISABLE_LPSOLVE
inner_ball = ComputeChebychevBall<NT, Point>(_A, b); // use lpsolve library
#else

if (inner_ball.second <= NT(0)) {

NT const tol = 0.00000001;
std::tuple<VT, NT, bool> inner_ball = max_inscribed_ball(_A, b, 150, tol);

// check if the solution is feasible
if (is_in(Point(std::get<0>(inner_ball))) == 0 || std::get<1>(inner_ball) < NT(0) ||
std::isnan(std::get<1>(inner_ball)) || std::isinf(std::get<1>(inner_ball)) ||
!std::get<2>(inner_ball) || is_inner_point_nan_inf(std::get<0>(inner_ball)))
{
inner_ball.second = -1.0;
} else
{
inner_ball.first = Point(std::get<0>(inner_ball));
inner_ball.second = std::get<1>(inner_ball);
}
}
#endif

return inner_ball;

}


Expand Down

0 comments on commit c9fb177

Please sign in to comment.