Find random solutions of a system of inequalities

8 次查看(过去 30 天)
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 个评论
Etienne Vaccaro-Grange
Using the function solve, I manage to get conditions on parameter (u,v,w) for example. The issue is to draw randomly from the set of admissible parameters u,v,w to obtain (random) point solutions of x_{1},x_{2},x_{3}. Any idea?

请先登录,再进行评论。

采纳的回答

Aditya Patil
Aditya Patil 2021-4-5
As the solutions are infinite, you can get solutions as a system of equations themselves. Then, you can either randomly put parameter values and verify the result, or you solve the system of equations by setting some of the parameters and solving for the other ones.
See the following code for example of randomly setting values.
syms x1 x2 x3;
A = [1 2 3; 4 5 6; 7 8 9];
eq1 = A(1, 1) * x1 + A(1, 2) * x2 + A(1, 3) * x3 > 0;
eq2 = A(1, 1) * x1 + A(1, 2) * x2 + A(1, 3) * x3 > 0;
eq3 = A(1, 1) * x1 + A(1, 2) * x2 + A(1, 3) * x3 > 0;
solutions = solve([eq1, eq2, eq3], [x1 x2 x3], 'ReturnConditions',true);
solutions.parameters
% select random parameters
inputs = randn(length(solutions.parameters), 1)';
% check if these inputs are valid
condWithValues = subs(solutions.conditions, solutions.parameters, inputs);
if isAlways(condWithValues)
subs(solutions.x1, solutions.parameters, inputs)
subs(solutions.x2, solutions.parameters, inputs)
subs(solutions.x3, solutions.parameters, inputs)
end
See the solve inequalities documentation section for more details.
  2 个评论
Etienne Vaccaro-Grange
Many thanks for your reply Aditya. The problem is that in your code random parameters drawn in inputs do not nessecerily satisfy the conditions. How could I make sure they do. Can I turn solutions.conditions into a function or use assume(solution.conditions) for that?

请先登录,再进行评论。

更多回答(1 个)

Bruno Luong
Bruno Luong 2021-4-5
编辑:Bruno Luong 2021-4-5
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

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by