This commit is contained in:
Johannes Merl 2024-04-21 13:22:14 +02:00
parent 8432103a18
commit 0862943ebc
4 changed files with 27 additions and 26 deletions

View File

@ -2,17 +2,17 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1655624069, "lastModified": 1713145326,
"narHash": "sha256-7g1zwTdp35GMTERnSzZMWJ7PG3QdDE8VOX3WsnOkAtM=", "narHash": "sha256-m7+IWM6mkWOg22EC5kRUFCycXsXLSU7hWmHdmBfmC3s=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "0d68d7c857fe301d49cdcd56130e0beea4ecd5aa", "rev": "53a2c32bc66f5ae41a28d7a9a49d321172af621e",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "0d68d7c857fe301d49cdcd56130e0beea4ecd5aa", "rev": "53a2c32bc66f5ae41a28d7a9a49d321172af621e",
"type": "github" "type": "github"
} }
}, },

View File

@ -2,8 +2,7 @@
description = "Flake for haga"; description = "Flake for haga";
inputs = { inputs = {
nixpkgs.url = nixpkgs.url =
# 2022-06-22 "github:NixOS/nixpkgs/53a2c32bc66f5ae41a28d7a9a49d321172af621e";
"github:NixOS/nixpkgs/0d68d7c857fe301d49cdcd56130e0beea4ecd5aa";
}; };
@ -14,10 +13,12 @@
# defaultPackage.${system} = haskellPackages.callPackage ./default.nix { }; # defaultPackage.${system} = haskellPackages.callPackage ./default.nix { };
devShell.${system} = mkShell { devShell.${system} = mkShell {
buildInputs = [ buildInputs = [
haskell.compiler.ghc981
git
gcc
gmp
feedgnuplot feedgnuplot
haskellPackages.cabal-install stack
haskellPackages.ormolu
haskell.compiler.ghc8107
]; ];
}; };
}; };

View File

@ -49,8 +49,8 @@ library
, Pretty , Pretty
, Szenario191 , Szenario191
, LambdaCalculus , LambdaCalculus
, GermanDataset , NurseryDataset
, GermanData , NurseryData
, Utils , Utils
executable haga executable haga
build-depends: base build-depends: base
@ -83,8 +83,8 @@ executable haga
, Pretty , Pretty
, Szenario191 , Szenario191
, LambdaCalculus , LambdaCalculus
, GermanDataset , NurseryDataset
, GermanData , NurseryData
, Utils , Utils
executable haga-test executable haga-test
@ -119,6 +119,6 @@ executable haga-test
, Pretty , Pretty
, Szenario191 , Szenario191
, LambdaCalculus , LambdaCalculus
, GermanDataset , NurseryDataset
, GermanData , NurseryData
, Utils , Utils

View File

@ -9,7 +9,7 @@ import Protolude hiding (for)
import System.IO import System.IO
-- import Szenario212Pun -- import Szenario212Pun
-- import Szenario191 -- import Szenario191
import GermanDataset import NurseryDataset
import Debug.Trace as DB import Debug.Trace as DB
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
@ -51,19 +51,19 @@ main :: IO ()
main = main =
execParser optionsWithHelp >>= \opts -> do execParser optionsWithHelp >>= \opts -> do
hSetBuffering stdout NoBuffering hSetBuffering stdout NoBuffering
germanLEE <- shuffledGermanLEE nurseryLEE <- shuffledNurseryLEE
let env = germanLE let env = nurseryLE
let selType = Tournament 3 let selType = Tournament 3
let run' = run germanLEE env selType 80 (5 / 100) (populationSize opts) (steps (iterations opts)) let run' = run nurseryLEE env selType 80 (5 / 100) (populationSize opts) (steps (iterations opts))
pop' <- runEffect (for run' logCsv) pop' <- runEffect (for run' logCsv)
germanLEE' <- calc germanLEE pop' nurseryLEE' <- calc nurseryLEE pop'
let (res, _) = bests germanLEE' 5 pop' let (res, _) = bests nurseryLEE' 5 pop'
let germanLEE' = germanLEE {training = False} let nurseryLEE' = nurseryLEE {training = False}
germanLEE' <- calc germanLEE' res nurseryLEE' <- calc nurseryLEE' res
mapM_ (format germanLEE') res mapM_ (format nurseryLEE') res
where where
format germanL s = do format nurseryL s = do
let f = fitness' germanL s let f = fitness' nurseryL s
putErrText $ show f <> "\n" <> pretty s putErrText $ show f <> "\n" <> pretty s
logCsv = putText . csv logCsv = putText . csv
csv (t, f) = show t <> " " <> show f csv (t, f) = show t <> " " <> show f