-
Notifications
You must be signed in to change notification settings - Fork 0
/
tarea1.py
58 lines (47 loc) · 1.27 KB
/
tarea1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 30 23:45:12 2017
@author: juan
"""
from __future__ import division
from pyomo.environ import *
from pyomo.opt import SolverFactory
import energia1
# Create a solver
opt = SolverFactory('glpk')
data = DataPortal()
data.load(filename='energia1.dat')
# Create a model instance and optimize
instance = energia1.model.create_instance(data)
instance.dual = Suffix(direction=Suffix.IMPORT)
results = opt.solve(instance)
print " "
print "************** Resultados *************"
print "Funcion objetivo", instance.cost()
#Imprimir variables
#print " "
print "Variables"
for i in instance.E:
for h in instance.D:
print f, instance.x[i,h].value
#print " "
#print "Variabl dual de restriccion de volumen"
#print instance.dual[instance.volume]
#
#print " "
#print "Variabl dual de restricciones de nutrientes minimos"
#for j in instance.N:
# print j, instance.dual[instance.nutrient_limit_min[j]]
#print " "
#print "Sensibilidad respecto a Vmax"
#Mutar un parametro y volver a resolver, ojo que debe ser mutable
#for valores in [30,40,50,60]:
# #re definir el valor de Vmax
# instance.Vmax.value=valores
#
# #volver a resolver
# results = opt.solve(instance)
#
# #imprimir vmax y funcion objetivo
# print valores, instance.cost()