MATLAB Answers

How to constrain distance between points in optimization?

3 views (last 30 days)
Víctor del Álamo
Víctor del Álamo on 29 Mar 2020
Edited: Matt J on 31 Mar 2020
For example in the matlab problem of placing 10 electrons:
In a similar problem I want to constrain the minimum distance between electrons to 0.1. Would you know how to do that with elecprob.Constraints.spherec?
Thank you very much for your time

  2 Comments

Alan Weiss
Alan Weiss on 29 Mar 2020
I'm sorry, but I do not understand your constraint. Are you constraining the minimum distance between any pair of electrons to be greater than 0.1? Or the maximum distance to be 0.1? Or that all electrons are exactly 0.1 distance away from each other? Or that some particular pairs of electrons are exactly 0.1 distance from each other?
Alan Weiss
MATLAB mathematical toolbox documentation
Víctor del Álamo
Víctor del Álamo on 29 Mar 2020
Hi Alan
Thanks for answering my question. I would like to put a constrain so that the minimum distance between any pair of electrons must be greater than 0.1.
It is for another similar problem, but I would like to know how this constraint can be performed.
Thank you very much!!

Sign in to comment.

Accepted Answer

Matt J
Matt J on 29 Mar 2020
Edited: Matt J on 30 Mar 2020
It can be set up this way, but keep in mind that this is a highly non-convex feasible set. It may be challenging to find a global optimum.
IJ=nchoosek(1:N,2); I=IJ(:,1); J=IJ(:,2);
elecprob.Constraints.MinDist=(x(I)-x(J)).^2+(y(I)-y(J)).^2 +(z(I)-z(J)).^2 >=0.1^2;

  2 Comments

Víctor del Álamo
Víctor del Álamo on 31 Mar 2020
Hi Matt
Thanks for answering my question,
I think it could work. If I wanted just to constrain the distance on the X-axis, I mean something like:
elecprob.Constraints.MinDist=(x(I)-x(J)).^2 >=0.1^2;
But with equal y and z axis, that is:
elecprob.Constraints.MinDist=(y(I)-y(J)).^2 ==0;
elecprob.Constraints.MinDist=(z(I)-z(J)).^2 ==0;
Would there be any way to incorporate it into the first constraint?
Matt J
Matt J on 31 Mar 2020
If you know that all y and z coordinates are the same I believe they cease to be unknowns. You can just solve the problem under the assumption that all y and z coordinates are zero.

Sign in to comment.

More Answers (0)

Sign in to answer this question.