PYOMO Model Checking, Testing the optimisation model

131 views
Skip to first unread message

MUHAMMAD WAQAS SWATI

unread,
Jul 21, 2022, 11:33:20 AM7/21/22
to Pyomo Forum

I have a resource scheduling optimisation model in Pyomo with 3 constraints and an objective. The model runs well for the minimisation and maximisation objectives.

Constraint1: Each job is assigned to some machine.
Constraint2: Demand job <= Capacity of the machine.
Constraint3: Each job must be assigned to almost 1 machine.

Objective: MIN(Jobs placement cost on different machines)

Now, I want to write a  separate function that verifies my PYOMO model's result is "as" expected.

I mean the function will confirm that my model validates all the constraints before the results. Looking for some directions.

David Woodruff

unread,
Jul 21, 2022, 1:28:08 PM7/21/22
to pyomo...@googlegroups.com
You want something like this:
pyo.assert_optimal_termination(results)

Here's a little context:

import pyomo.environ as pyo
...
opt = pyo.SolverFactory('glpk')
results = opt.solve(model)  # solves and updates model
pyo.assert_optimal_termination(results)

If your library has this book, you might want to look at it:

Pyomo ― Optimization Modeling in Python (Springer Optimization and Its Applications, 67) 3rd ed. 2021 Edition

(The assert_optimal_termination function is in the third edition, but not the second edition)

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyomo-forum/6a3b7f22-5272-4302-9269-f2abfec1e86en%40googlegroups.com.

MUHAMMAD WAQAS SWATI

unread,
Jul 22, 2022, 11:53:00 AM7/22/22
to Pyomo Forum
Thank You Sir for the guidance. I have studied the termination condition from the book. Actually, it terminates when the solver failed to return an optimal solution for the pyomo model...
However, I want a different function that works in the same way as my pyomo model and confirms that all constraints are met and the objective function's output is what was anticipated.
Reply all
Reply to author
Forward
0 new messages