Solving SDP problems with pyomo and Mosek - pyomo

The output of my solver gives the following error>>
Error: rescode.err_qcon_upper_triangle(1417): Only elements in the lower triangle of the quadratic terms should be specified. The element q[1,12] is in the upper triangle of 0th constraint is specified.
Any idea on how I can go about troubleshooting this?

Related

error/sensitivity analysis for camera pose estimation

I am testing OpenCV pose estimation with solvePnPRansac. The method uses a parameter reprojectionError which distinguishes inliers/outliers for RANSAC. Assuming that a pose estimation returning T=T(R,t), is it possible to find the maximal estimation error $$\DeltaT_max$$ given a value of reprojectionError?
I've done some tests by formulating this question as a constraint optimization problem and see that this estimation is rather sensitive. In the sense that, with a small reprojectionEror tolerance e.g. .1, .01..., maximal error in translation can reach hundreds of millimeters, and almost all possible angle rotation. From this view point, is it reliable to use such an estimation where some small errors can be easily found e.g. round-up of pixel location of the reference point?
Edit 1:
I've found some massive tests from "Absolute Pose Estimation from Line Correspondences using Direct Linear Transformation"
It looks like to have a good estimation, better to enforce the reprojection error to be rather small e.g. <1e-6 or <1e-7 and number of matches should be near to 10 in order to have a sound estimation in position and orientation (say angle < 1 Deg and position < 1 meter which is still huge). So, regards to the reprojectionError earlier I mentioned i.e. .1, .01 is very far from accurate. With this being relate to solvePnPRansac, the default value for this reprojectionEror is ... 8 pixel! isn't this almost irrelevant? if a point is inlier, the required reprojection error should be very very small
Also, if the graph and my understanding it is right, it also can be interpreted like...to have position error <.01 meter, number of matching lines/points should reach >2000 and rotation error <.1 Deg, this number is up to > 100 to 500. These numbers of matching are very huge for cases

CGAL: Refining triangulation with collinear faces

