Re: Support for constrained multiobjective optimization

289 views
Skip to first unread message

Aaron Garrett

unread,
Nov 8, 2012, 9:58:31 AM11/8/12
to insp...@googlegroups.com
It supports constraints, yes, and NSGA-II is implemented already. Depending on the types of constraints you have, it may take a little extra code to get it to do exactly what you want, but it should work. I'm happy to answer specific questions about that, though.

On Thursday, November 8, 2012 2:35:15 AM UTC-6, Olumide wrote:
I'm considering learning inspyred with a view to using it to solve a constrained multiobjective optimization problem. Does inspyred support such problems?

Also, does inspyred implement NSGA-II?

Thanks,

- Olumide

Olumide

unread,
Nov 11, 2012, 2:34:40 PM11/11/12
to insp...@googlegroups.com
Sorry about that. I mean to ask if SPEA2 is implemented.

I am currently working my way though the tutorial and will get back to you with specific questions, should they arise.

Aaron Garrett

unread,
Nov 11, 2012, 3:21:54 PM11/11/12
to insp...@googlegroups.com
SPEA2 is not implemented. It's on my roadmap of things to add, but I haven't done that yet (and cannot give a timeline on it). 



Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
Jacksonville State University
Jacksonville, AL  36265
agar...@jsu.edu
256-782-5364
http://mcis.jsu.edu/faculty/agarrett


On Sun, Nov 11, 2012 at 1:34 PM, Olumide <50...@web.de> wrote:
Sorry about that. I mean to ask if SPEA2 is implemented.

I am currently working my way though the tutorial and will get back to you with specific questions, should they arise.

--
You received this message because you are subscribed to the Google Groups "Inspyred" group.
To view this discussion on the web visit https://groups.google.com/d/msg/inspyred/-/JZcukyB8UgoJ.
To post to this group, send email to insp...@googlegroups.com.
To unsubscribe from this group, send email to inspyred+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/inspyred?hl=en.

Eason Chen

unread,
Jul 3, 2013, 12:52:33 AM7/3/13
to insp...@googlegroups.com
Hi Aaron Garrett, 

 do you have some examples of constrained optimization problem, such as constrained linear programming problem? or some hints?

Thanks, 

在 2012年11月8日星期四UTC+8下午10时58分31秒,Aaron Garrett写道:

Aaron Garrett

unread,
Jul 3, 2013, 8:16:19 AM7/3/13
to insp...@googlegroups.com
I don't have any examples, but if you have a specific problem, I can help you make it work. And then it would become an example. :-)



Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
131 Ayers Hall

Jacksonville State University
Jacksonville, AL  36265
agar...@jsu.edu
256-782-5364

--
You received this message because you are subscribed to the Google Groups "Inspyred" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inspyred+u...@googlegroups.com.

To post to this group, send email to insp...@googlegroups.com.
Visit this group at http://groups.google.com/group/inspyred.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Eason Chen

unread,
Jul 7, 2013, 8:45:10 AM7/7/13
to insp...@googlegroups.com
Hi Aaron Garrett, 

 I really appreciate for your help. I have a complicated constrained  linear programming problem, and I extract a simple example as:
 
Min z=8*x1+2*x2+ 4*x3+7*x4 + 5*x5

  subject to
  -3*x1-3*x2+x3+2*x4+3*x5 <= -2
  -5*x1-3*x2-2*x3-x4+x5 <= -4
  xj =0 or 1

could you give me some codes to solve it using some tools in the Inspyred package?
Thanks in advance! 

在 2013年7月3日星期三UTC+8下午8时16分19秒,Aaron Garrett写道:

Aaron Garrett

