code
stringlengths
1
1.72M
language
stringclasses
1 value
""" Copyright (c) 2003-2007 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import datetime import struct import time import sys import os relativedelta = None pa...
Python
""" Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import itertools import datetime import calendar import thread import sys __all__ = ["...
Python
""" Copyright (c) 2003-2007 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import datetime __all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTE...
Python
""" Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" __version__ = "1.5"
Python
""" Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ from dateutil.tz import tzfile from tarfile import TarFile import os __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" __all__ = ["setca...
Python
# This code was originally contributed by Jeffrey Harris. import datetime import struct import _winreg __author__ = "Jeffrey Harris & Gustavo Niemeyer <gustavo@niemeyer.net>" __all__ = ["tzwin", "tzwinlocal"] ONEWEEK = datetime.timedelta(7) TZKEYNAMENT = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" TZ...
Python
from _Book import _Book class Book(_Book): pass # Custom logic goes here.
Python
''' Module which brings history information about files from Mercurial. @author: Rodrigo Damazio ''' import re import subprocess REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*') def _GetOutputLines(args): ''' Runs an external process and returns its output as a list of lines. @param args: the argume...
Python
#!/usr/bin/python ''' Entry point for My Tracks i18n tool. @author: Rodrigo Damazio ''' import mytracks.files import mytracks.translate import mytracks.validate import sys def Usage(): print 'Usage: %s <command> [<language> ...]\n' % sys.argv[0] print 'Commands are:' print ' cleanup' print ' translate' p...
Python
''' Module which prompts the user for translations and saves them. TODO: implement @author: Rodrigo Damazio ''' class Translator(object): ''' classdocs ''' def __init__(self, language): ''' Constructor ''' self._language = language def Translate(self, string_names): print string_names
Python
''' Module which compares languague files to the master file and detects issues. @author: Rodrigo Damazio ''' import os from mytracks.parser import StringsParser import mytracks.history class Validator(object): def __init__(self, languages): ''' Builds a strings file validator. Params: @para...
Python
''' Module for dealing with resource files (but not their contents). @author: Rodrigo Damazio ''' import os.path from glob import glob import re MYTRACKS_RES_DIR = 'MyTracks/res' ANDROID_MASTER_VALUES = 'values' ANDROID_VALUES_MASK = 'values-*' def GetMyTracksDir(): ''' Returns the directory in which the MyTrac...
Python
''' Module which parses a string XML file. @author: Rodrigo Damazio ''' from xml.parsers.expat import ParserCreate import re #import xml.etree.ElementTree as ET class StringsParser(object): ''' Parser for string XML files. This object is not thread-safe and should be used for parsing a single file at a time...
Python
#!/bin/env python import xml.dom.minidom as dom import sys import struct WEAP_NUM = 780 struct_fmt = "<H BBHBBBB 8B8B8b8b8b8b8H bbBBBB" def pack_weapon(dict): l = [] l.append(dict['drain']) l.append(dict['shotRepeat']) l.append(dict['multi']) l.append(dict['weapAni']) l.append(dict['max']) l.append(dict['tx...
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
#!/usr/bin/env python """ tesshelper.py -- Utility operations to compare, report stats, and copy public headers for tesseract 3.0x VS2008 Project $RCSfile: tesshelper.py,v $ $Revision: 7ca575b377aa $ $Date: 2012/03/07 17:26:31 $ """ r""" Requires: python 2.7 or greater: activestate.co...
Python
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright 2012 Zdenko Podobný # Author: Zdenko Podobný # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LIC...
Python
#!/usr/bin/env python import gzip, sys, threading import crawle class SaveURLHandler(crawle.Handler): """This handler simply saves all pages. into a gziped file. Any reponses with status other than 200 is placed back on the queue. This example also demonstrates the importance of synchronization as mul...
Python
#!/usr/bin/env python import getpass, re, sys, threading import crawle class TwitterHandler(crawle.Handler): """This is an example of doing authentication with CRAWL-E. It must first be noted that twitter's robots.txt file disallows crawling thus proceed at your own risk. """ TWITTER_SESS_RE = re...
Python
#!/usr/bin/env python from distutils.core import setup from crawle import VERSION setup(name='CRAWL-E', version=VERSION, description='Highly distributed web crawling framework', author='Bryce Boe', author_email='bboe (_at_) cs.ucsb.edu', url='http://code.google.com/p/crawl-e', py_mo...
Python
"""CRAWL-E is a highly distributed web crawling framework.""" import Queue, cStringIO, gzip, httplib, logging, mimetypes, resource, socket import sys, subprocess, threading, time, urllib, urlparse VERSION = '0.6.3' HEADER_DEFAULTS = {'Accept':'*/*', 'Accept-Language':'en-us,en;q=0.8', 'User-Agent':...
Python
''' Module which brings history information about files from Mercurial. @author: Rodrigo Damazio ''' import re import subprocess REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*') def _GetOutputLines(args): ''' Runs an external process and returns its output as a list of lines. @param args: the argume...
Python
#!/usr/bin/python ''' Entry point for My Tracks i18n tool. @author: Rodrigo Damazio ''' import mytracks.files import mytracks.translate import mytracks.validate import sys def Usage(): print 'Usage: %s <command> [<language> ...]\n' % sys.argv[0] print 'Commands are:' print ' cleanup' print ' translate' p...
Python
''' Module which prompts the user for translations and saves them. TODO: implement @author: Rodrigo Damazio ''' class Translator(object): ''' classdocs ''' def __init__(self, language): ''' Constructor ''' self._language = language def Translate(self, string_names): print string_names
Python
''' Module which compares languague files to the master file and detects issues. @author: Rodrigo Damazio ''' import os from mytracks.parser import StringsParser import mytracks.history class Validator(object): def __init__(self, languages): ''' Builds a strings file validator. Params: @para...
Python
''' Module for dealing with resource files (but not their contents). @author: Rodrigo Damazio ''' import os.path from glob import glob import re MYTRACKS_RES_DIR = 'MyTracks/res' ANDROID_MASTER_VALUES = 'values' ANDROID_VALUES_MASK = 'values-*' def GetMyTracksDir(): ''' Returns the directory in which the MyTrac...
Python
''' Module which parses a string XML file. @author: Rodrigo Damazio ''' from xml.parsers.expat import ParserCreate import re #import xml.etree.ElementTree as ET class StringsParser(object): ''' Parser for string XML files. This object is not thread-safe and should be used for parsing a single file at a time...
Python
import socket import urllib __author__="uli" __date__ ="$12.01.2009 16:48:52$" if __name__ == "__main__": url = raw_input("URL: ") count = int(raw_input("Count: ")) traffic = 0 #Traffic in bytes for i in xrange(count): print "Starting %ith download" % (i+1) socket = urllib.urlopen(url)...
Python
# -*- coding: UTF-8 -*- # # gameOver.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ...
Python
# -*- coding: UTF-8 -*- # # menu.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ...
Python
# -*- coding: UTF-8 -*- # # intro.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ...
Python
# -*- coding: UTF-8 -*- # # funciones.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ...
Python
# -*- coding: UTF-8 -*- # # nivel_1.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ...
Python
# -*- coding: UTF-8 -*- # # puntajes.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ...
Python
# -*- coding: UTF-8 -*- # # objetos.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ...
Python
# -*- coding: UTF-8 -*- # # creditos.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ...
Python
#!/usr/bin/env python import sys import string if len( sys.argv ) == 1 : for asc_line in sys.stdin.readlines(): mpw_line = string.replace(asc_line, "\\xA5", "\245") mpw_line = string.replace(mpw_line, "\\xB6", "\266") mpw_line = string.replace(mpw_line, "\\xC4", "\304") mpw_line = string.replace(mpw_...
Python
#!/usr/bin/env python import sys import string if len( sys.argv ) == 1 : for asc_line in sys.stdin.readlines(): mpw_line = string.replace(asc_line, "\\xA5", "\245") mpw_line = string.replace(mpw_line, "\\xB6", "\266") mpw_line = string.replace(mpw_line, "\\xC4", "\304") mpw_line = string.replace(mpw_...
Python
#!/usr/bin/env python # # # FreeType 2 glyph name builder # # Copyright 1996-2000, 2003, 2005, 2007, 2008, 2011 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LI...
Python
# compute arctangent table for CORDIC computations in fttrigon.c import sys, math #units = 64*65536.0 # don't change !! units = 256 scale = units/math.pi shrink = 1.0 comma = "" def calc_val( x ): global units, shrink angle = math.atan(x) shrink = shrink * math.cos(angle) return angle/math.pi *...
Python
#!/usr/bin/env python # # Check trace components in FreeType 2 source. # Author: suzuki toshiya, 2009 # # This code is explicitly into the public domain. import sys import os import re SRC_FILE_LIST = [] USED_COMPONENT = {} KNOWN_COMPONENT = {} SRC_FILE_DIRS = [ "src" ] TRACE_DEF_FILES = [ "include/freetype/in...
Python
#!/usr/bin/env python # # # FreeType 2 glyph name builder # # Copyright 1996-2000, 2003, 2005, 2007, 2008, 2011 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LI...
Python
#!/usr/bin/env python # # Check trace components in FreeType 2 source. # Author: suzuki toshiya, 2009 # # This code is explicitly into the public domain. import sys import os import re SRC_FILE_LIST = [] USED_COMPONENT = {} KNOWN_COMPONENT = {} SRC_FILE_DIRS = [ "src" ] TRACE_DEF_FILES = [ "include/freetype/in...
Python
#!/usr/bin/env python # # DocMaker (c) 2002, 2004, 2008 David Turner <david@freetype.org> # # This program is a re-write of the original DocMaker took used # to generate the API Reference of the FreeType font engine # by converting in-source comments into structured HTML. # # This new version is capable of outputting ...
Python
#!/usr/bin/env python # # DocBeauty (c) 2003, 2004, 2008 David Turner <david@freetype.org> # # This program is used to beautify the documentation comments used # in the FreeType 2 public headers. # from sources import * from content import * from utils import * import utils import sys, os, time, string, getopt ...
Python
# Sources (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009 # David Turner <david@freetype.org> # # # this file contains definitions of classes needed to decompose # C sources files into a series of multi-line "blocks". There are # two kinds of blocks: # # - normal blocks, which contain source code or ordinary comment...
Python
# Formatter (c) 2002, 2004, 2007, 2008 David Turner <david@freetype.org> # from sources import * from content import * from utils import * # This is the base Formatter class. Its purpose is to convert # a content processor's data into specific documents (i.e., table of # contents, global index, and individual API...
Python
# ToHTML (c) 2002, 2003, 2005, 2006, 2007, 2008 # David Turner <david@freetype.org> from sources import * from content import * from formatter import * import time # The following defines the HTML header used by all generated pages. html_header_1 = """\ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional/...
Python
#!/usr/bin/env python # # DocMaker (c) 2002, 2004, 2008 David Turner <david@freetype.org> # # This program is a re-write of the original DocMaker took used # to generate the API Reference of the FreeType font engine # by converting in-source comments into structured HTML. # # This new version is capable of outputting ...
Python
# Utils (c) 2002, 2004, 2007, 2008 David Turner <david@freetype.org> # import string, sys, os, glob # current output directory # output_dir = None # This function is used to sort the index. It is a simple lexicographical # sort, except that it places capital letters before lowercase ones. # def index_sort( s1, ...
Python
# Content (c) 2002, 2004, 2006, 2007, 2008, 2009 # David Turner <david@freetype.org> # # This file contains routines used to parse the content of documentation # comment blocks and build more structured objects out of them. # from sources import * from utils import * import string, re # this regular expression...
Python
#!/usr/bin/env python # # DocBeauty (c) 2003, 2004, 2008 David Turner <david@freetype.org> # # This program is used to beautify the documentation comments used # in the FreeType 2 public headers. # from sources import * from content import * from utils import * import utils import sys, os, time, string, getopt ...
Python
# # Stochastic Optimization PS#1 Problem 6a # Nurse Staffing # # Reference Format: Vehicle Routing Problem # # Imports # from coopr.pyomo import * #from coopr.opt.base import solver # # Model # model = AbstractModel() # # Parameters # # Define sets model.I = Set() # units model.J = Set() # days # Data_determinis...
Python
# # Stochastic Optimization PS#1 Problem 6a # Nurse Staffing # # Reference Format: Vehicle Routing Problem # # Imports # from coopr.pyomo import * #from coopr.opt.base import solver # # Model # model = AbstractModel() # # Parameters # # Define sets model.I = Set() # units model.J = Set() # days # Data_determinis...
Python
import cplex import random import numpy as np from pylab import * from stoch_trnsport_gen import * from cplex.exceptions import CplexError NI = 20 NJ = 20 NW = 20 prob,demand = gen_stoch_trnsport(NI, NJ, NW) prob.solve() I = range(NI) J = range(NJ) O = range(NW) bigm = 0.1 print prob.solution.get_objective_value(), ...
Python
import cplex import random import numpy as np import time from stoch_trnsport_gen import * from cplex.exceptions import CplexError import cplex.callbacks as CPX_CB class MySolve(CPX_CB.SolveCallback): def __call__(self): self.times_called += 1 print "hello" self.solve() # print "Lowe...
Python
from coopr.pyomo import * # # Model # model = AbstractModel() model.I = Set() model.J = Set() model.A = Param(model.J, model.I) model.b = Param(model.J) model.c = Param(model.I) model.p = Param(model.J) #probability for scenarios model.alpha = Param() #required chance model.bigm = Param(model.J) model.X = Var(...
Python
import cplex import random import numpy as np prob = cplex.Cplex() prob.objective.set_sense(prob.objective.sense.minimize) N = 5 M = 10 # Add continuous variables bin_var_name = ["y" + str(i) for i in range(N)] bin_var_type = ["B" for i in range(N)] bin_var_obj = [random.randint(1,10) for i in range(N)] con_var_nam...
Python
import cplex import random import numpy as np import time from pylab import * from stoch_trnsport_gen import * from cplex.exceptions import CplexError import mpl_toolkits.mplot3d.axes3d as p3 NI = 50 NJ = 50 NW = 500 I = range(NI) J = range(NJ) O = range(NW) prob,demand = gen_stoch_trnsport(NI, NJ, NW, eps=0.2) #prob...
Python
import random fname = 'chance_mod.dat' f = open(fname, 'w') random.seed(1000) f.write('\n') #f.write('hello, world' + '\n') #f.write('second line') def write_set(name, data, file): f = file size = len(data) f.write('set' + ' ' + name + ' ' + ':='+' ') for i in range(size): f.write(data[i] + ' '...
Python
import cplex import random import numpy as np import time from pylab import * from stoch_trnsport_gen import * from cplex.exceptions import CplexError import mpl_toolkits.mplot3d.axes3d as p3 NI = 20 NJ = 20 NW = 20 I = range(NI) J = range(NJ) O = range(NW) prob,demand = gen_stoch_trnsport(NI, NJ, NW, eps=0.5) prob.s...
Python
""" This script is used for benchmarking the time takes for different formulations includes IP, SIP, IP(M*) """ from time import time from ccfs.fscplex import fscplex f = open("../output/bench_formulations.txt", 'w') header = "%4s %4s" % ('NI', 'NS') header += "%10s %10s %10s" % ("IP_v", "SIP_v", "IP(M*)_v") header +...
Python
""" This script is used for benchmarking the time takes for different formulations includes IP, SIP, IP(M*) """ from time import time from ccfs.fscplex import fscplex f = open("../output/bench_formulations.txt", 'w') header = "%4s %4s" % ('NI', 'NS') header += "%10s %10s %10s" % ("IP_v", "SIP_v", "IP(M*)_v") header +...
Python
from ccfs.fscplex import fscplex f = open("../output/bench_singlebigm.txt", 'w') header = "%4s %4s" % ('NI', 'NS') header += "%10s %10s %10s" % ("BigM", "Obj", "Nodes") #header += "%10s %10s" % ('t_stre', 't_bigm') header += "\n" f.write(header) NI = 20 NS = 20 fc = fscplex() fc.generate_instance(NI, NS, eps=0.2) f...
Python
################# # Created 5.5 # Used for benchmarking with range of two bigms ################# from ccfs.fscplex import fscplex fc = fscplex() fc.generate_instance(NI = 2, NS=100, eps=0.2) fc.parameters.read_file("../../param/stofac.prm") fc.write("fc.lp") for i in range(20): val1 = i * 0.1 for j in range(...
Python
import time import cplex import cplex.callbacks as CPX_CB import random import numpy as np from ccfs.instances import genfs from ccfs.callbacks import CheckBounds def bench_checkresolve(NI = 40, NS=35): step = 0.1 flag = [0] #mutable I = range(NI) S = range(NS) x_name = ["x" + '_' + str(i) for i in...
Python
""" This is the main benchmark script for the check and resolve procedure. Created: May 7th First version May 7th. Things begin to work as expected. Todo: Output result on instance from 10 to 100 with or without heuristics Author: Derek Zhang """ import cplex import random import numpy as np import sys from time imp...
Python
""" This script contains all callback functions that might be called during the procedure Created: May 1st? Version 1.0: May 7th Author: Derek Zhang Todo: - Optimality condition improvement - Code optimization and organization """ import cplex.callbacks as CPX_CB class MySolve(CPX_CB.SolveCallback): def __call_...
Python
""" The main script that contains subclass of cplex class. All customized featured are to be added incrementally Created: May 1st? Version 1.0 May 7th Author Derek Zhang """ import cplex import random from math import floor from heapq import nlargest class fscplex(cplex.Cplex): def __init__(self): cplex...
Python
import cplex from time import time from fs import fs from callback import check_bigm_at_incumbent from callback import check_bigm_at_branch SZ = 40 f = open("results.txt","w") c = fs() c.parameters.read_file("../../param/stofac.prm") c.gen_inst(NI = 2, NS = 50, RLB = 40, seed = 100) c.solve() f.write(str(c.solution.g...
Python
from pylab import * from time import time from fs import fs import numpy as np import mpl_toolkits.mplot3d.axes3d as p3 NI = 2 NS = 40 RLB = 20 SZ = 30 c = fs() c.parameters.read_file("../../param/stofac.prm") c.gen_inst(NI = NI, NS = NS, RLB = RLB, seed = 100) Z = np.zeros((SZ, SZ)) c.solve() print c.solution.get_obj...
Python
from time import time from fs import fs org_times = [] str_times = [] org_vals = [] str_vals = [] org_nodes = [] str_nodes = [] for i in range(10): c = fs() c.parameters.read_file("../../param/stofac.prm") c.gen_inst(NI = 5, NS = 5, seed = i*20) c.init_lists() t0 = time() c.solve() t1 = ti...
Python
import cplex import random class fs(cplex.Cplex): def __init__(self): cplex.Cplex.__init__(self) #has to be called to activa self.NI = 1; self.NS = 1 self.I = range(self.NI); self.J = range(self.NS) self.x_name = []; self.y_name = []; self.rhs = [] self.num_M = 0; self.M_row...
Python
import cplex.callbacks as CPX_CB class check_bigm_at_incumbent(CPX_CB.IncumbentCallback): def __call__(self): print "\n" if self.fc.flag == 1: #self.times_called += 1 x_val = self.get_values(self.fc.x_name) y_val = self.get_values(self.fc.y_name) slac...
Python
import cplex import random import numpy as np #from instances import fscplex from ccfs.fscplex import fscplex from ccfs.callbacks import CheckBigM from ccfs.callbacks import Reject # Generate instances and read in parameters fc = fscplex() fc.generate_instance(NI = 15, NS=15, eps=0.2, Ordered=False) fc.parameters.read_...
Python
import cplex import random import sys from time import time f1 = sys.argv[1] f2 = sys.argv[2] c = cplex.Cplex() c.parameters.read_file("../../param/stofac.prm") c.read(f1) t0 = time() c.solve() t1 = time() print "time is ", t1 - t0 print "solution is", c.solution.get_objective_value() print "nodes is ", c.solution...
Python
#This is a script that used on the command line to # run .lp files # The advantage is to be able to change the parameters # directly from .lp file import cplex c=cplex.Cplex() c.read("ccfs_new.lp") c.parameters.read_file("../../param/stofac.prm") c.solve() print c.solution.get_objective_value() print c.solution.get_...
Python
import cplex import cplex.callbacks as CPX_CB import random import numpy as np #from instances import fscplex from fscplex import fscplex from callbacks import CheckBounds NI = 30 NS = 30 step = 0.1 # Generate instances and read in parameters fc = fscplex() fc.generate_instance(NI, NS) fc.write("fc_org.lp") fc.param...
Python
# Farmer: rent out version has a singleton root node var # note: this will minimize # # Imports # from coopr.pyomo import * # # Model # model = AbstractModel() # # Parameters # model.CROPS = Set() model.TOTAL_ACREAGE = Param(within=PositiveReals) model.PriceQuota = Param(model.CROPS, within=PositiveReals) model...
Python
# Imports from coopr.pyomo import * from coopr.opt import SolverFactory from ReferenceModel import model import numpy # Solve EV for given number of sample realizations with fixed X at X_EV numSamples = 500 numX=5 optVal=numpy.array([0 for i in range(numSamples)]) # Choose the solver opt = SolverFactory('gurobi') # ...
Python
# Imports from coopr.pyomo import * from coopr.opt import SolverFactory from ReferenceModel import model import numpy # Solve WS for given number of sample realizations with fixed X at X_WS numSamples = 500 numX = 5 optVal = numpy.array([0 for i in range(numSamples)]) # Choose the solver opt = SolverFactory('gurobi')...
Python
#This file estimate EV # Imports from coopr.pyomo import * from coopr.opt import SolverFactory import numpy from ReferenceModelBase import model # Solve WS for given number of sample realizations numSamples=1 numX = 5 optVal = numpy.array ([0 for i in range(numSamples)]) optSoln = numpy.array([[0 for...
Python
#This file estimate EV # Imports from coopr.pyomo import * from coopr.opt import SolverFactory from ReferenceModel import model import numpy # Solve WS for given number of sample realizations numSamples=20 numX = 5 optVal = numpy.array ([0 for i in range(numSamples)]) optSoln = numpy.array([[0 for i in range(numSam...
Python
# Vehicle Routing Problem # Imports from coopr.pyomo import * from coopr.opt import SolverFactory # Model model = AbstractModel() # Sets model.I = Set() #node model.J = Set() #node model.S = Set() #source node model.D = Set() #demand node # Data model.Arc = Param(model.I, model.J) #arc available m...
Python
# Imports from coopr.pyomo import * from coopr.opt import SolverFactory import ReferenceModelBase import numpy """ # Model model = AbstractModel() # Sets model.I = Set() #node model.J = Set() #node model.S = Set() #source node model.D = Set() #demand node # Data model.Arc = Param(model.I, model.J) ...
Python
#! /usr/bin/python import glob import shutil import sys import subprocess import os def cpfile(src, target): sys.stdout.write("Copying %s to %s\n" % (src, target)) shutil.copy(src, target) # We only copy the armeabi version of the binary archs = ["armeabi"] for arch in archs: try: os.makedirs("....
Python
#! /usr/bin/python import glob import shutil import sys import subprocess import os def cpfile(src, target): sys.stdout.write("Copying %s to %s\n" % (src, target)) shutil.copy(src, target) # We only copy the armeabi version of the binary archs = ["armeabi"] for arch in archs: try: os.makedirs("....
Python
#! /usr/bin/python import glob import shutil import sys import subprocess import os if 'linux' in sys.platform: platform = 'linux' else: platform = 'darwin' toolchain = "%s/android-toolchain" % os.getenv("HOME") openssl_version = "1.0.0k" encfs_version = "1.7.4" def cpfile(src, target): sys.stdout.write...
Python
#!/usr/bin/env python # # Copyright 2006, 2007 Google Inc. All Rights Reserved. # Author: danderson@google.com (David Anderson) # # Script for uploading files to a Google Code project. # # This is intended to be both a useful script for people who want to # streamline project uploads and a reference implementation for ...
Python
# -*- coding: utf-8 -*- from ca import * # Nombre: Claves Candidatas Creator/dor, aka clcncr) # Funcion que toma un conjunto de cierres de atributos y es esquema universal # y devuelve un NUEVO conjunto de claves candidatas. # Requires: # R = esquema universal (Set) # LCA = List. de Cierre atributos (Set of tubples ...
Python
# -*- coding: utf-8 -*- from df import * from ca import * def cierreAtributos (f, eu): """Usando el conjunto de d.f. y el esquema universal construimos el cierre de atributos de cada atributo. Lo representaremos con un TAD que es un par ordenado, donde la primer componente ('a') es el atributo considerad...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # # df.py # # Copyright 2009 Drasky Vanderhoff <drasky@drasky-laptop> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Softw...
Python
# -*- coding: utf-8 -*- # # FC.py # # Copyright 2009 Drasky Vanderhoff <drasky.vanderhoff@gmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
Python
# -*- coding: utf-8 -*- from attrs import * from df import * from clcncr import getCCC from fprima import * from c3fn import calculate3FN from FNBC import calcular_FNBC, chequear_FNBC , chequear_FNBC_df from FC import * def mainProg(): # Para saber si ya se ha calculado la descomposición en FNBC calcFNBC = False ...
Python
# -*- coding: utf-8 -*- from df import * import copy #Vamos a hacer la parte primero del foreach #Esta funcion va a chequear si algun Ri contiene a la dep. func. a->b #LRi = Conjuntos de Ri (sets of sets) #dep = Dependencia funcional a->b (es un tubple (a,b)) # Returns: # True si encontramos # False caso contrario d...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # # df.py # # Copyright 2009 Drasky Vanderhoff <drasky@drasky-laptop> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Softw...
Python