# Path: ipet/Key.py
# CONTEXT_LOGFILE = 1  # the log file of a solver which most readers are reading from
# CONTEXT_ERRFILE = 2  # the error file of a solver
# CONTEXT_SETFILE = 3  # the settings file used for solving
# CONTEXT_TRACEFILE = 5
# CONTEXT_METAFILE = 0  # the metadata
#     MINIMIZE = 1
#     MAXIMIZE = -1
# class SolverStatusCodes:
# class ProblemStatusCodes:
# class ObjectiveSenseCode:
#     def getBestStatus(*args):
#     def getWorstStatus(*args):
# def solverToProblemStatusCode(solverstatus : int) -> str:
# 
# Path: ipet/misc/misc.py
# FLOAT_INFINITY = 1e20
# FLOAT_LARGE = 1e15
# DEFAULT_MIN_GEOM_MEAN = 1.0
#     FLOAT_INFINITY = infinity
# def sortingKeyContext(context):
# def filenameGetContext(filename):
# def getWordAtIndex(line : str, index : int) -> str:
# def getNumberAtIndex(line : str, index : int) -> str:
# def getSoluFileProbName(probname):
# def floatPrint(number, digitsbef=16, digitsafter=9, dispchar='g'):
# def getTexName(name):
# def getCplexGap(value, referencevalue):
# def getGap(value : float, referencevalue : float, useCplexGap : bool=False) -> float:
# def listGetArithmeticMean(listofnumbers):
# def iqr(listofnumbers):
# def lQuart(listofnumbers):
# def uQuart(listofnumbers):
# def shmean(listofnumbers, shiftby=10.0):
# def gemean(listofnumbers, mingeommean=DEFAULT_MIN_GEOM_MEAN):
# def listGetGeomMean(listofnumbers, mingeommean=DEFAULT_MIN_GEOM_MEAN):
# def listGetShiftedGeometricMean(listofnumbers, shiftby=10.0):
# def getVariabilityScore(listofnumbers):
# def isInfinite(value : float) -> bool:
# def getInfinity() -> float:
# def setInfinity(infinity : float):
# def cutString(string, char='_', maxlength=-1):
# def listGetMinColWidth(listofitems):
# def strConcat(strings : list) -> str:
# def meanOrConcat(l : list):
# def saveAsXML(nodeobject, filename : str) -> None:
# def convertTimeStamp(timestamp : float) -> str:


import re
import os
import logging
from ipet import Key
from ipet.misc import misc
from operator import itemgetter
from builtins import int, str
from numpy import char
    primalboundhistory_exp = re.compile('^\s+time\s+\| .* \|\s+primalbound\s+\|\s+gap')
    heurdispcharexp = re.compile('^[^ \d]')
    """ all lines starting with a non-whitespace and non-digit character """

    shorttablecheckexp = re.compile('s\|')
    firstsolexp = re.compile('^  First Solution   :')

    # variables needed for dual bound history
    regular_exp = re.compile('\|')  # compile the regular expression to speed up reader

    solverstatusmap = {
        "no problem exists" : Key.SolverStatusCodes.Readerror,
        "SCIP Status        : problem is solved \[optimal solution found\]":Key.SolverStatusCodes.Optimal,
        "SCIP Status        : problem is solved \[infeasible\]": Key.SolverStatusCodes.Infeasible,
        "SCIP Status        : problem is solved \[infeasible or unbounded\]": Key.SolverStatusCodes.InfOrUnbounded,
        "SCIP Status        : solving was interrupted \[time limit reached\]" : Key.SolverStatusCodes.TimeLimit,
        "SCIP Status        : solving was interrupted \[memory limit reached\]" : Key.SolverStatusCodes.MemoryLimit,
        "SCIP Status        : solving was interrupted \[node limit reached\]" : Key.SolverStatusCodes.NodeLimit,
        "SCIP Status        : solving was interrupted \[gap limit reached\]" : Key.SolverStatusCodes.GapLimit,
        "SCIP Status        : solving was interrupted" : Key.SolverStatusCodes.Interrupted,
    }

    def __init__(self, **kw):
        super(SCIPSolver, self).__init__(**kw)

    def reset(self):
        """ reset stored data
        """
        Solver.reset(self)
        # variables needed for dual bound history

