def main(solver=config.user_config.solver): logging.basicConfig(level=logging.CRITICAL, format='%(levelname)s: %(message)s') from minpower import solve dirNm=splitFilename(__file__)[0] if dirNm=='': dirNm='.' excludeL=[] for fileNm in os.listdir(dirNm): if fileNm in excludeL: continue testDir = joindir(dirNm, fileNm) if not os.path.isdir(testDir): continue print 'testing: ',fileNm wipeTestSlate(testDir) fResults=open(joindir(testDir,'results.txt'),'w+') fError=open(joindir(testDir,'error.txt'),'w+') sys.stdout=fResults #switch output to results file if hasPyscript(testDir): sys.stdout = sys.__stdout__ #switch back to standard outputting os.system('python {s}'.format(s=hasPyscript(testDir)[0])) else: try: user_config.scenarios = 2 solve.solve_problem(testDir) sys.stdout = sys.__stdout__ #switch back to standard outputting fError.close() os.remove(joindir(testDir,'error.txt')) except: #write the error to file exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_tb(exc_traceback, file=fError ) traceback.print_exception(exc_type, exc_value, exc_traceback, file=fError) sys.stdout = sys.__stdout__ #switch back to standard outputting print '\t had error' #note that this dir produced error else: sys.stdout = sys.__stdout__ #switch back to standard outputting
def leak_on_stochastic_reset(): solve.solve_problem(datadir='./uc-stochastic', shell = False, csv = False, hours_commitment = 24, hours_commitment_overlap = 12, get_duals = False, Nscenarios = None, ) test_counts = get_counts('uc-stochastic') assert sum(test_counts.values()) == 0
def test(resultsfile='out.txt', logfile='out.log'): sys.stdout = open(resultsfile, 'w+') solve.solve_problem( datadir='/home/adam/ercot-data/ercot-2010-test-system/', shell=True, problemfile=False, visualization=False, csv=False, solver='cplex', num_breakpoints=10, hours_commitment=24, hours_commitment_overlap=12, get_duals=False, logging_file=logfile, solution_file=False)
def test(resultsfile='out.txt', logfile='out.log'): sys.stdout = open(resultsfile, 'w+') solve.solve_problem( datadir='/home/adam/ercot-data/ercot-2010-test-system/', shell=True, problemfile=False, visualization=False, csv=False, solver='cplex', num_breakpoints=10, hours_commitment=24, hours_commitment_overlap=12, get_duals=False, logging_file=logfile, solution_file=False )