0
3
0
... | ... |
@@ -179,13 +179,13 @@ |
179 | 179 |
|
180 | 180 |
// Create an .eps file showing the colors of a default Palette |
181 | 181 |
ListDigraph h; |
182 | 182 |
ListDigraph::NodeMap<int> hcolors(h); |
183 | 183 |
ListDigraph::NodeMap<Point> hcoords(h); |
184 | 184 |
|
185 |
int cols=int(sqrt(double(palette.size()))); |
|
185 |
int cols=int(std::sqrt(double(palette.size()))); |
|
186 | 186 |
for(int i=0;i<int(paletteW.size());i++) { |
187 | 187 |
Node n=h.addNode(); |
188 | 188 |
hcoords[n]=Point(1+i%cols,1+i/cols); |
189 | 189 |
hcolors[n]=i; |
190 | 190 |
} |
191 | 191 |
... | ... |
@@ -378,13 +378,14 @@ |
378 | 378 |
_in_arc(ns.in_arc), _arc_num(ns._arc_num), _next_arc(0) |
379 | 379 |
{ |
380 | 380 |
// The main parameters of the pivot rule |
381 | 381 |
const double BLOCK_SIZE_FACTOR = 2.0; |
382 | 382 |
const int MIN_BLOCK_SIZE = 10; |
383 | 383 |
|
384 |
_block_size = std::max( int(BLOCK_SIZE_FACTOR * |
|
384 |
_block_size = std::max( int(BLOCK_SIZE_FACTOR * |
|
385 |
std::sqrt(double(_arc_num))), |
|
385 | 386 |
MIN_BLOCK_SIZE ); |
386 | 387 |
} |
387 | 388 |
|
388 | 389 |
// Find next entering arc |
389 | 390 |
bool findEnteringArc() { |
390 | 391 |
Cost c, min = 0; |
... | ... |
@@ -454,13 +455,14 @@ |
454 | 455 |
// The main parameters of the pivot rule |
455 | 456 |
const double LIST_LENGTH_FACTOR = 1.0; |
456 | 457 |
const int MIN_LIST_LENGTH = 10; |
457 | 458 |
const double MINOR_LIMIT_FACTOR = 0.1; |
458 | 459 |
const int MIN_MINOR_LIMIT = 3; |
459 | 460 |
|
460 |
_list_length = std::max( int(LIST_LENGTH_FACTOR * |
|
461 |
_list_length = std::max( int(LIST_LENGTH_FACTOR * |
|
462 |
std::sqrt(double(_arc_num))), |
|
461 | 463 |
MIN_LIST_LENGTH ); |
462 | 464 |
_minor_limit = std::max( int(MINOR_LIMIT_FACTOR * _list_length), |
463 | 465 |
MIN_MINOR_LIMIT ); |
464 | 466 |
_curr_length = _minor_count = 0; |
465 | 467 |
_candidates.resize(_list_length); |
466 | 468 |
} |
... | ... |
@@ -574,13 +576,14 @@ |
574 | 576 |
// The main parameters of the pivot rule |
575 | 577 |
const double BLOCK_SIZE_FACTOR = 1.5; |
576 | 578 |
const int MIN_BLOCK_SIZE = 10; |
577 | 579 |
const double HEAD_LENGTH_FACTOR = 0.1; |
578 | 580 |
const int MIN_HEAD_LENGTH = 3; |
579 | 581 |
|
580 |
_block_size = std::max( int(BLOCK_SIZE_FACTOR * |
|
582 |
_block_size = std::max( int(BLOCK_SIZE_FACTOR * |
|
583 |
std::sqrt(double(_arc_num))), |
|
581 | 584 |
MIN_BLOCK_SIZE ); |
582 | 585 |
_head_length = std::max( int(HEAD_LENGTH_FACTOR * _block_size), |
583 | 586 |
MIN_HEAD_LENGTH ); |
584 | 587 |
_candidates.resize(_head_length + _block_size); |
585 | 588 |
_curr_length = 0; |
586 | 589 |
} |
... | ... |
@@ -1222,13 +1225,13 @@ |
1222 | 1225 |
_pi[_root] = -art_cost; |
1223 | 1226 |
} else { |
1224 | 1227 |
_pi[_root] = art_cost; |
1225 | 1228 |
} |
1226 | 1229 |
|
1227 | 1230 |
// Store the arcs in a mixed order |
1228 |
int k = std::max(int(sqrt(_arc_num)), 10); |
|
1231 |
int k = std::max(int(std::sqrt(double(_arc_num))), 10); |
|
1229 | 1232 |
int i = 0; |
1230 | 1233 |
for (ArcIt e(_graph); e != INVALID; ++e) { |
1231 | 1234 |
_arc_ref[i] = e; |
1232 | 1235 |
if ((i += k) >= _arc_num) i = (i % k) + 1; |
1233 | 1236 |
} |
1234 | 1237 |
... | ... |
@@ -62,13 +62,13 @@ |
62 | 62 |
ListGraph::NodeMap<Point> coords(g); |
63 | 63 |
|
64 | 64 |
|
65 | 65 |
double totalLen(){ |
66 | 66 |
double tlen=0; |
67 | 67 |
for(EdgeIt e(g);e!=INVALID;++e) |
68 |
tlen+=sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare()); |
|
68 |
tlen+=std::sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare()); |
|
69 | 69 |
return tlen; |
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
int tsp_impr_num=0; |
73 | 73 |
|
74 | 74 |
const double EPSILON=1e-8; |
... | ... |
@@ -185,13 +185,13 @@ |
185 | 185 |
(r.x * r.x + r.y * r.y) * (p.x - q.x); |
186 | 186 |
|
187 | 187 |
double f = (p.x * p.x + p.y * p.y) * (q.x * r.y - r.x * q.y) + |
188 | 188 |
(q.x * q.x + q.y * q.y) * (r.x * p.y - p.x * r.y) + |
189 | 189 |
(r.x * r.x + r.y * r.y) * (p.x * q.y - q.x * p.y); |
190 | 190 |
|
191 |
return d / (2 * a) + sqrt((d * d + e * e) / (4 * a * a) + f / a); |
|
191 |
return d / (2 * a) + std::sqrt((d * d + e * e) / (4 * a * a) + f / a); |
|
192 | 192 |
} |
193 | 193 |
|
194 | 194 |
inline bool circle_form(const Point& p, const Point& q, const Point& r) { |
195 | 195 |
return rot90(q - p) * (r - q) < 0.0; |
196 | 196 |
} |
197 | 197 |
|
... | ... |
@@ -203,13 +203,13 @@ |
203 | 203 |
if (sx < p.x + epsilon) return p.y; |
204 | 204 |
if (sx < q.x + epsilon) return q.y; |
205 | 205 |
|
206 | 206 |
double a = q.x - p.x; |
207 | 207 |
double b = (q.x - sx) * p.y - (p.x - sx) * q.y; |
208 | 208 |
double d = (q.x - sx) * (p.x - sx) * (p - q).normSquare(); |
209 |
return (b - sqrt(d)) / a; |
|
209 |
return (b - std::sqrt(d)) / a; |
|
210 | 210 |
} |
211 | 211 |
|
212 | 212 |
struct YLess { |
213 | 213 |
|
214 | 214 |
|
215 | 215 |
YLess(const std::vector<Point>& points, double& sweep) |
... | ... |
@@ -810,13 +810,13 @@ |
810 | 810 |
|
811 | 811 |
|
812 | 812 |
std::cout << "Number of nodes : " << countNodes(g) << std::endl; |
813 | 813 |
std::cout << "Number of arcs : " << countEdges(g) << std::endl; |
814 | 814 |
double tlen=0; |
815 | 815 |
for(EdgeIt e(g);e!=INVALID;++e) |
816 |
tlen+=sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare()); |
|
816 |
tlen+=std::sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare()); |
|
817 | 817 |
std::cout << "Total arc length : " << tlen << std::endl; |
818 | 818 |
|
819 | 819 |
if(ap["eps"]) |
820 | 820 |
graphToEps(g,prefix+".eps").scaleToA4(). |
821 | 821 |
scale(600).nodeScale(.005).arcWidthScale(.001).preScale(false). |
822 | 822 |
coords(coords).hideNodes(ap.given("nonodes")).run(); |
0 comments (0 inline)