Skip to content
Snippets Groups Projects
Commit 523b0bf7 authored by Francois Hamonic's avatar Francois Hamonic
Browse files

fonctionnel

parent 84b7d25a
No related branches found
No related tags found
No related merge requests found
No preview for this file type
5 8 3
0 0 0
1 1 2
2 2 0
0 1 0.0
1 2 0.0
2 0 0.0
0 3 3.0
1 3 1.0
1 4 1.0
2 4 2.0
3 4 1.0
\ No newline at end of file
12 25 5
0 0.0 1.0
1 0.951 0.309
2 0.587 -0.809
3 -0.587 -0.809
4 -0.951 0.309
0 1 0.0
1 2 0.0
2 3 0.0
3 4 0.0
4 0 0.0
0 5 1.0
0 6 1.0
0 7 1.0
1 7 1.0
1 8 1.0
2 9 1.0
3 10 1.0
3 11 1.0
4 5 1.0
4 11 1.0
5 6 1.0
5 11 1.0
6 7 1.0
6 8 1.0
6 9 1.0
6 11 1.0
7 8 1.0
8 9 1.0
9 10 1.0
10 11 1.0
debug.lp.lp 0 → 100644
This diff is collapsed.
%!PS-Adobe-2.0 EPSF-2.0
%%Creator: LEMON, graphToEps()
%%CreationDate: Wed Dec 4 17:27:29 2019
%%BoundingBox: -13 -13 213 213
%%CreationDate: Thu Dec 5 03:27:44 2019
%%BoundingBox: -108 -94 108 113
%%EndComments
/lb { setlinewidth setrgbcolor newpath moveto
4 2 roll 1 index 1 index curveto stroke } bind def
......@@ -68,17 +68,46 @@ gsave
100 dup scale
%Arcs:
gsave
2 2 2 0 0 0 0 0.00848528 l
0 0 2 0 0 0 0 0.00848528 l
0 0 2 2 0 0 0 0.00848528 l
0 0 0 0.0642791 0 0 0 0.00787469 l
0.312799 0 0 0 0 0 0 0.00787469 l
0.466503 0.297236 0.312799 0 0 0 0 0.00787469 l
0.404061 0.49723 0.466503 0.297236 0 0 0 0.00787469 l
0.196965 0.383206 0 0.0642791 0 0 0 0.00787469 l
0.196965 0.383206 0.312799 0 0 0 0 0.00787469 l
0.196965 0.383206 0.466503 0.297236 0 0 0 0.00787469 l
0.196965 0.383206 0.404061 0.49723 0 0 0 0.00787469 l
0 0.439313 0 0.0642791 0 0 0 0.00787469 l
0 0.439313 0.196965 0.383206 0 0 0 0.00787469 l
-0.951 0.309 0 0.0642791 0 0 0 0.00787469 l
-0.951 0.309 0 0.439313 0 0 0 0.00787469 l
-0.587 -0.809 0 0.0642791 0 0 0 0.00787469 l
-0.587 -0.809 0 0 0 0 0 0.00787469 l
-0.587 -0.809 -0.951 0.309 0 0 0 0.00787469 l
0.587 -0.809 0.312799 0 0 0 0 0.00787469 l
0.587 -0.809 -0.587 -0.809 0 0 0 0.00787469 l
0.951 0.309 0.466503 0.297236 0 0 0 0.00787469 l
0.951 0.309 0.404061 0.49723 0 0 0 0.00787469 l
0.951 0.309 0.587 -0.809 0 0 0 0.00787469 l
0 1 0.404061 0.49723 0 0 0 0.00787469 l
0 1 0.196965 0.383206 0 0 0 0.00787469 l
0 1 0 0.439313 0 0 0 0.00787469 l
0 1 -0.951 0.309 0 0 0 0.00787469 l
0 1 0.951 0.309 0 0 0 0.00787469 l
grestore
%Nodes:
gsave
0 0 0.0282843 1 1 1 nc
0 0 0.0282843 1 1 1 nc
2 0 0.0282843 1 1 1 nc
2 2 0.0282843 1 1 1 nc
0 0 0.0282843 1 1 1 nc
0 0.0642791 0.026249 1 1 1 nc
0 0 0.026249 1 1 1 nc
0.312799 0 0.026249 1 1 1 nc
0.466503 0.297236 0.026249 1 1 1 nc
0.404061 0.49723 0.026249 1 1 1 nc
0.196965 0.383206 0.026249 1 1 1 nc
0 0.439313 0.026249 1 1 1 nc
-0.951 0.309 0.026249 1 1 1 nc
-0.587 -0.809 0.026249 1 1 1 nc
0.587 -0.809 0.026249 1 1 1 nc
0.951 0.309 0.026249 1 1 1 nc
0 1 0.026249 1 1 1 nc
grestore
grestore
showpage
......@@ -32,8 +32,8 @@ class OsiClpSolver_Builder{
CoinPackedMatrix * matrix;
public:
static const int MIN = -1;
static const int MAX = 1;
static const int MIN = 1;
static const int MAX = -1;
OsiClpSolver_Builder();
......
No preview for this file type
......@@ -17,7 +17,10 @@ typedef lemon::ListGraph Graph_t;
typedef lemon::dim2::Point<double> Point_t;
Graph_t graph;
int n;
int m;
Graph_t::EdgeMap<double> strengthMap(graph);
std::map<Graph_t::Node, Point_t> nailed_nodes;
void create_nodes(int n) {
......@@ -28,22 +31,45 @@ void create_edge(int u, int v, double strength) {
Graph_t::Edge e = graph.addEdge(graph.nodeFromId(u), graph.nodeFromId(v));
strengthMap[e] = strength;
}
void parse(std::string & file_name) {
std::ifstream in(file_name);
int s;
in >> n >> m >> s;
create_nodes(n);
for(int i=0; i<s; i++) {
int v;
double x, y;
in >> v >> x >> y;
nailed_nodes[graph.nodeFromId(v)] = Point_t(x, y);
}
for(int i=0; i<m; i++) {
int u, v;
double strength;
in >> u >> v >> strength;
create_edge(u, v, strength);
}
}
int main (/*int argc, const char *argv[]*/)
{
const int n = 5;
int main (int argc, const char *argv[]) {
if(argc < 3) {
std::cerr << "input requiered : <graph data file> <g>" << std::endl;
return -1;
}
std::string file_name = argv[1];
const int g = std::atoi(argv[2]);
create_nodes(n);
create_edge(0, 1, 1.0);
create_edge(1, 2, 1.0);
create_edge(2, 0, 1.0);
parse(file_name);
double max_d2 = 0;
for( auto const& [_, p1] : nailed_nodes ) {
for( auto const& [_, p2] : nailed_nodes ) {
const double d2 = std::pow(p2.x*p1.x, 2) + std::pow(p2.y-p1.y, 2);
max_d2 = std::max(d2, max_d2);
}
}
const double diameter = std::sqrt(max_d2);
std::map<Graph_t::Node, Point_t> nailed_nodes;
nailed_nodes[graph.nodeFromId(0)] = Point_t(0,0);
nailed_nodes[graph.nodeFromId(1)] = Point_t(2,2);
nailed_nodes[graph.nodeFromId(2)] = Point_t(2,0);
const int m = lemon::countEdges(graph);
auto x_var = [&] (Graph_t::Node v) {
......@@ -70,15 +96,14 @@ int main (/*int argc, const char *argv[]*/)
const int y2_var_number = m;
const int g = 10;
auto o_const = [&] (Graph_t::Edge e, int i) {
return strengthMap[e] * pow(i/(double)(g-1), 2);
};
auto m_const = [&] (Graph_t::Edge e, int i) {
(void)e;
return i/(double)(g-1);
return diameter*i/(double)(g-1);
};
auto o_const = [&] (Graph_t::Edge e, int i) {
return strengthMap[e] * pow(m_const(e,i), 2);
};
......@@ -106,25 +131,29 @@ int main (/*int argc, const char *argv[]*/)
for(int i = 0; i < g; i++) {
const double scale = (o_const(e,i+1) - o_const(e,i)) / (m_const(e,i+1) - m_const(e,i));
const double offset = m_const(e,i) * scale - o_const(e,i);
solver_builder->buffEntry(x_var(u), 1);
solver_builder->buffEntry(x_var(v), -1);
solver_builder->buffEntry(x2_var(e), -scale);
solver_builder->pushRow(-offset, solver_builder->infty());
solver_builder->buffEntry(x_var(u), -1);
solver_builder->buffEntry(x_var(v), 1);
solver_builder->buffEntry(x2_var(e), -scale);
solver_builder->pushRow(-offset, solver_builder->infty());
solver_builder->buffEntry(y_var(u), 1);
solver_builder->buffEntry(y_var(v), -1);
solver_builder->buffEntry(y2_var(e), -scale);
solver_builder->pushRow(-offset, solver_builder->infty());
solver_builder->buffEntry(y_var(u), -1);
solver_builder->buffEntry(y_var(v), 1);
solver_builder->buffEntry(y2_var(e), -scale);
solver_builder->pushRow(-offset, solver_builder->infty());
const double offset = o_const(e,i) - scale * m_const(e,i);
// x2_e >= scale * (x_u - x_v) + offset
solver_builder->buffEntry(x2_var(e), 1);
solver_builder->buffEntry(x_var(u), -scale);
solver_builder->buffEntry(x_var(v), scale);
solver_builder->pushRow(offset, solver_builder->infty());
solver_builder->buffEntry(x2_var(e), 1);
solver_builder->buffEntry(x_var(u), scale);
solver_builder->buffEntry(x_var(v), -scale);
solver_builder->pushRow(offset, solver_builder->infty());
solver_builder->buffEntry(y2_var(e), 1);
solver_builder->buffEntry(y_var(u), -scale);
solver_builder->buffEntry(y_var(v), scale);
solver_builder->pushRow(offset, solver_builder->infty());
solver_builder->buffEntry(y2_var(e), 1);
solver_builder->buffEntry(y_var(u), scale);
solver_builder->buffEntry(y_var(v), -scale);
solver_builder->pushRow(offset, solver_builder->infty());
}
}
// nailed nodes
......@@ -137,7 +166,7 @@ int main (/*int argc, const char *argv[]*/)
OsiClpSolverInterface * solver = solver_builder->buildSolver(OsiClpSolver_Builder::MIN);
solver->writeLp("test");
solver->writeLp("debug.lp");
solver->resolve();
const double * solution = solver->getColSolution();
......@@ -148,10 +177,11 @@ int main (/*int argc, const char *argv[]*/)
const double x_u = solution[x_var(u)];
const double y_u = solution[y_var(u)];
coordsMap[u] = Point_t(x_u, y_u);
}
std::cout << graph.id(u) << " (" << x_u << ", " << y_u << ")" << std::endl;
}
lemon::graphToEps(graph, "graph").coords(coordsMap).run();
lemon::graphToEps(graph, "graph.eps").coords(coordsMap).run();
delete solver;
delete solver_builder;
......
\Problem name: ClpDefaultName
Minimize
obj: - x10 - x11 - x12 - x13 - x14 - x15
Subject To
cons0: - x0 + x2 -0.11111 x12 >= -0
cons1: x0 - x2 -0.11111 x12 >= -0
cons2: - x5 + x7 -0.11111 x15 >= -0
cons3: x5 - x7 -0.11111 x15 >= -0
cons4: - x0 + x2 -0.33333 x12 >= -0.02469
cons5: x0 - x2 -0.33333 x12 >= -0.02469
cons6: - x5 + x7 -0.33333 x15 >= -0.02469
cons7: x5 - x7 -0.33333 x15 >= -0.02469
cons8: - x0 + x2 -0.55556 x12 >= -0.07407
cons9: x0 - x2 -0.55556 x12 >= -0.07407
cons10: - x5 + x7 -0.55556 x15 >= -0.07407
cons11: x5 - x7 -0.55556 x15 >= -0.07407
cons12: - x0 + x2 -0.77778 x12 >= -0.14815
cons13: x0 - x2 -0.77778 x12 >= -0.14815
cons14: - x5 + x7 -0.77778 x15 >= -0.14815
cons15: x5 - x7 -0.77778 x15 >= -0.14815
cons16: - x0 + x2 - x12 >= -0.24691
cons17: x0 - x2 - x12 >= -0.24691
cons18: - x5 + x7 - x15 >= -0.24691
cons19: x5 - x7 - x15 >= -0.24691
cons20: - x0 + x2 -1.22222 x12 >= -0.37037
cons21: x0 - x2 -1.22222 x12 >= -0.37037
cons22: - x5 + x7 -1.22222 x15 >= -0.37037
cons23: x5 - x7 -1.22222 x15 >= -0.37037
cons24: - x0 + x2 -1.44444 x12 >= -0.51852
cons25: x0 - x2 -1.44444 x12 >= -0.51852
cons26: - x5 + x7 -1.44444 x15 >= -0.51852
cons27: x5 - x7 -1.44444 x15 >= -0.51852
cons28: - x0 + x2 -1.66667 x12 >= -0.69136
cons29: x0 - x2 -1.66667 x12 >= -0.69136
cons30: - x5 + x7 -1.66667 x15 >= -0.69136
cons31: x5 - x7 -1.66667 x15 >= -0.69136
cons32: - x0 + x2 -1.88889 x12 >= -0.88889
cons33: x0 - x2 -1.88889 x12 >= -0.88889
cons34: - x5 + x7 -1.88889 x15 >= -0.88889
cons35: x5 - x7 -1.88889 x15 >= -0.88889
cons36: - x0 + x2 -2.11111 x12 >= -1.11111
cons37: x0 - x2 -2.11111 x12 >= -1.11111
cons38: - x5 + x7 -2.11111 x15 >= -1.11111
cons39: x5 - x7 -2.11111 x15 >= -1.11111
cons40: x1 - x2 -0.11111 x11 >= -0
cons41: - x1 + x2 -0.11111 x11 >= -0
cons42: x6 - x7 -0.11111 x14 >= -0
cons43: - x6 + x7 -0.11111 x14 >= -0
cons44: x1 - x2 -0.33333 x11 >= -0.02469
cons45: - x1 + x2 -0.33333 x11 >= -0.02469
cons46: x6 - x7 -0.33333 x14 >= -0.02469
cons47: - x6 + x7 -0.33333 x14 >= -0.02469
cons48: x1 - x2 -0.55556 x11 >= -0.07407
cons49: - x1 + x2 -0.55556 x11 >= -0.07407
cons50: x6 - x7 -0.55556 x14 >= -0.07407
cons51: - x6 + x7 -0.55556 x14 >= -0.07407
cons52: x1 - x2 -0.77778 x11 >= -0.14815
cons53: - x1 + x2 -0.77778 x11 >= -0.14815
cons54: x6 - x7 -0.77778 x14 >= -0.14815
cons55: - x6 + x7 -0.77778 x14 >= -0.14815
cons56: x1 - x2 - x11 >= -0.24691
cons57: - x1 + x2 - x11 >= -0.24691
cons58: x6 - x7 - x14 >= -0.24691
cons59: - x6 + x7 - x14 >= -0.24691
cons60: x1 - x2 -1.22222 x11 >= -0.37037
cons61: - x1 + x2 -1.22222 x11 >= -0.37037
cons62: x6 - x7 -1.22222 x14 >= -0.37037
cons63: - x6 + x7 -1.22222 x14 >= -0.37037
cons64: x1 - x2 -1.44444 x11 >= -0.51852
cons65: - x1 + x2 -1.44444 x11 >= -0.51852
cons66: x6 - x7 -1.44444 x14 >= -0.51852
cons67: - x6 + x7 -1.44444 x14 >= -0.51852
cons68: x1 - x2 -1.66667 x11 >= -0.69136
cons69: - x1 + x2 -1.66667 x11 >= -0.69136
cons70: x6 - x7 -1.66667 x14 >= -0.69136
cons71: - x6 + x7 -1.66667 x14 >= -0.69136
cons72: x1 - x2 -1.88889 x11 >= -0.88889
cons73: - x1 + x2 -1.88889 x11 >= -0.88889
cons74: x6 - x7 -1.88889 x14 >= -0.88889
cons75: - x6 + x7 -1.88889 x14 >= -0.88889
cons76: x1 - x2 -2.11111 x11 >= -1.11111
cons77: - x1 + x2 -2.11111 x11 >= -1.11111
cons78: x6 - x7 -2.11111 x14 >= -1.11111
cons79: - x6 + x7 -2.11111 x14 >= -1.11111
cons80: x0 - x1 -0.11111 x10 >= -0
cons81: - x0 + x1 -0.11111 x10 >= -0
cons82: x5 - x6 -0.11111 x13 >= -0
cons83: - x5 + x6 -0.11111 x13 >= -0
cons84: x0 - x1 -0.33333 x10 >= -0.02469
cons85: - x0 + x1 -0.33333 x10 >= -0.02469
cons86: x5 - x6 -0.33333 x13 >= -0.02469
cons87: - x5 + x6 -0.33333 x13 >= -0.02469
cons88: x0 - x1 -0.55556 x10 >= -0.07407
cons89: - x0 + x1 -0.55556 x10 >= -0.07407
cons90: x5 - x6 -0.55556 x13 >= -0.07407
cons91: - x5 + x6 -0.55556 x13 >= -0.07407
cons92: x0 - x1 -0.77778 x10 >= -0.14815
cons93: - x0 + x1 -0.77778 x10 >= -0.14815
cons94: x5 - x6 -0.77778 x13 >= -0.14815
cons95: - x5 + x6 -0.77778 x13 >= -0.14815
cons96: x0 - x1 - x10 >= -0.24691
cons97: - x0 + x1 - x10 >= -0.24691
cons98: x5 - x6 - x13 >= -0.24691
cons99: - x5 + x6 - x13 >= -0.24691
cons100: x0 - x1 -1.22222 x10 >= -0.37037
cons101: - x0 + x1 -1.22222 x10 >= -0.37037
cons102: x5 - x6 -1.22222 x13 >= -0.37037
cons103: - x5 + x6 -1.22222 x13 >= -0.37037
cons104: x0 - x1 -1.44444 x10 >= -0.51852
cons105: - x0 + x1 -1.44444 x10 >= -0.51852
cons106: x5 - x6 -1.44444 x13 >= -0.51852
cons107: - x5 + x6 -1.44444 x13 >= -0.51852
cons108: x0 - x1 -1.66667 x10 >= -0.69136
cons109: - x0 + x1 -1.66667 x10 >= -0.69136
cons110: x5 - x6 -1.66667 x13 >= -0.69136
cons111: - x5 + x6 -1.66667 x13 >= -0.69136
cons112: x0 - x1 -1.88889 x10 >= -0.88889
cons113: - x0 + x1 -1.88889 x10 >= -0.88889
cons114: x5 - x6 -1.88889 x13 >= -0.88889
cons115: - x5 + x6 -1.88889 x13 >= -0.88889
cons116: x0 - x1 -2.11111 x10 >= -1.11111
cons117: - x0 + x1 -2.11111 x10 >= -1.11111
cons118: x5 - x6 -2.11111 x13 >= -1.11111
cons119: - x5 + x6 -2.11111 x13 >= -1.11111
Bounds
0 <= x0 <= 0
2 <= x1 <= 2
2 <= x2 <= 2
0 <= x5 <= 0
2 <= x6 <= 2
0 <= x7 <= 0
End
tmp.py 0 → 100644
import math
center_x = 0
center_y = 0
radius = 1
nb_vertices = 5
angle = 2 * math.pi / nb_vertices
for i in range(nb_vertices):
x = center_x + radius * math.sin(i * angle)
y = center_y + radius * math.cos(i * angle)
print(x, y)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment