<s> from __future__ import print_function <EOL> from __future__ import unicode_literals <EOL> from __future__ import absolute_import <EOL> from __future__ import generators <EOL> import os , sys , inspect , copy <EOL> if - <NUM_LIT:1> != sys . path [ <NUM_LIT:0> ] . find ( '<STR_LIT>' ) : raise Exception ( '<STR_LIT>' ) <EOL> exampleFileDirectory = sys . path [ <NUM_LIT:0> ] [ : sys . path [ <NUM_LIT:0> ] . rfind ( os . sep ) ] <EOL> pyeq2IimportDirectory = os . path . join ( os . path . join ( exampleFileDirectory , '<STR_LIT:..>' ) , '<STR_LIT:..>' ) <EOL> if pyeq2IimportDirectory not in sys . path : <EOL> sys . path . append ( pyeq2IimportDirectory ) <EOL> import pyeq2 <EOL> def UniqueCombinations ( items , n ) : <EOL> if n == <NUM_LIT:0> : <EOL> yield [ ] <EOL> else : <EOL> for i in xrange ( len ( items ) ) : <EOL> for cc in UniqueCombinations ( items [ i + <NUM_LIT:1> : ] , n - <NUM_LIT:1> ) : <EOL> yield [ items [ i ] ] + cc <EOL> def SetParametersAndFit ( inEquation , resultList ) : <EOL> try : <EOL> if len ( inEquation . GetCoefficientDesignators ( ) ) > len ( inEquation . dataCache . allDataCacheDictionary [ '<STR_LIT>' ] ) : <EOL> return <EOL> if inEquation . ShouldDataBeRejected ( inEquation ) : <EOL> return <EOL> inEquation . Solve ( ) <EOL> target = inEquation . CalculateAllDataFittingTarget ( inEquation . solvedCoefficients ) <EOL> if target > <NUM_LIT> : <EOL> return <EOL> except : <EOL> print ( "<STR_LIT>" + inEquation . __class__ . __name__ + '<STR_LIT:\n>' + str ( sys . exc_info ( ) [ <NUM_LIT:0> ] ) + '<STR_LIT:\n>' + str ( sys . exc_info ( ) [ <NUM_LIT:1> ] ) + '<STR_LIT:\n>' ) <EOL> return <EOL> t0 = copy . copy ( inEquation . __module__ ) <EOL> t1 = copy . copy ( inEquation . __class__ . __name__ ) <EOL> t2 = copy . copy ( inEquation . extendedVersionHandler . __class__ . __name__ . split ( '<STR_LIT:_>' ) [ <NUM_LIT:1> ] ) <EOL> t3 = copy . copy ( target ) <EOL> t4 = copy . copy ( inEquation . solvedCoefficients ) <EOL> t5 = copy . copy ( inEquation . polyfunctional3DFlags ) <EOL> t6 = copy . copy ( inEquation . xPolynomialOrder ) <EOL> t7 = copy . copy ( inEquation . yPolynomialOrder ) <EOL> resultList . append ( [ t0 , t1 , t2 , t3 , t4 , t5 , t6 , t7 ] ) <EOL> rawData = '''<STR_LIT>''' <EOL> resultList = [ ] <EOL> fittingTargetText = '<STR_LIT>' <EOL> externalDataCache = pyeq2 . dataCache ( ) <EOL> equation = pyeq2 . Models_3D . Polyfunctional . UserSelectablePolyfunctional ( fittingTargetText ) <EOL> equation . dataCache = externalDataCache <EOL> pyeq2 . dataConvertorService ( ) . ConvertAndSortColumnarASCII ( rawData , equation , False ) <EOL> functionList = [ ] <EOL> for k in range ( len ( equation . polyfunctionalEquationList_X ) ) : <EOL> for l in range ( len ( equation . polyfunctionalEquationList_Y ) ) : <EOL> if [ l , k ] not in functionList : <EOL> functionList . append ( [ k , l ] ) <EOL> maxCombinationCount = <NUM_LIT:2> <EOL> combinationGenerator = UniqueCombinations ( functionList , maxCombinationCount ) <EOL> fitCount = <NUM_LIT:0> <EOL> print ( '<STR_LIT>' ) <EOL> for k in combinationGenerator : <EOL> equation . __init__ ( fittingTargetText ) <EOL> equation . polyfunctional3DFlags = k <EOL> equation . dataCache = externalDataCache <EOL> fitCount += <NUM_LIT:1> <EOL> if fitCount % <NUM_LIT> == <NUM_LIT:0> : <EOL> print ( '<STR_LIT>' + str ( fitCount ) ) <EOL> SetParametersAndFit ( equation , resultList ) <EOL> resultList . sort ( key = lambda item : item [ <NUM_LIT:3> ] ) <EOL> print ( ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( ) <EOL> bestResult = resultList [ <NUM_LIT:0> ] <EOL> moduleName = bestResult [ <NUM_LIT:0> ] <EOL> className = bestResult [ <NUM_LIT:1> ] <EOL> extendedVersionHandlerName = bestResult [ <NUM_LIT:2> ] <EOL> fittingTarget = bestResult [ <NUM_LIT:3> ] <EOL> solvedCoefficients = bestResult [ <NUM_LIT:4> ] <EOL> polyfunctional3DFlags = bestResult [ <NUM_LIT:5> ] <EOL> equation = eval ( moduleName + "<STR_LIT:.>" + className + "<STR_LIT>" + fittingTargetText + "<STR_LIT>" + extendedVersionHandlerName + "<STR_LIT>" + str ( polyfunctional3DFlags ) + "<STR_LIT:)>" ) <EOL> pyeq2 . dataConvertorService ( ) . ConvertAndSortColumnarASCII ( rawData , equation , False ) <EOL> equation . fittingTarget = fittingTargetText <EOL> equation . solvedCoefficients = solvedCoefficients <EOL> equation . dataCache . FindOrCreateAllDataCache ( equation ) <EOL> equation . CalculateModelErrors ( equation . solvedCoefficients , equation . dataCache . allDataCacheDictionary ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' , moduleName + "<STR_LIT:.>" + className ) <EOL> print ( '<STR_LIT>' , equation . fittingTarget + "<STR_LIT::>" , equation . CalculateAllDataFittingTarget ( equation . solvedCoefficients ) ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' , polyfunctional3DFlags ) <EOL> print ( ) <EOL> for i in range ( len ( equation . solvedCoefficients ) ) : <EOL> print ( "<STR_LIT>" + equation . GetCoefficientDesignators ( ) [ i ] + "<STR_LIT>" + str ( equation . solvedCoefficients [ i ] ) ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( pyeq2 . outputSourceCodeService ( ) . GetOutputSourceCodePYTHON ( equation ) ) </s>
