Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fminsearch and integers

224 views
Skip to first unread message

Thomas Bunn

unread,
May 14, 2013, 12:13:08 PM5/14/13
to
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

Matt J

unread,
May 14, 2013, 5:29:10 PM5/14/13
to
"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

Brendan

unread,
May 15, 2013, 9:12:07 AM5/15/13
to
"Matt J" wrote in message <kmuab6$kid$1...@newscl01ah.mathworks.com>...
You might want to take a look at the OPTI Toolbox
http://www.i2c2.aut.ac.nz/Wiki/OPTI/

Thomas Bunn

unread,
May 15, 2013, 12:31:11 PM5/15/13
to
"Brendan" wrote in message <kn01j7$g7s$1...@newscl01ah.mathworks.com>...
Thank-you for both tips.

pietro

unread,
May 15, 2013, 1:25:08 PM5/15/13
to
"Thomas Bunn" wrote in message <kn0d8f$q94$1...@newscl01ah.mathworks.com>...
Or you could make your variables interger in your objective function using floor or round

Matt J

unread,
May 23, 2013, 12:42:09 AM5/23/13
to
"pietro " <braca...@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.

Thomas Bunn

unread,
May 23, 2013, 1:40:22 PM5/23/13
to
"Matt J" wrote in message <knk6n1$i5i$1...@newscl01ah.mathworks.com>...
> "pietro " <braca...@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.

Hannah

unread,
Jun 27, 2013, 8:31:05 PM6/27/13
to
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.

Thomas Bunn

unread,
Jun 28, 2013, 11:31:12 AM6/28/13
to
"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].
0 new messages