Find random solutions of a system of inequalities
Show older comments
Hi everyone,
I am trying to find solutions of a system of inequalities, represented in matrix format by AX>0, where A is a known nxn matrix and X is an nx1 vector of unknown.
In a simple example where n=3, I would have:
a_{11}x_{1}+a_{12}x_{2}+a_{13}x_{3}>0
a_{21}x_{1}+a_{22}x_{2}+a_{23}x_{3}>0
a_{31}x_{1}+a_{32}x_{2}+a_{33}x_{3}>0
Now, I do not want to find all solutions as there are probably an infinity. I would like to randomly pick a solution that works from the set of all possible solutions, without having to find them all. I wondered whether this could be feasible.
I have read about how to convert this linear program in standard form and the use the simplex algorithm. But as far as I understand, this would only give me a particular solution (especially if I use Matlab function "linprog" for that). Using the function solve did not seem to be satisfying either (although I may be wrong). Instead I would like at best to be able to write:
x(1)=random(truncate(makedist('Normal','mu',0,'sigma',1),ub,db),1,1)
where I can find ub and db from the system of equations, potentially also randomly from the set of possible ub and db.
Is there any way to do that mathematically and on Matlab?
Many thanks in advance for your help!
1 Comment
Etienne Vaccaro-Grange
on 31 Mar 2021
Accepted Answer
More Answers (1)
Bruno Luong
on 5 Apr 2021
Edited: Bruno Luong
on 5 Apr 2021
For small dimensions, you might use existing tools in FEX to enumerate the vertexes of the polytopes.
If the domain is non bounded, you must bounded so it can give the vertexes that define the bounded domain.
clear
A = -magic(3);
% bounding box limits
lo = -1000;
up = 1000;
p = 1e5; % number of points
[m,n] = size(A);
AA = [-A; eye(n); -eye(n)];
b = [0;0;0];
BB = [b(:); up+zeros(n,1); -lo+zeros(n,1)];
% https://www.mathworks.com/matlabcentral/fileexchange/30892-analyze-n-dimensional-convex-polyhedra?s_tid=srchtitle
V=lcon2vert(AA,BB);
K = convhull(V);
% linear convex of the vertexes
W=-log(rand(p,size(V,1)));
W=W./sum(W,2);
X = W*V;
close all
plot3(X(:,1),X(:,2),X(:,3),'.');
hold on
for i=1:size(K,1)
xyz = V(K(i,:),:);
xyz = xyz([1 2 3; 2 3 1],:);
plot3(xyz(:,1),xyz(:,2),xyz(:,3),'-r');
end

Categories
Find more on Mathematics 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!