How to use quadprog with a group of points

1 view (last 30 days)
Marc Arbones
Marc Arbones on 6 Oct 2015
Edited: Torsten on 12 Oct 2015
Hi, I am trying to use the function quadprog from a group of points to obtain the middle point and make the smallest circle that encloses all the points. I don't know how to obtain the H, I suposse is the Hessian, Aeq and Beq. Someone could help me with this problem?
[X,FVAL,EXITFLAG] = quadprog(H,f,A,b,Aeq,beq)
The points are P =[3 0;0 -3;-2 1;1 4]
The matrix A is
1 0 -1 0 0 0 0 0 0 0;
1 0 0 0 -1 0 0 0 0 0;
1 0 0 0 0 0 -1 0 0 0;
1 0 0 0 0 0 0 0 -1 0;
-1 0 -1 0 0 0 0 0 0 0;
-1 0 0 0 -1 0 0 0 0 0;
-1 0 0 0 0 0 -1 0 0 0;
-1 0 0 0 0 0 0 0 -1 0;
0 1 0 -1 0 0 0 0 0 0;
0 1 0 0 0 -1 0 0 0 0;
0 1 0 0 0 0 0 -1 0 0;
0 1 0 0 0 0 0 0 0 -1;
0 -1 0 -1 0 0 0 0 0 0;
0 -1 0 0 0 -1 0 0 0 0;
0 -1 0 0 0 0 0 -1 0 0;
0 -1 0 0 0 0 0 0 0 -1;
The f is
0 0 1 1 1 1 1 1 1 1;
The b is
3 -3 0 0;
0 0 -3 3;
-2 2 1 -1;
1 -1 4 -4;
Thank you for your help, and sorry for the long post.

Answers (2)

Alan Weiss
Alan Weiss on 7 Oct 2015
I am not sure what you are really trying to do. You seem to already have f, A, and b. Do you need to figure out an appropriate H?
I suggest that you start with a verbal description of your problem and then try to write equations that represent the problem. What are your control variables (the things that you can change to try to reach a minimum)? What is your objective function? What kinds of constraints are there in the problem? Once you have figured out all that, you can see what kind of solver is appropriate.
Alan Weiss
MATLAB mathematical toolbox documentation
  3 Comments
Alan Weiss
Alan Weiss on 9 Oct 2015
It sounds like you have three control variables: the x- and y- locations of the circle center, and the radius of the circle. Let's call these variables x(1), x(2), and x(3) respectively.
Your objective is to minimize x(3) or x(3)^2, subject to the constraints that the points in P are in your circle.
You need to devise a formula to represent the constraints that each point in P is inside your circle. Something like
(x(1) - P(1))^2 + (x(2) - P(2))^2 <= x(3)^2
for each point (P(1),P(2)).
Did I understand your problem correctly? If so, then perhaps you can take it from here and find an appropriate solver and the inputs to that solver.
Alan Weiss
MATLAB mathematical toolbox documentation
John D'Errico
John D'Errico on 9 Oct 2015
Except this constraint is a quadratic constraint in the unknowns. quadprog does not handle constraints of that form.

Sign in to comment.


Torsten
Torsten on 9 Oct 2015
Edited: Torsten on 12 Oct 2015
Since you try to minimize the maximum distance between the center (xc,yc) of the circle and the points (x(i),y(i)) given, try fminimax with the F_i given by
F_i(xc,yc) = sqrt((x(i)-xc)^2 + (y(i)-yc)^2)
Best wishes
Torsten.

Categories

Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!