wouterbles / pyaugmecon

An AUGMECON based multi-objective optimization solver for Pyomo.
Other
24 stars 8 forks source link

PyAugmecon opens multiple environments simultaneously #10

Closed AndresFCortes closed 1 year ago

AndresFCortes commented 1 year ago

Dear Wouter,

I started working with your package on a project and realised that when it solves the model, more than one Gurobi environment is executed. There is no problem if your institution has a multi-use licence. However, if there is a single-use license, where only one process can be used at-a-time, this causes an error when calling the method pyaugmecon.solve(). Therefore, a partner of us has found an elegant solution to this issue in the model.py file in order not to limit the license's usage, as follows:

def solve(self): """ Solve the model using the specified solver.

    The result, termination condition, and solver status are stored as class attributes.
    """
    opt = pyo.SolverFactory(self.opts.solver_name, solver_io=self.opts.solver_io, manage_env=True)
    opt.options.update(self.opts.solver_opts)
    try:
        self.result = opt.solve(self.model)
        self.term = self.result.solver.termination_condition
        self.status = self.result.solver.status
    finally:
        opt.close()`

I've modified this in a Fork to be considered it would be modified in the main branch.

BR

Dr. Andrés Cortés Ph.D

wouterbles commented 1 year ago

Thanks for your contribution! I think this should already be addressed in: https://github.com/wouterbles/pyaugmecon/pull/9 right?

AndresFCortes commented 1 year ago

Yes, you are right. I think David should have suggested the same changes.

Best regards,

Andrés Felipe Cortés Borray

PhD Investigador / Unidad de Transición Energética, Climática y Urbana PhD Researcher - Energy, Climate Change and Urban Transition

+34 664111685 [Tecnalia]https://www.tecnalia.com/ [Linkedin]https://www.linkedin.com/company/tecnalia-research-&-innovation [Twitter] https://twitter.com/tecnalia [Instagram] https://www.instagram.com/tecnaliaoficial/ [Facebook] https://www.facebook.com/Tecnalia/ [Youtube] https://www.youtube.com/user/tecnaliaTV [RSS] https://cms.tecnalia.com/feed/?post_type=news&lang=es Este mensaje puede contener información confidencial o privilegiada. Si no eres el destinatario de este mensaje, notifícaselo por favor al remitente y bórralo sin reenviarlo o guardarlo dado que está legalmente prohibido.

This message may contain confidential, proprietary or legally privileged information. If you are not the intended recipient of this message, please notify it to the sender and delete without resending or backing it, as it is legally prohibited

De: Wouter Bles @.> Enviado el: miércoles, 9 de agosto de 2023 12:59 Para: wouterbles/pyaugmecon @.> CC: Cortes Borray, Andres Felipe @.>; Author @.> Asunto: Re: [wouterbles/pyaugmecon] PyAugmecon opens multiple environments simultaneously (Issue #10)

Thanks for your contribution! I think this should already be addressed in: #9https://github.com/wouterbles/pyaugmecon/pull/9 right?

- Reply to this email directly, view it on GitHubhttps://github.com/wouterbles/pyaugmecon/issues/10#issuecomment-1671109368, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYFANDIXGE5XQDSRAYR2PZDXUNUQHANCNFSM6AAAAAA3IBDSY4. You are receiving this because you authored the thread.Message ID: @.**@.>>