-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.jl
84 lines (63 loc) · 2.3 KB
/
main.jl
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""
mainmod
Main module for a more complex exercise: a monte carlo analysis on the parameters of a linear model (including visualisation through plots)
"""
module mainmod # for the module to be recognised it needs to be part of a package that is added in Julia
using JSON
using JuMP
using Ipopt,Cbc,HiGHS,GLPK
export main,loadfile,savefile,parameteranalysis,randomselection,linearmodel
"""
loadfile(;iofile="./iofile.json")
Loads a json file 'iofile' and returns a dictionary.
If the file does not exist, a warning is displayed and a default dictionary is returned instead.
# Examples
```julia-repl
julia> loadfile(iofile="")
The file does not exist, falling back to default dictionary.
Dict("parameteranalysis" => Dict("i" => 0))
```
"""
function loadfile(;iofile="./iofile.json")
end
"""
savefile(iodb::Dict;iofile="./iofile.json")
Saves a dictionary to a json file 'iofile'.
"""
function savefile(iodb::Dict;iofile="./iofile.json")
end
"""
parameteranalysis()
Outer optimisation loop for selecting parameters and evaluating an inner optimisation loop for these parameters.
"""
function parameteranalysis(;finish=0.0,i=0,itarget=10,t=0.0,ttarget=NaN,a=0.0,atarget=NaN,n=0,ntarget=NaN)
end
function randomselection()
end
"""
linearmodel(;iofile="./iofile.json")
Linear model using JuMP with the Ipopt solver.
"""
function linearmodel()
end
# something with powermodels? Nah, not for the Mopo project. Same for machine learning in the selection process.
function spinewrapper()
end
function main()
loadfile()
parameteranalysis()
savefile(Dict())
println("The main file works")
end
end#module end
if abspath(PROGRAM_FILE) == @__FILE__
#=
This protects the module from executing this script when it is called by a different module or during an interactive session in the REPL.
To use the file in the REPL you should use the following code:
include("./mainmod.jl")
mainmod.main()
This is a more pythonic way of doing things. In Julia they typically make a separate example or test file (without the if abspath...). That would also make it easier to use in the REPL...
=#
using .mainmod #using because this code block is outside of the module and . for a local module
main()
end