Optimization with constraints matlab

In summary, the conversation discusses a problem with parts (a) - (o) and the individual's progress on part (k). They mention working on problem 5 in a PDF and using different values for debugging and the actual assignment. They also share their code for parts (a) - (j) and mention being stuck on finding the single index of valid designs for part (j). They then clarify that they redid their code for part (j) and received confirmation from the autograder. They express frustration with part (k) being the same as part (j).
  • #1
gfd43tg
Gold Member
950
50

Homework Statement


Just a heads up, this is a problem with parts (a) - (o). I am working on (k). I am working on problem 5 in the attached PDF. I will show my code for the other parts. We were told to use N = 5 while writing the code for debugging and testing, but run N = 500 for the real assignment. Either way, it doesn't make a difference right now because I don't know the synthax for finding indices in arrays for a single index.


Homework Equations





The Attempt at a Solution


(a)
Code:
bMin = 0.001;
bMax = 0.2;
hMin = 0.001;
hMax = 0.2;
Pv = 1000;
Ph = 100;
(b)
Code:
N = 500;
(c)
Code:
bValues = linspace(bMin,bMax,N);
hValues = linspace(hMin,hMax,N);
(d)
Code:
B = repmat(bValues,N,1)';
H = repmat(hValues,N,1);
(e)
Code:
S1 = (6*Pv)./(B.*H.^2);
(f)
Code:
S2 = (6*Ph)./(B.^2.*H);
(g)
Code:
D1 = (4*Pv)./(2e11.*B.*H.^3);
(h)
Code:
D2 = (4*Ph)./(2e11.*B.^3.*H);
(i)
Code:
A = B.*H;
(j)
Code:
constraints = find((S1 < 1e8) & (S2 < 1e8) & (D1 < 0.001) & (D2 < .001));
nValidDesigns = numel(constraints);
(k)
This is where I am now stuck. I'm not sure what command I can use to find the single index of the valid designs from part (j).
Code:
[indexValidDesigns, I] = find((S1 < 1e8) & (S2 < 1e8) & (D1 < 0.001) & (D2 < .001));
 

Attachments

  • REL 5.pdf
    51.7 KB · Views: 278
Physics news on Phys.org
  • #2
I just redid what I put in part (j)

Code:
indexValidDesigns = find((S1 < 1e8) & (S2 < 1e8) & (D1 < 0.001) & (D2 < .001));

And the autograder gave said its right. Kind of dumb that part (k) is just the same thing as part(j), no??

I will put any more questions pertaining to this problem in this thread. Thanks.
 

What is optimization with constraints in Matlab?

Optimization with constraints in Matlab refers to the process of finding the best possible solution to a problem while satisfying a set of constraints or limitations. This is commonly used in engineering, economics, and other fields to maximize or minimize a certain objective while considering various constraints.

How do I define constraints in Matlab?

In Matlab, constraints can be defined using the "nonlcon" parameter in the optimization function. This parameter takes in a function that evaluates the constraints and returns a vector of values that should be equal to or less than zero for the constraints to be satisfied.

What are some common types of constraints used in optimization?

Some common types of constraints used in optimization include equality constraints, where a certain value must be equal to a given value, and inequality constraints, where a certain value must be less than or equal to a given value. Other types include bound constraints, which limit the range of possible values, and linear constraints, where the constraints can be expressed as linear equations or inequalities.

How can I visualize the optimization process with constraints in Matlab?

One way to visualize the optimization process with constraints in Matlab is by using the "plot" function to plot the objective function and the constraints. You can also use the "fmincon" function to plot the optimization path and see how the constraints are being satisfied at each step.

What are some common algorithms used for optimization with constraints in Matlab?

Some common algorithms used for optimization with constraints in Matlab include the interior-point method, active-set method, and sequential quadratic programming. These algorithms are designed to efficiently handle the constraints and find the optimal solution within the given constraints.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
Back
Top