Skip to content

Commit 0c38095

Browse files
authored
Merge pull request #9 from LAMPSPUC/feature/ci
Fix ci pipe
2 parents e76601d + 170b47f commit 0c38095

File tree

4 files changed

+29
-37
lines changed

4 files changed

+29
-37
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
version:
2626
- '1.11'
2727
- '1.6'
28-
- 'pre'
2928
os:
3029
- ubuntu-latest
3130
arch:

Project.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
name = "ApplicationDrivenLearning"
2+
uuid = "0856f1c8-ef17-4e14-9230-2773e47a789e"
3+
authors = ["giovanni "]
4+
version = "0.1.0"
5+
16
[deps]
27
BilevelJuMP = "485130c0-026e-11ea-0f1a-6992cd14145c"
3-
DiffOpt = "930fe3bc-9c6b-11ea-2d94-6184641e85e7"
4-
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
58
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
6-
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
7-
JobQueueMPI = "32d208e1-246e-420c-b6ff-18b71b410923"
9+
DiffOpt = "930fe3bc-9c6b-11ea-2d94-6184641e85e7"
810
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
9-
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
10-
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
1111
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
1212
ParametricOptInterface = "0ce4ce61-57bf-432b-a095-efac525d185e"
1313
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1414
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
15+
JobQueueMPI = "32d208e1-246e-420c-b6ff-18b71b410923"
16+
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"

src/simulation.jl

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Distributed
2-
31
function compute_single_step_cost(
42
model::Model,
53
y::Vector{<:Real},
@@ -48,7 +46,7 @@ function compute_single_step_gradient(
4846
end
4947

5048
"""
51-
compute_cost(model, X, Y, with_gradients=false, n_workers=1)
49+
compute_cost(model, X, Y, with_gradients=false)
5250
5351
Compute the cost function (C) based on the model predictions and the true values.
5452
@@ -67,7 +65,6 @@ function compute_cost(
6765
X::Matrix{<:Real},
6866
Y::Matrix{<:Real},
6967
with_gradients::Bool = false,
70-
n_workers::Int = 1,
7168
)
7269

7370
# data size assertions
@@ -96,32 +93,11 @@ function compute_cost(
9693
# get predictions
9794
Yhat = model.forecast(X')' # size=(T, output_size)
9895

99-
# main loop - sequential
100-
if n_workers == 1
101-
for t = 1:T
102-
result = _compute_step(Y[t, :], Yhat[t, :])
103-
C += result[1] ./ T
104-
dC .+= result[2] ./ T
105-
end
106-
107-
# main loop - parallel
108-
elseif n_workers > 1
109-
110-
# add workers and import package on first call
111-
if nprocs() < n_workers
112-
error(
113-
"Please add workers and import the AppDrivenLearning module @everywhere before calling `train!` function.",
114-
)
115-
end
116-
117-
# parallel computation
118-
result =
119-
pmap(_compute_step, [Y[t, :] for t = 1:T], [Yhat[t, :] for t = 1:T])
120-
C = sum([r[1] for r in result])
121-
dC = sum([r[2] for r in result])
122-
123-
else
124-
error("Invalid number of workers")
96+
# main loop to compute cost
97+
for t = 1:T
98+
result = _compute_step(Y[t, :], Yhat[t, :])
99+
C += result[1] ./ T
100+
dC .+= result[2] ./ T
125101
end
126102

127103
if with_gradients

test/Project.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[deps]
2+
BilevelJuMP = "485130c0-026e-11ea-0f1a-6992cd14145c"
3+
DiffOpt = "930fe3bc-9c6b-11ea-2d94-6184641e85e7"
4+
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
5+
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
6+
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
7+
JobQueueMPI = "32d208e1-246e-420c-b6ff-18b71b410923"
8+
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
9+
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
10+
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
11+
ParametricOptInterface = "0ce4ce61-57bf-432b-a095-efac525d185e"
12+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
13+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
14+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
15+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

0 commit comments

Comments
 (0)