1# PuLP : Python LP Modeler 2 3# Copyright (c) 2002-2005, Jean-Sebastien Roy (js@jeannot.org) 4# Modifications Copyright (c) 2007- Stuart Anthony Mitchell (s.mitchell@auckland.ac.nz) 5# $Id:constants.py 1791 2008-04-23 22:54:34Z smit023 $ 6 7# Permission is hereby granted, free of charge, to any person obtaining a 8# copy of this software and associated documentation files (the 9# "Software"), to deal in the Software without restriction, including 10# without limitation the rights to use, copy, modify, merge, publish, 11# distribute, sublicense, and/or sell copies of the Software, and to 12# permit persons to whom the Software is furnished to do so, subject to 13# the following conditions: 14 15# The above copyright notice and this permission notice shall be included 16# in all copies or substantial portions of the Software. 17 18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.""" 25 26""" 27This file contains the constant definitions for PuLP 28Note that hopefully these will be changed into something more pythonic 29""" 30VERSION = "2.6.0" 31EPS = 1e-7 32 33# variable categories 34LpContinuous = "Continuous" 35LpInteger = "Integer" 36LpBinary = "Binary" 37LpCategories = {LpContinuous: "Continuous", LpInteger: "Integer", LpBinary: "Binary"} 38 39# objective sense 40LpMinimize = 1 41LpMaximize = -1 42LpSenses = {LpMaximize: "Maximize", LpMinimize: "Minimize"} 43 44# problem status 45LpStatusNotSolved = 0 46LpStatusOptimal = 1 47LpStatusInfeasible = -1 48LpStatusUnbounded = -2 49LpStatusUndefined = -3 50LpStatus = { 51 LpStatusNotSolved: "Not Solved", 52 LpStatusOptimal: "Optimal", 53 LpStatusInfeasible: "Infeasible", 54 LpStatusUnbounded: "Unbounded", 55 LpStatusUndefined: "Undefined", 56} 57 58# solution status 59LpSolutionNoSolutionFound = 0 60LpSolutionOptimal = 1 61LpSolutionIntegerFeasible = 2 62LpSolutionInfeasible = -1 63LpSolutionUnbounded = -2 64LpSolution = { 65 LpSolutionNoSolutionFound: "No Solution Found", 66 LpSolutionOptimal: "Optimal Solution Found", 67 LpSolutionIntegerFeasible: "Solution Found", 68 LpSolutionInfeasible: "No Solution Exists", 69 LpSolutionUnbounded: "Solution is Unbounded", 70} 71LpStatusToSolution = { 72 LpStatusNotSolved: LpSolutionInfeasible, 73 LpStatusOptimal: LpSolutionOptimal, 74 LpStatusInfeasible: LpSolutionInfeasible, 75 LpStatusUnbounded: LpSolutionUnbounded, 76 LpStatusUndefined: LpSolutionInfeasible, 77} 78 79# constraint sense 80LpConstraintLE = -1 81LpConstraintEQ = 0 82LpConstraintGE = 1 83LpConstraintTypeToMps = {LpConstraintLE: "L", LpConstraintEQ: "E", LpConstraintGE: "G"} 84LpConstraintSenses = {LpConstraintEQ: "=", LpConstraintLE: "<=", LpConstraintGE: ">="} 85# LP line size 86LpCplexLPLineSize = 78 87 88 89def isiterable(obj): 90 try: 91 obj = iter(obj) 92 except: 93 return False 94 else: 95 return True 96 97 98class PulpError(Exception): 99 """ 100 Pulp Exception Class 101 """ 102 103 pass 104