tweak params
This commit is contained in:
parent
e4c8e3f79f
commit
16189ef988
|
@ -30,6 +30,7 @@ library
|
||||||
, MonadRandom
|
, MonadRandom
|
||||||
, mwc-random
|
, mwc-random
|
||||||
, optparse-applicative
|
, optparse-applicative
|
||||||
|
, parallel
|
||||||
, path
|
, path
|
||||||
, pipes
|
, pipes
|
||||||
, primitive
|
, primitive
|
||||||
|
@ -63,6 +64,7 @@ executable haga
|
||||||
, MonadRandom
|
, MonadRandom
|
||||||
, mwc-random
|
, mwc-random
|
||||||
, optparse-applicative
|
, optparse-applicative
|
||||||
|
, parallel
|
||||||
, path
|
, path
|
||||||
, pipes
|
, pipes
|
||||||
, primitive
|
, primitive
|
||||||
|
@ -99,6 +101,7 @@ executable haga-test
|
||||||
, MonadRandom
|
, MonadRandom
|
||||||
, mwc-random
|
, mwc-random
|
||||||
, optparse-applicative
|
, optparse-applicative
|
||||||
|
, parallel
|
||||||
, path
|
, path
|
||||||
, pipes
|
, pipes
|
||||||
, primitive
|
, primitive
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#SBATCH --time=01:30:00
|
#SBATCH --time=06:30:00
|
||||||
#SBATCH --partition=cpu
|
#SBATCH --partition=cpu
|
||||||
#SBATCH --array=0-1
|
#SBATCH --array=0-30
|
||||||
#SBATCH --output=./output/output_run_%j.txt
|
#SBATCH --output=./output/output_run_%j.txt
|
||||||
#SBATCH --error=./output/error_run_%j.txt
|
#SBATCH --error=./output/error_run_%j.txt
|
||||||
#SBATCH --nodelist=oc-compute02
|
#SBATCH --nodelist=oc-compute02
|
||||||
#SBATCH --mem=8G
|
#SBATCH --mem=3G
|
||||||
srun nix develop --command stack --no-nix --system-ghc --no-install-ghc run haga
|
srun nix develop --command stack --no-nix --system-ghc --no-install-ghc run haga
|
||||||
|
|
|
@ -26,7 +26,7 @@ options =
|
||||||
( long "iterations"
|
( long "iterations"
|
||||||
<> short 'i'
|
<> short 'i'
|
||||||
<> metavar "N"
|
<> metavar "N"
|
||||||
<> value 1000
|
<> value 10000
|
||||||
<> help "Number of iterations"
|
<> help "Number of iterations"
|
||||||
)
|
)
|
||||||
<*> option
|
<*> option
|
||||||
|
@ -34,7 +34,7 @@ options =
|
||||||
( long "population-size"
|
( long "population-size"
|
||||||
<> short 'p'
|
<> short 'p'
|
||||||
<> metavar "N"
|
<> metavar "N"
|
||||||
<> value 100
|
<> value 400
|
||||||
<> help "Population size"
|
<> help "Population size"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ main =
|
||||||
nurseryLEE <- shuffledNurseryLEE
|
nurseryLEE <- shuffledNurseryLEE
|
||||||
let env = nurseryLE
|
let env = nurseryLE
|
||||||
let selType = Tournament 3
|
let selType = Tournament 3
|
||||||
let run' = run nurseryLEE env selType 80 (5 / 100) (populationSize opts) (steps (iterations opts))
|
let run' = run nurseryLEE env selType 120 (5 / 100) (populationSize opts) (steps (iterations opts))
|
||||||
pop' <- runEffect (for run' logCsv)
|
pop' <- runEffect (for run' logCsv)
|
||||||
nurseryLEE' <- calc nurseryLEE pop'
|
nurseryLEE' <- calc nurseryLEE pop'
|
||||||
let (res, _) = bests nurseryLEE' 5 pop'
|
let (res, _) = bests nurseryLEE' 5 pop'
|
||||||
|
|
|
@ -74,13 +74,13 @@ nurseryLE =
|
||||||
((Ref.SomeTypeRep (Ref.TypeRep @(Health))), [(fmap show (enumUniform NotRecommendHealth PriorityHealth ))])
|
((Ref.SomeTypeRep (Ref.TypeRep @(Health))), [(fmap show (enumUniform NotRecommendHealth PriorityHealth ))])
|
||||||
],
|
],
|
||||||
targetType = (Ref.SomeTypeRep (Ref.TypeRep @(Parents -> HasNurs -> Form -> Children -> Housing -> Finance -> Social -> Health -> NurseryClass))),
|
targetType = (Ref.SomeTypeRep (Ref.TypeRep @(Parents -> HasNurs -> Form -> Children -> Housing -> Finance -> Social -> Health -> NurseryClass))),
|
||||||
maxDepth = 8,
|
maxDepth = 7,
|
||||||
weights =
|
weights =
|
||||||
ExpressionWeights
|
ExpressionWeights
|
||||||
{ lambdaSpucker = 1,
|
{ lambdaSpucker = 2,
|
||||||
lambdaSchlucker = 1,
|
lambdaSchlucker = 1,
|
||||||
symbol = 30,
|
symbol = 30,
|
||||||
variable = 10,
|
variable = 20,
|
||||||
constant = 5
|
constant = 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,23 +165,19 @@ dset :: LamdaExecutionEnv -> ([(Parents, HasNurs, Form, Children, Housing, Finan
|
||||||
dset lEE = if training lEE then trainingData lEE else testData lEE
|
dset lEE = if training lEE then trainingData lEE else testData lEE
|
||||||
|
|
||||||
evalResults :: LamdaExecutionEnv -> [TypeRequester] -> Hint.InterpreterT IO [(TypeRequester, FittnesRes)]
|
evalResults :: LamdaExecutionEnv -> [TypeRequester] -> Hint.InterpreterT IO [(TypeRequester, FittnesRes)]
|
||||||
evalResults ex trs = mapM (evalResult ex) trs
|
evalResults ex trs = do
|
||||||
|
|
||||||
evalResult :: LamdaExecutionEnv -> TypeRequester -> Hint.InterpreterT IO (TypeRequester, FittnesRes)
|
|
||||||
evalResult ex tr = do
|
|
||||||
Hint.setImports $ (map T.unpack (imports ex)) ++ ["Protolude"]
|
Hint.setImports $ (map T.unpack (imports ex)) ++ ["Protolude"]
|
||||||
Hint.unsafeSetGhcOption "-O2"
|
Hint.unsafeSetGhcOption "-O2"
|
||||||
result <- Hint.interpret (T.unpack (toLambdaExpressionS tr)) (Hint.as :: Parents -> HasNurs -> Form -> Children -> Housing -> Finance -> Social -> Health -> NurseryClass)
|
let arrayOfFunctionText = map toLambdaExpressionS trs
|
||||||
let res = map (\(a, b, c, d, e, f, g, h) -> result a b c d e f g h) (fst (dset ex))
|
let textOfFunctionArray = "[" <> T.intercalate "," arrayOfFunctionText <> "]"
|
||||||
let resAndTarget = (zip (snd (dset ex)) res)
|
result <- Hint.interpret (T.unpack (textOfFunctionArray)) (Hint.as :: [Parents -> HasNurs -> Form -> Children -> Housing -> Finance -> Social -> Health -> NurseryClass])
|
||||||
let acc = (foldr (\ts s -> if ((fst ts) == (snd ts)) then s + 1 else s) 0 resAndTarget) / fromIntegral (length resAndTarget)
|
return $ zipWith (evalResult ex) trs result
|
||||||
let biasSmall = exp ((-(fromIntegral (countTrsR tr))) / 1000) -- 0 (schlecht) bis 1 (gut)
|
|
||||||
let fitness' = meanOfAccuricyPerClass resAndTarget
|
|
||||||
let score = fitness' + (biasSmall - 1)
|
evalResult :: LamdaExecutionEnv -> TypeRequester -> (Parents -> HasNurs -> Form -> Children -> Housing -> Finance -> Social -> Health -> NurseryClass) -> (TypeRequester, FittnesRes)
|
||||||
return
|
evalResult ex tr result = ( tr,
|
||||||
( tr,
|
|
||||||
FittnesRes
|
FittnesRes
|
||||||
{ total = score,
|
{ total = acc * 100 + (biasSmall - 1),
|
||||||
fitnessTotal = fitness',
|
fitnessTotal = fitness',
|
||||||
fitnessMean = meanOfAccuricyPerClass resAndTarget,
|
fitnessMean = meanOfAccuricyPerClass resAndTarget,
|
||||||
fitnessGeoMean = geomeanOfDistributionAccuracy resAndTarget,
|
fitnessGeoMean = geomeanOfDistributionAccuracy resAndTarget,
|
||||||
|
@ -190,6 +186,14 @@ evalResult ex tr = do
|
||||||
totalSize = countTrsR tr
|
totalSize = countTrsR tr
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
where
|
||||||
|
res = map (\(a, b, c, d, e, f, g, h) -> result a b c d e f g h) (fst (dset ex))
|
||||||
|
resAndTarget = (zip (snd (dset ex)) res)
|
||||||
|
acc = (foldr (\ts s -> if ((fst ts) == (snd ts)) then s + 1 else s) 0 resAndTarget) / fromIntegral (length resAndTarget)
|
||||||
|
biasSmall = exp ((-(fromIntegral (countTrsR tr))) / 1000) -- 0 (schlecht) bis 1 (gut)
|
||||||
|
fitness' = meanOfAccuricyPerClass resAndTarget
|
||||||
|
score = fitness' + (biasSmall - 1)
|
||||||
|
|
||||||
|
|
||||||
if' :: Bool -> a -> a -> a
|
if' :: Bool -> a -> a -> a
|
||||||
if' True e _ = e
|
if' True e _ = e
|
||||||
|
|
|
@ -30,7 +30,7 @@ geomean :: (Show f, Floating f) => [f] -> f
|
||||||
geomean values = (product values) ** (1 / (fromIntegral (length values)))
|
geomean values = (product values) ** (1 / (fromIntegral (length values)))
|
||||||
|
|
||||||
accuracyInClass :: (Eq r) => [(r, r)] -> r -> R
|
accuracyInClass :: (Eq r) => [(r, r)] -> r -> R
|
||||||
accuracyInClass results clas = ((accuracy' (inResClass results clas)) * 100) / fromIntegral (length (inClass results clas))
|
accuracyInClass results clas = if fromIntegral (length (inClass results clas)) == 0 then 100 else ((accuracy' (inResClass results clas)) * 100) / fromIntegral (length (inClass results clas))
|
||||||
|
|
||||||
inClass :: (Eq r) => [(r, r)] -> r -> [(r, r)]
|
inClass :: (Eq r) => [(r, r)] -> r -> [(r, r)]
|
||||||
inClass results clas = (filter ((clas ==) . fst) results)
|
inClass results clas = (filter ((clas ==) . fst) results)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user