# Path: ipet/Key.py
# CONTEXT_LOGFILE = 1  # the log file of a solver which most readers are reading from
# CONTEXT_ERRFILE = 2  # the error file of a solver
# CONTEXT_SETFILE = 3  # the settings file used for solving
# CONTEXT_TRACEFILE = 5
# CONTEXT_METAFILE = 0  # the metadata
#     MINIMIZE = 1
#     MAXIMIZE = -1
# class SolverStatusCodes:
# class ProblemStatusCodes:
# class ObjectiveSenseCode:
#     def getBestStatus(*args):
#     def getWorstStatus(*args):
# def solverToProblemStatusCode(solverstatus : int) -> str:
# 
# Path: ipet/misc/misc.py
# FLOAT_INFINITY = 1e20
# FLOAT_LARGE = 1e15
# DEFAULT_MIN_GEOM_MEAN = 1.0
#     FLOAT_INFINITY = infinity
# def sortingKeyContext(context):
# def filenameGetContext(filename):
# def getWordAtIndex(line : str, index : int) -> str:
# def getNumberAtIndex(line : str, index : int) -> str:
# def getSoluFileProbName(probname):
# def floatPrint(number, digitsbef=16, digitsafter=9, dispchar='g'):
# def getTexName(name):
# def getCplexGap(value, referencevalue):
# def getGap(value : float, referencevalue : float, useCplexGap : bool=False) -> float:
# def listGetArithmeticMean(listofnumbers):
# def iqr(listofnumbers):
# def lQuart(listofnumbers):
# def uQuart(listofnumbers):
# def shmean(listofnumbers, shiftby=10.0):
# def gemean(listofnumbers, mingeommean=DEFAULT_MIN_GEOM_MEAN):
# def listGetGeomMean(listofnumbers, mingeommean=DEFAULT_MIN_GEOM_MEAN):
# def listGetShiftedGeometricMean(listofnumbers, shiftby=10.0):
# def getVariabilityScore(listofnumbers):
# def isInfinite(value : float) -> bool:
# def getInfinity() -> float:
# def setInfinity(infinity : float):
# def cutString(string, char='_', maxlength=-1):
# def listGetMinColWidth(listofitems):
# def strConcat(strings : list) -> str:
# def meanOrConcat(l : list):
# def saveAsXML(nodeobject, filename : str) -> None:
# def convertTimeStamp(timestamp : float) -> str:


# Path: ipet/parsing/Solver.py
import re
import os
import logging
from ipet import Key
from ipet.misc import misc
from operator import itemgetter
from builtins import int, str
from numpy import char

    primalboundhistory_exp = re.compile('^\s+time\s+\| .* \|\s+primalbound\s+\|\s+gap')
    heurdispcharexp = re.compile('^[^ \d]')
    """ all lines starting with a non-whitespace and non-digit character """

    shorttablecheckexp = re.compile('s\|')
    firstsolexp = re.compile('^  First Solution   :')

    # variables needed for dual bound history
    regular_exp = re.compile('\|')  # compile the regular expression to speed up reader

    solverstatusmap = {
        "no problem exists" : Key.SolverStatusCodes.Readerror,
        "SCIP Status        : problem is solved \[optimal solution found\]":Key.SolverStatusCodes.Optimal,
        "SCIP Status        : problem is solved \[infeasible\]": Key.SolverStatusCodes.Infeasible,
        "SCIP Status        : problem is solved \[infeasible or unbounded\]": Key.SolverStatusCodes.InfOrUnbounded,
        "SCIP Status        : solving was interrupted \[time limit reached\]" : Key.SolverStatusCodes.TimeLimit,
        "SCIP Status        : solving was interrupted \[memory limit reached\]" : Key.SolverStatusCodes.MemoryLimit,
        "SCIP Status        : solving was interrupted \[node limit reached\]" : Key.SolverStatusCodes.NodeLimit,
        "SCIP Status        : solving was interrupted \[gap limit reached\]" : Key.SolverStatusCodes.GapLimit,
        "SCIP Status        : solving was interrupted" : Key.SolverStatusCodes.Interrupted,
    }

    def __init__(self, **kw):
        super(SCIPSolver, self).__init__(**kw)

    def reset(self):
        """ reset stored data
        """
        Solver.reset(self)
        # variables needed for dual bound history

        self.lastdualbound = misc.FLOAT_INFINITY