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 and integers

Subject: fminsearch and integers

From: Thomas Bunn

Date: 14 May, 2013 16:13:08

Message: 1 of 9

I am using fminsearch to minimize a function that depends on 5 variables. I want two of the variables to be integers. Is there a way to pass integers and real numbers to the function using fminsearch?

Tom

Subject: fminsearch and integers

From: Matt J

Date: 14 May, 2013 21:29:10

Message: 2 of 9

"Thomas Bunn" wrote in message <kmtnqk$jhh$1@newscl01ah.mathworks.com>...
> I am using fminsearch to minimize a function that depends on 5 variables. I want two of the variables to be integers. Is there a way to pass integers and real numbers to the function using fminsearch?
========

No, there is not. You would need GA from the Global Optimization Toolbox, which has options for mixed integer programming

Subject: fminsearch and integers

From: Brendan

Date: 15 May, 2013 13:12:07

Message: 3 of 9

"Matt J" wrote in message <kmuab6$kid$1@newscl01ah.mathworks.com>...
> "Thomas Bunn" wrote in message <kmtnqk$jhh$1@newscl01ah.mathworks.com>...
> > I am using fminsearch to minimize a function that depends on 5 variables. I want two of the variables to be integers. Is there a way to pass integers and real numbers to the function using fminsearch?
> ========
>
> No, there is not. You would need GA from the Global Optimization Toolbox, which has options for mixed integer programming
You might want to take a look at the OPTI Toolbox
http://www.i2c2.aut.ac.nz/Wiki/OPTI/

Subject: fminsearch and integers

From: Thomas Bunn

Date: 15 May, 2013 16:31:11

Message: 4 of 9

"Brendan" wrote in message <kn01j7$g7s$1@newscl01ah.mathworks.com>...
> "Matt J" wrote in message <kmuab6$kid$1@newscl01ah.mathworks.com>...
> > "Thomas Bunn" wrote in message <kmtnqk$jhh$1@newscl01ah.mathworks.com>...
> > > I am using fminsearch to minimize a function that depends on 5 variables. I want two of the variables to be integers. Is there a way to pass integers and real numbers to the function using fminsearch?
> > ========
> >
> > No, there is not. You would need GA from the Global Optimization Toolbox, which has options for mixed integer programming
> You might want to take a look at the OPTI Toolbox
> http://www.i2c2.aut.ac.nz/Wiki/OPTI/

Thank-you for both tips.

Subject: fminsearch and integers

From: pietro

Date: 15 May, 2013 17:25:08

Message: 5 of 9

"Thomas Bunn" wrote in message <kn0d8f$q94$1@newscl01ah.mathworks.com>...
> "Brendan" wrote in message <kn01j7$g7s$1@newscl01ah.mathworks.com>...
> > "Matt J" wrote in message <kmuab6$kid$1@newscl01ah.mathworks.com>...
> > > "Thomas Bunn" wrote in message <kmtnqk$jhh$1@newscl01ah.mathworks.com>...
> > > > I am using fminsearch to minimize a function that depends on 5 variables. I want two of the variables to be integers. Is there a way to pass integers and real numbers to the function using fminsearch?
> > > ========
> > >
> > > No, there is not. You would need GA from the Global Optimization Toolbox, which has options for mixed integer programming
> > You might want to take a look at the OPTI Toolbox
> > http://www.i2c2.aut.ac.nz/Wiki/OPTI/
>
> Thank-you for both tips.

Or you could make your variables interger in your objective function using floor or round

Subject: fminsearch and integers

From: Matt J

Date: 23 May, 2013 04:42:09

Message: 6 of 9

"pietro " <bracardi82@email.it> wrote in message <kn0gdk$710$1@newscl01ah.mathworks.com>...
>
>
> Or you could make your variables interger in your objective function using floor or round

I would not recommend that. Doing so makes every feasible integer value a local minimum of the objective (because floor and round are locally flat) and the algorithm can very easily get stuck anywhere.

Subject: fminsearch and integers

From: Thomas Bunn

Date: 23 May, 2013 17:40:22

Message: 7 of 9

"Matt J" wrote in message <knk6n1$i5i$1@newscl01ah.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <kn0gdk$710$1@newscl01ah.mathworks.com>...
> >
> >
> > Or you could make your variables interger in your objective function using floor or round
>
> I would not recommend that. Doing so makes every feasible integer value a local minimum of the objective (because floor and round are locally flat) and the algorithm can very easily get stuck anywhere.

Yep, found that out the hard way before Pietro's suggestion. The OPTI routines seem to work for now.

Subject: fminsearch and integers

From: Hannah

Date: 28 Jun, 2013 00:31:05

Message: 8 of 9

Can you please post how to use opti to include an integer as one of the variables to be optimised? I have the same question.

Subject: fminsearch and integers

From: Thomas Bunn

Date: 28 Jun, 2013 15:31:12

Message: 9 of 9

"Hannah" wrote in message <kqilg9$6to$1@newscl01ah.mathworks.com>...
> Can you please post how to use opti to include an integer as one of the variables to be optimised? I have the same question.

Here is the website. http://www.i2c2.aut.ac.nz/PHP/getOPTI.php Authors have published 2.0

I've been using the NOMAD solver with success. You send the SOLVE routine a string array having the same size as the array of optimized variables. For an integer variable, the corresponding string character will be 'I' i.e., xtype = ['I' etc].

Tags for this Thread

No tags are associated with 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