Nlopt build fix
This commit is contained in:
parent
588456a5d9
commit
9172a69e27
@ -27,5 +27,6 @@ set(NLOPT_LINK_PYTHON OFF CACHE BOOL "" FORCE)
|
|||||||
add_subdirectory(${nlopt_SOURCE_DIR} ${nlopt_BINARY_DIR})
|
add_subdirectory(${nlopt_SOURCE_DIR} ${nlopt_BINARY_DIR})
|
||||||
|
|
||||||
set(NLopt_LIBS nlopt)
|
set(NLopt_LIBS nlopt)
|
||||||
set(NLopt_INCLUDE_DIR ${nlopt_BINARY_DIR})
|
set(NLopt_INCLUDE_DIR ${nlopt_BINARY_DIR}
|
||||||
|
${nlopt_BINARY_DIR}/src/api)
|
||||||
set(SHARED_LIBS_STATE ${SHARED_STATE})
|
set(SHARED_LIBS_STATE ${SHARED_STATE})
|
@ -95,9 +95,9 @@ void toSVG(SVG& svg, const Model& model) {
|
|||||||
|
|
||||||
std::tuple<double /*score*/, Box /*farthest point from bin center*/>
|
std::tuple<double /*score*/, Box /*farthest point from bin center*/>
|
||||||
objfunc(const PointImpl& bincenter,
|
objfunc(const PointImpl& bincenter,
|
||||||
double bin_area,
|
double /*bin_area*/,
|
||||||
ShapeLike::Shapes<PolygonImpl>& pile, // The currently arranged pile
|
ShapeLike::Shapes<PolygonImpl>& pile, // The currently arranged pile
|
||||||
double pile_area,
|
double /*pile_area*/,
|
||||||
const Item &item,
|
const Item &item,
|
||||||
double norm, // A norming factor for physical dimensions
|
double norm, // A norming factor for physical dimensions
|
||||||
std::vector<double>& areacache
|
std::vector<double>& areacache
|
||||||
@ -114,11 +114,14 @@ objfunc(const PointImpl& bincenter,
|
|||||||
NfpPlacer::Pile bigs;
|
NfpPlacer::Pile bigs;
|
||||||
bigs.reserve(pile.size());
|
bigs.reserve(pile.size());
|
||||||
|
|
||||||
int idx = 0;
|
|
||||||
if(pile.size() < areacache.size()) areacache.clear();
|
if(pile.size() < areacache.size()) areacache.clear();
|
||||||
|
|
||||||
|
auto normarea = [norm](double area) { return std::sqrt(area)/norm; };
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
for(auto& p : pile) {
|
for(auto& p : pile) {
|
||||||
if(idx == areacache.size()) areacache.emplace_back(sl::area(p));
|
if(idx == areacache.size()) areacache.emplace_back(sl::area(p));
|
||||||
if(std::sqrt(areacache[idx])/norm > BIG_ITEM_TRESHOLD)
|
if( normarea(areacache[idx]) > BIG_ITEM_TRESHOLD)
|
||||||
bigs.emplace_back(p);
|
bigs.emplace_back(p);
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
@ -137,12 +140,13 @@ objfunc(const PointImpl& bincenter,
|
|||||||
|
|
||||||
// The size indicator of the candidate item. This is not the area,
|
// The size indicator of the candidate item. This is not the area,
|
||||||
// but almost...
|
// but almost...
|
||||||
auto itemnormarea = std::sqrt(ibb.width()*ibb.height())/norm;
|
|
||||||
|
|
||||||
// Will hold the resulting score
|
// Will hold the resulting score
|
||||||
double score = 0;
|
double score = 0;
|
||||||
|
|
||||||
if(itemnormarea > BIG_ITEM_TRESHOLD) {
|
double item_normarea = normarea(item.area());
|
||||||
|
|
||||||
|
if(item_normarea > BIG_ITEM_TRESHOLD) {
|
||||||
// This branch is for the bigger items..
|
// This branch is for the bigger items..
|
||||||
// Here we will use the closest point of the item bounding box to
|
// Here we will use the closest point of the item bounding box to
|
||||||
// the already arranged pile. So not the bb center nor the a choosen
|
// the already arranged pile. So not the bb center nor the a choosen
|
||||||
@ -182,7 +186,7 @@ objfunc(const PointImpl& bincenter,
|
|||||||
for(auto& p : pile) {
|
for(auto& p : pile) {
|
||||||
|
|
||||||
auto parea = areacache[idx];
|
auto parea = areacache[idx];
|
||||||
if(std::sqrt(parea)/norm > BIG_ITEM_TRESHOLD) {
|
if(normarea(areacache[idx]) > BIG_ITEM_TRESHOLD) {
|
||||||
auto chull = sl::convexHull(sl::Shapes<PolygonImpl>{p, trsh});
|
auto chull = sl::convexHull(sl::Shapes<PolygonImpl>{p, trsh});
|
||||||
auto carea = sl::area(chull);
|
auto carea = sl::area(chull);
|
||||||
|
|
||||||
@ -197,7 +201,7 @@ objfunc(const PointImpl& bincenter,
|
|||||||
auto C = 0.33;
|
auto C = 0.33;
|
||||||
score = C * dist + C * density + C * alignment_score;
|
score = C * dist + C * density + C * alignment_score;
|
||||||
|
|
||||||
} else if(itemnormarea < BIG_ITEM_TRESHOLD && bigs.empty()) {
|
} else if( item_normarea < BIG_ITEM_TRESHOLD && bigs.empty()) {
|
||||||
// If there are no big items, only small, we should consider the
|
// If there are no big items, only small, we should consider the
|
||||||
// density here as well to not get silly results
|
// density here as well to not get silly results
|
||||||
auto bindist = pl::distance(ibb.center(), bincenter) / norm;
|
auto bindist = pl::distance(ibb.center(), bincenter) / norm;
|
||||||
@ -230,7 +234,7 @@ void fillConfig(PConf& pcfg) {
|
|||||||
|
|
||||||
// The accuracy of optimization.
|
// The accuracy of optimization.
|
||||||
// Goes from 0.0 to 1.0 and scales performance as well
|
// Goes from 0.0 to 1.0 and scales performance as well
|
||||||
pcfg.accuracy = 0.4f;
|
pcfg.accuracy = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TBin>
|
template<class TBin>
|
||||||
|
Loading…
Reference in New Issue
Block a user