Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

clean up unit tests for generators and solvers. need to return the po…

…wer system object to keep the weakrefs alive. add a str representation for the OptimizationProblem.
  • Loading branch information...
commit 796e6abe7beb4d15842f21509ddb64458c1fc429 1 parent b051427
Adam Greenhall authored
2  minpower/config.py
View
@@ -96,6 +96,6 @@
default_hours_commitment_overlap=0
optimization_package='coopr' #'pulp'
-optimization_solver='gurobi'
+optimization_solver='glpk'
available_solvers = ['glpk','gurobi']#['glpk','gurobi','cplex']
logging_level= logging.INFO
1  minpower/optimization.py
View
@@ -335,6 +335,7 @@ def resolvefixvariables(instance,results):
#self.variables = instance.active_components(pyomo.Var)
return
+ def __str__(self): return 'power_system_problem'
def value(variable):
'''
14 minpower/tests/generators.py
View
@@ -26,9 +26,8 @@ def power_maximum():
make_cheap_gen(Pmax=Pmax),
make_expensive_gen()
]
- solve_problem(generators,**make_loads_times(Pd))
-
- assert generators[0].power(singletime[0]) == Pmax
+ power_system,times=solve_problem(generators,**make_loads_times(Pd))
+ assert generators[0].power(times[0]) == Pmax
@generation.test
def power_minimum():
@@ -43,8 +42,8 @@ def power_minimum():
make_cheap_gen(),
make_expensive_gen(Pmin=Pmin)
]
- solve_problem(generators,**make_loads_times(Pd))
- assert generators[1].power(singletime[0]) == Pmin
+ power_system,times=solve_problem(generators,**make_loads_times(Pd))
+ assert generators[1].power(times[0]) == Pmin
@generation.test
def ramp_up():
@@ -60,6 +59,7 @@ def ramp_up():
]
initial = [{'P':250},{'P':250}]
_,times=solve_problem(generators,gen_init=initial,**make_loads_times(Pdt=[250,350]))
+ print generators[1]._parent_problem()
assert generators[0].power(times[1]) - generators[0].power(times[0]) == ramp_limit
@generation.test
@@ -94,7 +94,7 @@ def ramp_up_initial():
initial = [{'P':250},{'P':250}]
_,times=solve_problem(generators,gen_init=initial,**make_loads_times(Pdt=[350,350]))
- ramp_rate = generators[0].power(times[0]) - generators[0].power(times.initialTime)
+ ramp_rate = generators[0].power(times[0]) - generators[0].initial_power
assert ramp_rate == ramp_limit
@@ -112,7 +112,7 @@ def ramp_down_initial():
initial = [{'P':250},{'P':250}]
_,times=solve_problem(generators,gen_init=initial,**make_loads_times(Pdt=[300,300]))
- ramp_rate = generators[1].power(times[0]) - generators[1].power(times.initialTime)
+ ramp_rate = generators[1].power(times[0]) - generators[1].initial_power
assert ramp_rate == ramp_limit
9 minpower/tests/solvers.py
View
@@ -11,12 +11,11 @@
logging.basicConfig( level=logging.INFO, format='%(levelname)s: %(message)s')
tracker=ClassTracker()
-for cls in [pyomo.ConcreteModel,pyomo.Var,pyomo.base.var._VarElement,
- pyomo.Constraint,optimization.Problem]:
+for cls in [pyomo.ConcreteModel,pyomo.Var,pyomo.base.var._VarElement,pyomo.Constraint,optimization.OptimizationProblem]:
tracker.track_class(cls)
def simple_problem():
- prob=optimization.newProblem()
+ prob=optimization.OptimizationProblem()
tracker.create_snapshot('prob. init')
x= optimization.new_variable('x',low=0,high=3)
y= optimization.new_variable('y',low=0,high=1)
@@ -31,9 +30,9 @@ def simple_problem():
def test_one_solver(solver_name):
prob=simple_problem()
- prob.solve(solver=solver_name)
+ prob.solve(solver=solver_name,get_duals=False)
tracker.create_snapshot('prob. solved')
- status=prob.status
+ status=prob.solved
del prob
tracker.create_snapshot('prob. deleted')
if solver_name=='glpk':
Please sign in to comment.
Something went wrong with that request. Please try again.