I have a 2D triangulation created with Constrained_triangulation_plus_2. I am adding many constraints coming from vector data for a geographic region. The problem is later when I create a Surface_mesh out of this triangulation, I come up with collinear faces (checking the triangulation faces didn't show collinear faces).
I tried to fix this problem by refining the triangulation using a Delaunay_mesher_2:
mesher.set_criteria(Criteria(0.125,edge_max_length));
mesher.refine_mesh();
This will give me the following runtime exception:
CGAL error: assertion violation!
Expression : n == zone.fh
File : ../CGAL-4.8/include/CGAL/Mesh_2/Refine_edges.h
Line : 447
Explanation:
Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html
libc++abi.dylib: terminating with uncaught exception of type CGAL::Assertion_exception: CGAL ERROR: assertion violation!
Expr: n == zone.fh
File: ../CGAL-4.8/include/CGAL/Mesh_2/Refine_edges.h
Line: 447
I couldn't really understand what is happening in Refine_edges.h, though I guess that's something to do with collinear faces. I even tried mesher.step_by_step_refine_mesh() function for some number of iterations, but that didn't fix those very small triangles.
Then I tried to remove small triangles from the triangulation, but some of them at least had a constrained edge, so that was not possible too, and I couldn't find a way to modify if an edge is constrained, or even if I do, that would break the closed region of a constraint on my triangulation.
I also tried to simplify triangulation before refining, using a call like PS::simplify(cdtp, Cost(), Stop(1e-5)), but that didn't seem to fix the error.
So, my question is how can I modify the triangulation so the refine_mesh() won't run into a problem? I'm currently using the Exact_predicates_inexact_constructions_kernel. I tried using an exact kernel too, in that case I didn't get that runtime error, but the refine function took forever.

Given a start and goal ,how to find the shortest way in a navigation mesh?

I googled "A* algorithm on navigation mesh" only to get wrong ways to estimate g-values,like this
or this
By summing up the length of the blue line segments ,we get the g-value ,but it's overestimated (g-value should be underestimated). This algorithm will return a optimized path ,but not guaranteed to be the shortest.
The only way I can think of is to draw a visibility graph based on the navigation mesh .But that would cost too much memory .
Are there any other ways to calculate the shortest way in a navigation mesh ?
To get a shortest path closer from what you mean, you should stop using fix points as A-star nodes i.e. stop using center of triangles or center of triangles'edge.
Try to move the points as the A-star propagates.
For instance, use A-star nodes on triangles'edge which are :
either the intersection of the triangle's edge of next A-star node with the segment formed by previous A-star node and the destination
or the closest point from the intersection mentioned above on the triangle's edge of next A-star node
Or, try to change the path nodes after computing your A-star as currently done, using similar criteria.
Note that this will smooth the final path (as the red line on your drawings).
But this will only help reducing the overestimation, this doesn't guarantee finding the shortest paths as you meant it.
Better, try to change the path nodes after computing your A-star using center of triangles'edges, using string pulling a.k.a funnel algorithm. This will give you the shortest path through the triangles traversed by the output path of the A-star.
A*-search algorithm is a performance modification of Dijkstra algorithm and gives you only an approximation of the shortest path by considering only edge-paths (in primary or in dual graph):
After that the path has to be optimized and converted into geodesic path by allowing it to cross arbitrary any mesh triangle:
See, for example, answers to this question for details.
The pictures above were made in MeshInspector application.

Maze least turns

I have a problem that i can't solve.I have a maze and I have to find a path from a point S to a point E,which has the least turns.It is known that the point E is reacheable.I can move only in 4 directions,left,right,up and down.It doesn't have to be the shortest path,just to have least turns.
I tried to store the number of turns in a priority queue.For example when I reach a certain place in the maze I will add the numbers of turns till there.From there I would add his neighbours to the priority queue,if they weren't visited already or they weren't walls,with the value of the current block i was sitting,for example t + x which can have the following values ( 0-if the neighbour is facing in the same direction I was facing when i got near him,or 1 if it is in a different direction).It seems that this approach doesn't work for every case.
I will appreciate if somebody could offer me some hints, without any code.
You are on the right track. What you need to implement for this problem is Dijkstra's algorithm. You just need to consider not just points as graph vertices, but pair of (point,direction). From every vertex (p,d) you have 5 edges (although last one can be blocked by wall): (p,0), (p,1), (p,2), (p,3), (neighbour of p in direction d, d). First four edges are of weight 1 (as you turn here), and the last one is of weight 0 (no turn, just move forward). Algorithm is good enough to ignore loops and works fine for edges of weight 0. You should end when any vertex (end point, _) is extracted from priority queue.
This method has one issue, as too many verticies are inspected in the process. If your maze is small, that's not the problem. Otherwise, consider a slight modification known as A*. You need a good heuristic function, describing lower bound on number of turns to the goal.

opencv calculate matrix rank

I am trying to find rank of a matrix. In matlab this is fairly straight-forward but I am using visual studio 2008 (c++). I recently installed openCV and it works for most of my matrix arithmetic so far except I can't figure out how to use openCV to get rank of a matrix. In my research online I found that apparently cvSVD can give me rank
http://www.emgu.com/wiki/files/1.3.0.0/html/55d6f4d2-223d-8c55-2770-2b6a9c6eefa2.htm
But I have no idea how cvSVD will return this particular property. Any ideas on getting matrix rank from openCV???
Thanks.
Read the following
http://en.wikipedia.org/wiki/Singular_value_decomposition#Applications_of_the_SVD
in the section Range, null space and rank it explains how to get the Rank from the singular values. Quoting this page:
As a consequence, the rank of M equals the number of non-zero singular
value
So basically you can count the number of non-zero singular values and that is the rank. According to the link you provide in the question, your SVD calculation function in opencv should return you a matrix or vector of singular values - if it is a matrix, the singular values lie on the main diagonal of this matrix. From here you should be ok. There may be a simpler way, but I am not familiar with opencv.