Menu

Optimization solvers

2025-03-05
2025-03-05
  • Geert Dierick

    Geert Dierick - 2025-03-05

    Hi,

    I'm looking for a non-linear constrained optimization solver.
    My problem is multi-variable (hundreds), multiple equality constraints and an objective function to minimize.

    This one is for gas permeation with multiple gas components.
    A 1D problem along the axis of the permeation module. It gets divided in N virtual sections.
    In each section, the composition of feed and permeate gas changes due to permeation through the membrane.
    There are calculation algorithms for this, but difficult to implement and not always stable.

    I see DWSim has several libraries for optimization:
    * dotnumerics.optimization: several solvers
    * DWSIM_MathOps_MathEx_Optimization: IPOPT, Newton.

    However, I can't find any examples or documentation apart from the concise class documentation.
    I also looked online for documentation on DotNumerics, but nothing there either.

    What I'm actually looking for is something akin to AMPL, Microsoft Solver Foundation (.Net), Pyomo (Python) or Gekko (Python).
    With these tools, one defines the mathematical model (variables, constraints, objective function), and the framework deals with the gritty details needed by specific solvers.

    Is there anything like this available in DWSim (via ironpython) or should I go Python.NET with Pyomo or Gekko?

    Best regards,

    Geert

     
  • Geert Dierick

    Geert Dierick - 2025-03-05

    A short follow-up:
    I managed to get Gekko running in DWSim.

    Procedure:
    - install WinPython (version 3.9);
    - install Gekko package (pip install gekko);
    - register winPython in DWSim (General settings/Python);
    - DWSim/Script Manager, set python interpreter = Python.NET

    Test one of these Gekko examples.

    A few changes are required to the scripts:
    - print(value) => Flowsheet.WriteMessage(str(value))
    - list comprehension: works for values but not for lists of objects, change to a for loop with list.append(object);

    It also outputs matplotlib figures (if installed), see image attached, PID Control Tuning.

    There's a bit of a lag while running this (about 0,5s).
    I assume it is setting up the solver environment.

    There are other examples in the link above.
    Including non linear optimization.

    Regards,

    Geert

     

    Last edit: Geert Dierick 2025-03-05
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.