Writing Optimization Code in Matlab - Resource Guide

In summary, the author is trying to write code to optimize an airplane's mission. They are having difficulty because they have never written code like this before. They need help finding a starting point.
  • #1
physicsCU
202
1
OK, here is the situation.

I am supposed to write optimization code in Matlab to determine which of two missions an airplane should perform. There are three total, but one of them has been decided on. So I need to determine which of the other two I should do.

The problem is that I have never written this type of code before, so I have no clue what to do.

Could someone give me a good resource I can use as a starting point to writing this code?
 
Physics news on Phys.org
  • #2
um i think you need to put parameters/variables/criterion that your using so that people can be more descriptive. ie is it a airplane path like TSP/Hcycles problem?
 
  • #3
ok, I need to minimize the weight as much as i can.

one mission involved flying up to 10 liters of water, and is scored by number of laps completed ^2, ie 5 laps = 25 for score

the other is carry 96 tennis balls for 2 minutes, and this can be any number, as long as all 96 fly. scored by 1/RAC where RAC = airframe + battery weight.

The plane already will carry 48 tennis balls and 4 liters of water.
 
  • #4
There is an optimization function built in.

What you want to do is define a goal function. The MATLAB function will
minimize that goal function (If you want to maximize it, put a minus sign in front
of it.)

Then there are some number of unknowns. You goal function is a function of the
unknowns and MATLAB will find particular values for the unknowns so that the
goal function is a minimum.


Try "help fminsearch"
 
  • #5
thanks!

is fminsearch in standard MATLAB or is it in a toolbox?
 
  • #6
... if you have the optimization toolbox then you've a number of great tools available. Fminsearch is for unconstrained nonlinear optimization and is a standard function.
 
  • #7
ok thanks.

sounds like i may want to consider using the optimization toolbox, especially because i need this code done in two weeks.
 
  • #8
... and depending on the degree of nonlinearity and in case you've 'complex' constraints you may have to implement, the optimization toolbox rules.
 

Related to Writing Optimization Code in Matlab - Resource Guide

What is writing optimization code in Matlab?

Writing optimization code in Matlab refers to the process of creating and implementing algorithms to improve the efficiency and speed of code written in the Matlab programming language. This can involve techniques such as vectorization, preallocation, and parallel processing.

Why is it important to optimize code in Matlab?

Optimizing code in Matlab can significantly improve the performance of programs, making them run faster and use less memory. This can be especially important for large and complex algorithms, where even small improvements in efficiency can have a big impact on overall execution time.

What are some general tips for writing efficient code in Matlab?

Some general tips for writing efficient code in Matlab include using vector and matrix operations instead of loops, preallocating arrays before filling them, and avoiding unnecessary function calls. It is also important to avoid using global variables and to optimize memory usage.

Are there any built-in functions in Matlab for optimizing code?

Yes, Matlab offers several built-in functions for optimizing code, such as squeeze for removing singleton dimensions from arrays, bsxfun for performing element-wise operations on arrays with different dimensions, and parallel computing for utilizing multiple processors for faster execution.

Are there any resources available for learning more about writing optimization code in Matlab?

Yes, there are many resources available for learning more about writing optimization code in Matlab, including online tutorials, books, and forums. Some recommended resources include "Efficient MATLAB Programming" by Jonas Lundgren, "Optimizing MATLAB Code" by Silvia Gazzola and Michael Paluszek, and the MathWorks website's optimization and performance improvement guides.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
793
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
669
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Back
Top