7 #include <gecode/gist.hh> 10 bool writeMiniZincData(
12 const int n,
const int m,
13 const std::vector<int>&
A,
const std::vector<int>& G,
const std::vector<int>& T)
15 FILE *fp = fopen(path,
"wb+");
17 assert(n*n == A.size());
18 assert(n == G.size());
19 assert(n*n*m == T.size());
23 ROS_ERROR(
"[Gecode-ts planning] fails to output minizinc data.");
27 fprintf(fp,
"n = %d;\n\n", n);
28 fprintf(fp,
"m = %d;\n\n", m);
30 fprintf(fp,
"G_data = [");
31 for(
int i = 0; i < G.size(); i++)
33 fprintf(fp,
"%d,", G[i]);
36 fprintf(fp,
"];\n\n");
40 fprintf(fp,
"A_data = [");
41 for(
int i = 0; i < A.size(); i++)
43 fprintf(fp,
"%d,", A[i]);
46 fprintf(fp,
"];\n\n");
50 fprintf(fp,
"T_data = [");
51 for(
int i = 0; i < T.size(); i++)
53 fprintf(fp,
"%d,", T[i]);
56 fprintf(fp,
"];\n\n");
91 for (
int i = 0; i <
Nd_; i++)
97 for (
int l = 0; l < layer_size; l++)
99 fprintf(stderr,
"Size of layer %d is %d\n", l, (
int)
layers_[l].
size());
103 bool bSuccess =
true;
104 for (
int l = 0; l < layer_size; l++)
119 for (
int i = 0; i < Nl; i++)
131 std::vector<int> A, G, T;
136 std::string str_path =
"/home/yijiangh/Documents/";
137 str_path = str_path +
"as_minizinc_data_layer_" + std::to_string(l) +
".dzn";
139 bSuccess = writeMiniZincData(str_path.c_str(), n, m, A, G, T);
158 std::vector<int>& A, std::vector<int>& G, std::vector<int>& T,
161 int n = layer_e.size();
164 A = std::vector<int>(n*n, 0);
165 G = std::vector<int>(n, 0);
166 T = std::vector<int>(n*n*m, 0);
168 for(
int i=0; i < n; i++)
182 if(exist_uj || exist_vj || e->
isPillar())
188 std::vector<int> connect_vert_id(2);
192 for(
const auto id : connect_vert_id)
204 for(
int j=0; j < n; j++)
206 if(eu->
ID() == layer_e[j]->ID() || eu->
ID() == layer_e[j]->ppair_->ID())
211 if(m_type == CSPDataMatrixStorageType::ROW_MAJOR)
214 index_2d = j + n * i;
218 index_2d = i + n * j;
231 for (
int j = 0; j < n; j++)
236 if (dual_i != dual_j)
238 std::vector<lld> tmp(3);
241 for (
int o = 0; o < 3; o++)
249 for(
int k=0; k<m; k++)
254 if(m_type == CSPDataMatrixStorageType::ROW_MAJOR)
257 index_3d = k + m * (j + n * i);
261 index_3d = i + n * (j + n * k);
264 T[index_3d] = tmp_vector[k];
274 printf(
"***GecodeAnalyzer timer result:\n");
std::vector< int > ConvertCollisionMapToIntMap(const std::vector< lld > &colli_map)
WF_edge * GetNeighborEdge(int u)
GLsizei const GLchar *const * path
std::vector< std::vector< WF_edge * > > layers_
bool isExistingVert(int u)
vector< vector< unsigned long long > > angle_state_
bool DetectCollision(WF_edge *target_e, DualGraph *ptr_subgraph, std::vector< lld > &result_map)
void ComputeGecodeInput(const std::vector< WF_edge * > &layer_e, std::vector< int > &A, std::vector< int > &G, std::vector< int > &T, CSPDataMatrixStorageType m_type)
DualGraph * ptr_wholegraph_
DualGraph * ptr_dualgraph_
QuadricCollision * ptr_collision_