필터 지우기
필터 지우기

I am looking for code, that is inverse of optimization. Have variable combinations (and plot them) that gives response value in a boundary.

조회 수: 7 (최근 30일)
For example
Y=3a+2b+5c-6a^2+7b^2
...is model. I want to have a, b, c combinations values that result in Y within -2 & +2. In addition, the subset of a, b, c must be in a given boundary i.e. -3<a<2, 4<b<7, 9<c<18 etc.
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 7월 25일
Is the question to determine all such values? There would be an indefinite number of such values if you permit floating point.
Biswanath Mahanty
Biswanath Mahanty 2018년 7월 26일
I understand, there is an infinite number of plausible solution. However, I need to draw a surface plot, with adequate combinations.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 7월 26일
Y = 200; %for example
N = 50;
av = linspace(-3,2,N);
bv = linspace(4,7,N);
cv = linspace(9,18,N);
[a,b,c] = ndgrid(av,bv,cv);
dy = 3*a + 2*b + 5*c - 6*a.^2 + 7*b.^2 - Y;
mask = dy > -2 & dy < 2;
scatter3(a(mask), b(mask), c(mask))
  댓글 수: 2
Biswanath Mahanty
Biswanath Mahanty 2018년 7월 29일
Thank you Walter Roberson. Your directives are great to start. However, when we are imposing mask onto a,b,c grids its a vector, not matrix. The results are fine with 3D scatter plot. But generating surface is not possible unless the a(mask), b(mask), c(mask) are reshaped into matrix.
Walter Roberson
Walter Roberson 2018년 7월 29일
You should not generate a surface plot for this: because you want Y within -2 & +2, you are defining a thickness with potentially multiple points instead of a surface.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Alan Weiss
Alan Weiss 2018년 7월 25일
You might be able to formulate this as an optimization problem. Your decision variables are a, b, c. The objective (the thing to minimize) is the sum of the squares (or absolute values) of the infeasibilities: max(Y,2) - 2 and abs(min(-2,Y) + 2).
To use Optimization Toolbox, formulate your problem in terms of one variable x = [a,b,c]. Then use the fmincon solver or the lsqnonlin solver. You can include bounds on the variables using the lb and ub arguments.
Alan Weiss
MATLAB mathematical toolbox documentation

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by