pyomo

Minimize cost based on purchased volume Pyomo

こ雲淡風輕ζ 提交于 2021-01-07 02:59:09
问题 I'd like to find the optimal solution for buying goods from suppliers where the shipping cost is dependent on the cost of goods bought from given supplier. I'm using Pyomo. My code so far is: model = ConcreteModel(name="(MN_2)") # products N = ['prod1', 'prod2', 'prod3'] # suppliers M = ['A', 'B'] # price p = {('prod1', 'A'): 10, ('prod2', 'A'): 9, ('prod3', 'A'): 50, ('prod1', 'B'): 16, ('prod2', 'B'): 20, ('prod3', 'B'): 35} # user quantity contraint q_u = {('prod1', 'A'): 2, ('prod2', 'A')

Pyomo accesing/retrieving dual variables - shadow price with binary variables

南楼画角 提交于 2021-01-07 02:36:52
问题 I am pretty new to optimization in general and pyomo in particular, so I apologize in advance for any rookie mistakes. I have defined a simple unit commitment exercise (example 3.1 from [1]) using [2] as starting point. I got the correct result and my code runs, but I have a few questions regarding how to access stuff. import matplotlib.pyplot as plt import numpy as np import pandas as pd import shutil import sys import os.path import pyomo.environ as pyo import pyomo.gdp as gdp #necessary if

PYOMO: Defining dataset using Sets and Parameters for solving an optimization problem

限于喜欢 提交于 2020-12-12 05:42:19
问题 I am trying to formulate some data into a PYOMO model for an optimization problem. materials = ['steel', 'alum', 'carbon', 'cheese'] Each material has 2 properties - density and conductivity and their values are defined as follows. density = { 'steel' : 1.2, 'alum' : 0.8, 'carbon': 1.8, 'cheese': 0.7} conductivity = {'steel' : 6.4, 'alum' : 3.1, 'carbon': 4.4, 'cheese': 0.3} The objective function calculates the weight of 2 rectangular plates as given below: Objective function = Area_1 *

PYOMO: Defining dataset using Sets and Parameters for solving an optimization problem

二次信任 提交于 2020-12-12 05:40:47
问题 I am trying to formulate some data into a PYOMO model for an optimization problem. materials = ['steel', 'alum', 'carbon', 'cheese'] Each material has 2 properties - density and conductivity and their values are defined as follows. density = { 'steel' : 1.2, 'alum' : 0.8, 'carbon': 1.8, 'cheese': 0.7} conductivity = {'steel' : 6.4, 'alum' : 3.1, 'carbon': 4.4, 'cheese': 0.3} The objective function calculates the weight of 2 rectangular plates as given below: Objective function = Area_1 *

PYOMO: How to use abstract models with internal data

痞子三分冷 提交于 2020-12-06 12:23:12
问题 Hei all, I am trying to set up an abstract model for a very simple QP of the form min (x-x0)^2 s.t. A x = b C x <= d I would like to use an abstract model, as I need to resolve with changing parameters (mainly x0, but potentially also A, b, C, d). I am right now struggeling with simply setting the parameters in the model instance. I do not want to use an external data file, but rather internal python variables. All examples I find online use AMPL formatted data files. This is the code I have

PYOMO: How to use abstract models with internal data

三世轮回 提交于 2020-12-06 12:22:18
问题 Hei all, I am trying to set up an abstract model for a very simple QP of the form min (x-x0)^2 s.t. A x = b C x <= d I would like to use an abstract model, as I need to resolve with changing parameters (mainly x0, but potentially also A, b, C, d). I am right now struggeling with simply setting the parameters in the model instance. I do not want to use an external data file, but rather internal python variables. All examples I find online use AMPL formatted data files. This is the code I have

How to use 'cbc' in pyomo's SolverFactory in Windows 10

不羁岁月 提交于 2020-07-10 10:26:46
问题 I have been trying to use 'cbc' solver in pyomo as following: """ import pyomo.environ as pe solver = pe.SolverFactory('cbc') result = solver.solve(m) """ Currently, I have been relying on the embedded solver with pyomo installation, which is 'glpk', and I have found that 'cbc' can do better job in many circumstances. I am using: python 3.XX Anaconda environment Windows 10 Pyomo (installed via Conda) It would be great to upgrade the ability of pyomo by using advanced solver! 回答1: You will