Generate set of feasible points for a function?
Show older comments
Suppose you have a function (equality or inequality). How can you generate the set of feasible points from it?
For example: if you have 5x1 + 5x2 + 3x3 <= 8, the set of feasible points is {(0,0,0), (1,0,0), (0,1,0), etc.}. How can you use MATLAB to generate this set of points?
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 31 May 2013
Edited: Azzi Abdelmalek
on 31 May 2013
a=arrangement([1 0],3);
co1=[5 5 3];
co2=8
b=sum(bsxfun(@times,a,co1),2)-co2;
out=a(b<=0,:)
% Before runing the above code, save the function arrangement.m:
function y=arrangement(v,n)
m=length(v);
y=zeros(m^n,n);
for k = 1:n
y(:,k) = repmat(reshape(repmat(v,m^(n-k),1),m*m^(n-k),1),m^(k-1),1);
end
Categories
Find more on Surrogate Optimization 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!