-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.swift
38 lines (24 loc) · 1.3 KB
/
main.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Foundation
import SwiftHBV
let root = "/Users/jont/Google Drive/Kode/Github/2019 - HBV/example-hagabru/"
// FILE-PATHS
let trainingsetFilepath = URL(fileURLWithPath: root + "data/Prepared-trainingset.csv")
let validationsetFilepath = URL(fileURLWithPath: root + "data/Prepared-validationset.csv")
let resultsFilepath = URL(fileURLWithPath: root + "outputs/Results.txt")
let trainingsetSimDataFilepath = URL(fileURLWithPath: root + "outputs/Testset-output.csv")
let validationsetSimDataFilepath = URL(fileURLWithPath: root + "outputs/Validationset-output.csv")
let catchmentParamsYamlFilepath = URL(fileURLWithPath: root + "data/CatchmentParameters.yaml")
let swiftHBV = SwiftHBV(
trainingsetFilepath: trainingsetFilepath,
validationsetFilepath: validationsetFilepath,
catchmentParamsYamlFilepath: catchmentParamsYamlFilepath
)!
// RUN OPTIMALIZATION.
// Optimized with the Nelder–Mead method
swiftHBV.optimize(runs: 10, maxIterationsEachRun: 1500, shouldPrintFeedback: true, printFeedbackInterval: 50)
// PRINT RESULTS
print(swiftHBV.getResults())
// SAVE RESULTS
swiftHBV.saveResults(filepath: resultsFilepath)
swiftHBV.saveSimulationData(filepath: trainingsetSimDataFilepath, dataset: .Trainingset)
swiftHBV.saveSimulationData(filepath: validationsetSimDataFilepath, dataset: .Validationset)