or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/pypi-pyomo

The Pyomo optimization modeling framework for formulating, analyzing, and solving mathematical optimization problems

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyomo@6.9.x

To install, run

npx @tessl/cli install tessl/pypi-pyomo@6.9.0

0

# Pyomo

1

2

Pyomo is a comprehensive Python-based open-source optimization modeling framework that enables users to formulate, analyze, and solve diverse mathematical optimization problems. It supports linear programming, quadratic programming, nonlinear programming, mixed-integer programming variants, stochastic programming, generalized disjunctive programming, differential algebraic equations, and mathematical programming with equilibrium constraints. The framework provides a full-featured modeling environment with symbolic problem definition capabilities, concrete instance creation, and integration with standard optimization solvers.

3

4

## Package Information

5

6

- **Package Name**: pyomo

7

- **Package Type**: pypi

8

- **Language**: Python

9

- **Installation**: `pip install pyomo`

10

11

## Core Imports

12

13

Primary interface importing all core APIs:

14

15

```python

16

from pyomo.environ import *

17

```

18

19

Specific component imports:

20

21

```python

22

from pyomo.environ import (

23

ConcreteModel, AbstractModel, Var, Constraint, Objective, Set, Param,

24

SolverFactory, value, minimize, maximize

25

)

26

```

27

28

Module-specific imports:

29

30

```python

31

import pyomo.core as pyo

32

import pyomo.opt as opt

33

import pyomo.gdp as gdp

34

```

35

36

## Basic Usage

37

38

```python

39

from pyomo.environ import *

40

41

# Create a concrete model

42

model = ConcreteModel()

43

44

# Define decision variables

45

model.x = Var([1, 2], domain=NonNegativeReals)

46

47

# Define objective function

48

model.obj = Objective(expr=2*model.x[1] + 3*model.x[2], sense=maximize)

49

50

# Define constraints

51

model.constraint1 = Constraint(expr=3*model.x[1] + 4*model.x[2] <= 1)

52

model.constraint2 = Constraint(expr=2*model.x[1] + 5*model.x[2] <= 2)

53

54

# Solve the optimization problem

55

solver = SolverFactory('glpk') # requires GLPK solver installed

56

results = solver.solve(model)

57

58

# Access solution values

59

print(f"x[1] = {value(model.x[1])}")

60

print(f"x[2] = {value(model.x[2])}")

61

print(f"Objective value = {value(model.obj)}")

62

```

63

64

## Architecture

65

66

Pyomo's architecture is built around several key design principles:

67

68

- **Component-based modeling**: All model elements (variables, constraints, objectives, parameters) are components that can be dynamically added to models

69

- **Algebraic modeling language**: Symbolic representation of optimization problems using Python expressions

70

- **Abstract vs. Concrete models**: Support for both template-based abstract models and concrete models with specific data

71

- **Solver integration**: Flexible interface to multiple optimization solvers through standardized APIs

72

- **Transformation framework**: Extensible system for problem reformulations and preprocessing

73

74

## Capabilities

75

76

### Core Modeling Components

77

78

Essential modeling components for creating optimization problems including models, variables, constraints, objectives, parameters, and sets. These form the foundation of all Pyomo optimization models.

79

80

```python { .api }

81

class ConcreteModel: ...

82

class AbstractModel: ...

83

class Var: ...

84

class Constraint: ...

85

class Objective: ...

86

class Set: ...

87

class Param: ...

88

```

89

90

[Core Modeling](./core-modeling.md)

91

92

### Optimization Interface

93

94

Solver factories, result handling, and optimization problem management. Provides standardized interface to dozens of optimization solvers with comprehensive result analysis capabilities.

95

96

```python { .api }

97

class SolverFactory: ...

98

class SolverResults: ...

99

def check_optimal_termination(results): ...

100

enum SolverStatus: ...

101

enum TerminationCondition: ...

102

```

103

104

[Optimization Interface](./optimization-interface.md)

105

106

### Mathematical Functions and Expressions

107

108

Built-in mathematical functions and expression utilities for constructing complex objective functions and constraints including trigonometric, logarithmic, and logical operations.

109

110

```python { .api }

111

def log(x): ...

112

def sin(x): ...

113

def cos(x): ...

114

def exp(x): ...

115

def value(expr): ...

116

def differentiate(expr, var): ...

117

```

118

119

[Mathematical Functions](./mathematical-functions.md)

120

121

### Domain Sets and Intervals

122

123

Predefined domain sets and interval constructors for variable bounds and parameter domains including real numbers, integers, booleans, and custom intervals.

124

125

```python { .api }

126

Reals: Set

127

NonNegativeReals: Set

128

Integers: Set

129

Boolean: Set

130

def RealInterval(lb, ub): ...

131

def IntegerInterval(lb, ub): ...

132

```

133

134

[Domain Sets](./domain-sets.md)

135

136

### Generalized Disjunctive Programming

137

138

Components for modeling logical relationships and disjunctive constraints including disjuncts, disjunctions, and GDP-specific transformations.

139

140

```python { .api }

141

class Disjunct: ...

142

class Disjunction: ...

143

class GDP_Error(Exception): ...

144

```

145

146

[Generalized Disjunctive Programming](./gdp.md)

147

148

### Differential Algebraic Equations

149

150

Components for modeling dynamic systems with differential and algebraic equations including continuous sets, derivative variables, and simulation interfaces.

151

152

```python { .api }

153

class ContinuousSet: ...

154

class DerivativeVar: ...

155

class Integral: ...

156

class Simulator: ...

157

```

158

159

[Differential Algebraic Equations](./dae.md)

160

161

### Mathematical Programming with Equilibrium Constraints

162

163

Components for modeling equilibrium problems, complementarity constraints, and bilevel optimization problems including variational inequalities and game-theoretic formulations.

164

165

```python { .api }

166

class Complementarity: ...

167

class ComplementarityList: ...

168

def complements(expr1, expr2): ...

169

```

170

171

[Mathematical Programming with Equilibrium Constraints](./mpec.md)

172

173

### Data Management

174

175

Data loading and management interfaces for importing external data from various sources including databases, spreadsheets, and structured files.

176

177

```python { .api }

178

class DataPortal: ...

179

class TableData: ...

180

class DataManagerFactory: ...

181

```

182

183

[Data Management](./data-management.md)

184

185

### Advanced Extensions

186

187

Contributed modules providing specialized optimization algorithms, solver interfaces, and modeling capabilities including nonlinear decomposition, sensitivity analysis, and robust optimization.

188

189

```python { .api }

190

# Selected contrib modules

191

pyomo.contrib.gdpopt: ...

192

pyomo.contrib.mindtpy: ...

193

pyomo.contrib.sensitivity_toolbox: ...

194

pyomo.contrib.pyros: ...

195

```

196

197

[Advanced Extensions](./advanced-extensions.md)