Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fminsearch constraints-- please help

Subject: fminsearch constraints-- please help

From: John

Date: 7 Jun, 2011 21:34:21

Message: 1 of 6

Hello all,

I am in my first engineering internship and I am trying to perform a basic analysis of dynamic positioning of a vessel with 6 thrusters. If I use fminsearch, how can I restrict which values are acceptable as results? I.e., you can't get negative thrust.

Is there a way I could use "If" statements or something like that?

Thanks!

Subject: fminsearch constraints-- please help

From: Matt J

Date: 7 Jun, 2011 21:48:04

Message: 2 of 6

"John " <johnps@gmail.com> wrote in message <ism5gt$m1j$1@newscl01ah.mathworks.com>...
> Hello all,
>
> I am in my first engineering internship and I am trying to perform a basic analysis of dynamic positioning of a vessel with 6 thrusters. If I use fminsearch, how can I restrict which values are acceptable as results? I.e., you can't get negative thrust.
==================

You could use a transformation of variables in the function you're trying to minimize, e.g.,

thrust=sqrtThrust^2; %write function in terms of sqrtThrust

There are those who speculate that this is a dangerous thing to do, but then again, FMINSEARCH is itself a semi-reliable algorithm (Nelder-Mead).

Subject: fminsearch constraints-- please help

From: John

Date: 7 Jun, 2011 22:43:02

Message: 3 of 6

"Matt J" wrote in message <ism6ak$o3j$1@newscl01ah.mathworks.com>...
> "John " <johnps@gmail.com> wrote in message <ism5gt$m1j$1@newscl01ah.mathworks.com>...
> > Hello all,
> >
> > I am in my first engineering internship and I am trying to perform a basic analysis of dynamic positioning of a vessel with 6 thrusters. If I use fminsearch, how can I restrict which values are acceptable as results? I.e., you can't get negative thrust.
> ==================
>
> You could use a transformation of variables in the function you're trying to minimize, e.g.,
>
> thrust=sqrtThrust^2; %write function in terms of sqrtThrust
>
> There are those who speculate that this is a dangerous thing to do, but then again, FMINSEARCH is itself a semi-reliable algorithm (Nelder-Mead).

Good idea. I'll give it a try! Otherwise I'll use Excel Solver like my boss-- which surely can't be more reliable. Thanks a lot.

Subject: fminsearch constraints-- please help

From: Steven_Lord

Date: 8 Jun, 2011 13:55:50

Message: 4 of 6



"John " <johnps@gmail.com> wrote in message
news:ism5gt$m1j$1@newscl01ah.mathworks.com...
> Hello all,
>
> I am in my first engineering internship and I am trying to perform a basic
> analysis of dynamic positioning of a vessel with 6 thrusters. If I use
> fminsearch, how can I restrict which values are acceptable as results?
> I.e., you can't get negative thrust.

From the reference page for FMINSEARCH:

http://www.mathworks.com/help/techdoc/ref/fminsearch.html

"Find minimum of ***_unconstrained_*** multivariable function using
derivative-free method" [Emphasis mine.]


For constrained minimizers, you want to switch to using an Optimization
Toolbox function like FMINCON.

http://www.mathworks.com/help/toolbox/optim/ug/fmincon.html

"Find minimum of constrained nonlinear multivariable function"

or perhaps something in Global Optimization Toolbox.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: fminsearch constraints-- please help

From: Matt J

Date: 8 Jun, 2011 14:25:20

Message: 5 of 6

"John " <johnps@gmail.com> wrote in message <ism5gt$m1j$1@newscl01ah.mathworks.com>...
> Hello all,
>
> I am in my first engineering internship and I am trying to perform a basic analysis of dynamic positioning of a vessel with 6 thrusters. If I use fminsearch, how can I restrict which values are acceptable as results? I.e., you can't get negative thrust.
================

John, I was assuming from the phrasing of your post that you did not have the Optimization Toolbox and were constrained to use FMINSEARCH. If you do have the Optimization Toolbox, using FMINCON, like Steve said, is preferable (probably) to the transformation of variables technique.

Subject: fminsearch constraints-- please help

From: John

Date: 9 Jun, 2011 13:29:05

Message: 6 of 6

"Matt J" wrote in message <iso0og$m0t$1@newscl01ah.mathworks.com>...
> "John " <johnps@gmail.com> wrote in message <ism5gt$m1j$1@newscl01ah.mathworks.com>...
> > Hello all,
> >
> > I am in my first engineering internship and I am trying to perform a basic analysis of dynamic positioning of a vessel with 6 thrusters. If I use fminsearch, how can I restrict which values are acceptable as results? I.e., you can't get negative thrust.
> ================
>
> John, I was assuming from the phrasing of your post that you did not have the Optimization Toolbox and were constrained to use FMINSEARCH. If you do have the Optimization Toolbox, using FMINCON, like Steve said, is preferable (probably) to the transformation of variables technique.

Aha, I see. I'm not sure if I have it-- which means that I probably don't I suppose. Thanks for the help. My company doesn't have MATLAB so it's not urgent-- I was doing it for my own clarification of thoughts.

Thanks again for the help!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us