unread,
Jul 8, 2013, 9:21:50 AM7/8/13
to insp...@googlegroups.com
OK. Here is one way to handle constraints. You can set a penalty for the individual proportional to the number of constraints that it violates (or the degree of the violation, if you prefer, but I didn't do that here).
That's what this code does. If that doesn't suit your purposes, let me know what you would rather see.

import inspyred
import random
import time

def my_generator(random, args):
    size = args.get('num_inputs', 3)
    return [random.choice([0, 1]) for i in range(size)]

@inspyred.ec.evaluators.evaluator
def my_evaluator(candidate, args):
    # Check the constraints.
    constraint_bounds = [-2, -4]
    constraint_coefficients = [[-3, -3, 1, 2, 3], [-5, -3, -2, -1, 1]]
    constraints = [sum([c * v for c, v in zip(coeff, candidate)]) for coeff in constraint_coefficients]
    failed_constraints = 0
    for constraint, bound in zip(constraints, constraint_bounds):
        if constraint > bound:
            failed_constraints += 1
            
    # Now calculate the fitness. Depending on the computational time, 
    # failed constraints may cause us to just skip this part.
    coefficients = [8, 2, 4, 7, 5]
    fitness = 0
    for c, v in zip(coefficients, candidate):
        fitness += c * v
    
    # Now, punish the candidate for any failed constraints. For the current
    # problem, the largest (i.e., worst) value for any candidate is 26, so
    # we'll make sure that our constraint penalty is larger than that.
    # (We'll make it an order of magnitude larger at 100.)
    return failed_constraints * 100 + fitness


prng_seed = int(time.time())
prng = random.Random()
prng.seed(prng_seed)
optimizer = inspyred.ec.GA(prng)
optimizer.selector = inspyred.ec.selectors.tournament_selection
#optimizer.selector = inspyred.ec.selectors.rank_selection   # <--- This is the GA's default selection scheme.
optimizer.terminator = inspyred.ec.terminators.evaluation_termination
optimizer.observer = inspyred.ec.observers.stats_observer
final_pop = optimizer.evolve(generator=my_generator,
                             evaluator=my_evaluator,
                             pop_size=2,
                             maximize=False,
                             bounder=inspyred.ec.DiscreteBounder([0, 1]),
                             max_evaluations=10,
                             tournament_size=2,
                             mutation_rate=0.1,
                             num_elites=1,
                             num_inputs=5)

final_pop.sort(reverse=True)
print(final_pop[0])






Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
131 Ayers Hall
Jacksonville State University
Jacksonville, AL  36265
agar...@jsu.edu
256-782-5364


constraints.py

Eason Chen

unread,
Jul 24, 2013, 4:21:19 AM7/24/13
to insp...@googlegroups.com
Aaron Garrett,
  I appreciate you so much for the perfect works. You give me a good way to solve my problems, I hope I can keep touch with you for talking some issues about inspyred package. Thank you once again!

Bests,

在 2013年7月8日星期一UTC+8下午9时21分50秒,Aaron Garrett写道:

Will Tsing

unread,
Jan 7, 2018, 8:48:22 AM1/7/18
to Inspyred
Aaron Garrett, 
  Many thanks for your code and detailed explanations, I just wounder if we could make a step further: are there anyways to handle mixed integer nonlinear programming problems with constraints using Inspyred?
  like:

  Min z=8*x1+2*x2+ 4*x3+7*x4 + 5*x5 + (x6+ x4)**3

  subject to
  -3*x1-3*x2+x3+2*x4+3*x5 <= -2
  -5*x1-3*x2-2*x3-x4+x5 <= -4
   x6 * (3* x1 + x2+1) + 10(x4 + x5) >= 0

  xj =0 or 1(exclude x6)
  -10< x6 < 10 (float)
not sure if the is a proper question, I just modified the above examples to looks like a  mixed integer nonlinear programming problem and it is OK if some other  MINLP benchmark problems are used.

Many Thanks!

在 2013年7月8日星期一 UTC+8下午9:21:50,Aaron Garrett写道:

Aaron Garrett

unread,
Jan 9, 2018, 3:04:10 PM1/9/18
to insp...@googlegroups.com
I think you should be able to adapt the previous answer to do what you want, yes. I don't see any clear reason why that wouldn't work.



--
Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
Wofford College
429 North Church Street
Spartanburg, SC 29303
Reply all
Reply to author
Forward
0 new messages