Optimization with constraints matlab

Click For Summary
SUMMARY

This discussion focuses on optimizing a MATLAB assignment involving constraints in a mathematical model. The user is working on problem 5, specifically part (k), which requires finding valid design indices based on constraints defined in previous parts. Key MATLAB commands used include linspace, repmat, and find for array manipulation and indexing. The user confirmed that their solution for part (k) is identical to part (j), which raised questions about the necessity of the repetition.

PREREQUISITES
  • Familiarity with MATLAB syntax and functions
  • Understanding of array manipulation in MATLAB
  • Knowledge of mathematical modeling and constraints
  • Basic concepts of optimization in engineering contexts
NEXT STEPS
  • Explore MATLAB's find function for advanced indexing techniques
  • Learn about MATLAB's array operations and broadcasting
  • Investigate optimization techniques in MATLAB using the fmincon function
  • Review MATLAB documentation on constraints and optimization problems
USEFUL FOR

Students and professionals working on MATLAB optimization problems, particularly in engineering and mathematical modeling contexts, will benefit from this discussion.

gfd43tg
Gold Member
Messages
949
Reaction score
48

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

Physics news on Phys.org
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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K