1#  ___________________________________________________________________________
2#
3#  Pyomo: Python Optimization Modeling Objects
4#  Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC
5#  Under the terms of Contract DE-NA0003525 with National Technology and
6#  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
7#  rights in this software.
8#  This software is distributed under the 3-clause BSD License.
9#  ___________________________________________________________________________
10#
11
12from pyomo.environ import ConcreteModel, Param, Var, Constraint, inequality
13
14from pyomo.contrib.sensitivity_toolbox.sens import sensitivity_calculation
15
16
17def create_model():
18
19    m = ConcreteModel()
20
21    m.a = Param(initialize=0, mutable=True)
22    m.b = Param(initialize=1, mutable=True)
23
24
25    m.x = Var(initialize = 1.0)
26    m.y = Var()
27    m.C_rangedIn = Constraint(expr=inequality(m.a,m.x,m.b))
28    m.C_equal = Constraint(expr=m.y==m.b)
29    m.C_singleBnd = Constraint(expr=m.x<=m.b)
30
31
32    return m
33
34if __name__=='__main__':
35    m = create_model()
36
37    m.pert_a = Param(initialize=0.01)
38    m.pert_b = Param(initialize=1.01)
39
40
41    m_sipopt = sensitivity_calculation('sipopt', m,[m.a,m.b],[m.pert_a,m.pert_b],
42                      tee=True)
43