Skip to content

Commit e16d515

Browse files
authored
Merge pull request #10 from LAMPSPUC/dev
Initial PR from dev
2 parents b85af07 + 0c38095 commit e16d515

28 files changed

+2029
-1
lines changed

.JuliaFormatter.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Configuration file for JuliaFormatter.jl
2+
# For more information, see: https://domluna.github.io/JuliaFormatter.jl/stable/config/
3+
4+
indent = 4
5+
always_use_return = true
6+
margin = 80
7+
remove_extra_newlines = true
8+
short_to_long_function_def = true
9+
format_docstrings = true

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/" # Location of package manifests
6+
schedule:
7+
interval: "weekly"

.github/workflows/CompatHelper.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CompatHelper
2+
on:
3+
schedule:
4+
- cron: 0 0 * * *
5+
workflow_dispatch:
6+
jobs:
7+
CompatHelper:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Pkg.add("CompatHelper")
11+
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
12+
- name: CompatHelper.main()
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
16+
run: julia -e 'using CompatHelper; CompatHelper.main()'

.github/workflows/TagBot.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: TagBot
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
7+
inputs:
8+
lookback:
9+
default: "3"
10+
permissions:
11+
actions: read
12+
checks: read
13+
contents: write
14+
deployments: read
15+
issues: read
16+
discussions: read
17+
packages: read
18+
pages: read
19+
pull-requests: read
20+
repository-projects: read
21+
security-events: read
22+
statuses: read
23+
jobs:
24+
TagBot:
25+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: JuliaRegistries/TagBot@v1
29+
with:
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
ssh: ${{ secrets.DOCUMENTER_KEY }}

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags: ['*']
7+
pull_request:
8+
workflow_dispatch:
9+
concurrency:
10+
# Skip intermediate builds: always.
11+
# Cancel intermediate builds: only if it is a pull request build.
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
14+
jobs:
15+
test:
16+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
17+
runs-on: ${{ matrix.os }}
18+
timeout-minutes: 60
19+
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
20+
actions: write
21+
contents: read
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
version:
26+
- '1.11'
27+
- '1.6'
28+
os:
29+
- ubuntu-latest
30+
arch:
31+
- x64
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: julia-actions/setup-julia@v2
35+
with:
36+
version: ${{ matrix.version }}
37+
arch: ${{ matrix.arch }}
38+
- uses: julia-actions/cache@v2
39+
- uses: julia-actions/julia-buildpkg@v1
40+
- uses: julia-actions/julia-runtest@v1
41+
- uses: julia-actions/julia-processcoverage@v1
42+
- uses: codecov/codecov-action@v5

Project.toml

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

README.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,76 @@
1-
# ApplicationDrivenLearning.jl
1+
# ApplicationDrivenLearning.jl
2+
3+
ApplicationDrivenLearning.jl is a Julia package for training time series models using the application driven learning framework, that connects the optimization problem final cost with predictive model parameters in order to achieve the best model for a given application.
4+
5+
## Usage
6+
7+
```julia
8+
import Pkg
9+
10+
Pkg.add("ApplicationDrivenLearning") # not working yet! clone the repo instead
11+
12+
using ApplicationDrivenLearning
13+
14+
## Single power plan problem
15+
16+
# data
17+
X = reshape([1 1], (2, 1))
18+
Y = reshape([0 2], (2, 1))
19+
20+
# main model and policy / forecast variables
21+
model = ApplicationDrivenLearning.Model()
22+
@variables(model, begin
23+
z, ApplicationDrivenLearning.Policy
24+
θ, ApplicationDrivenLearning.Forecast
25+
end)
26+
27+
# plan model
28+
@variables(ApplicationDrivenLearning.Plan(model), begin
29+
c1 0
30+
c2 0
31+
end)
32+
@constraints(ApplicationDrivenLearning.Plan(model), begin
33+
c1 100 *.plan-z.plan)
34+
c2 20 * (z.plan-θ.plan)
35+
end)
36+
@objective(ApplicationDrivenLearning.Plan(model), Min, 10*z.plan + c1 + c2)
37+
38+
# assess model
39+
@variables(ApplicationDrivenLearning.Assess(model), begin
40+
c1 0
41+
c2 0
42+
end)
43+
@constraints(ApplicationDrivenLearning.Assess(model), begin
44+
c1 100 *.assess-z.assess)
45+
c2 20 * (z.assess-θ.assess)
46+
end)
47+
@objective(ApplicationDrivenLearning.Assess(model), Min, 10*z.assess + c1 + c2)
48+
49+
# basic setting
50+
set_optimizer(model, HiGHS.Optimizer)
51+
set_silent(model)
52+
53+
# forecast model
54+
nn = Chain(Dense(1 => 1; bias=false))
55+
ApplicationDrivenLearning.set_forecast_model(model, nn)
56+
57+
# training and getting solution
58+
solution = ApplicationDrivenLearning.train!(
59+
model,
60+
X,
61+
Y,
62+
ApplicationDrivenLearning.Options(
63+
ApplicationDrivenLearning.NelderMeadMode
64+
)
65+
)
66+
print(solution.params)
67+
```
68+
69+
## Installation
70+
71+
This package is **not yet** registered so if you want to use or test the code clone this repo and include source code from `src` directory.
72+
73+
## Contributing
74+
75+
* PRs such as adding new models and fixing bugs are very welcome!
76+
* For nontrivial changes, you'll probably want to first discuss the changes via issue.

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

docs/make.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Documenter
2+
3+
push!(LOAD_PATH, "../src")
4+
using ApplicationDrivenLearning
5+
6+
makedocs(;
7+
modules = [ApplicationDrivenLearning],
8+
doctest = false,
9+
clean = true,
10+
sitename = "ApplicationDrivenLearning.jl",
11+
authors = "Giovanni Amorim, Joaquim Garcia",
12+
pages = ["Home" => "index.md", "API Reference" => "reference.md"],
13+
)

docs/src/index.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# ApplicationDrivenLearning.jl Documentation
2+
3+
## Introduction
4+
5+
ApplicationDrivenLearning.jl is a Julia package for training time series models using the application driven learning framework, that connects the optimization problem final cost with predictive model parameters in order to achieve the best model for a given application.
6+
7+
## Usage
8+
9+
```julia
10+
import Pkg
11+
12+
Pkg.add("ApplicationDrivenLearning") # not working yet! clone the repo instead
13+
14+
using ApplicationDrivenLearning
15+
16+
## Single power plan problem
17+
18+
# data
19+
X = reshape([1 1], (2, 1))
20+
Y = reshape([0 2], (2, 1))
21+
22+
# main model and policy / forecast variables
23+
model = ApplicationDrivenLearning.Model()
24+
@variables(model, begin
25+
z, ApplicationDrivenLearning.Policy
26+
θ, ApplicationDrivenLearning.Forecast
27+
end)
28+
29+
# plan model
30+
@variables(ApplicationDrivenLearning.Plan(model), begin
31+
c1 0
32+
c2 0
33+
end)
34+
@constraints(ApplicationDrivenLearning.Plan(model), begin
35+
c1 100 *.plan-z.plan)
36+
c2 20 * (z.plan-θ.plan)
37+
end)
38+
@objective(ApplicationDrivenLearning.Plan(model), Min, 10*z.plan + c1 + c2)
39+
40+
# assess model
41+
@variables(ApplicationDrivenLearning.Assess(model), begin
42+
c1 0
43+
c2 0
44+
end)
45+
@constraints(ApplicationDrivenLearning.Assess(model), begin
46+
c1 100 *.assess-z.assess)
47+
c2 20 * (z.assess-θ.assess)
48+
end)
49+
@objective(ApplicationDrivenLearning.Assess(model), Min, 10*z.assess + c1 + c2)
50+
51+
# basic setting
52+
set_optimizer(model, HiGHS.Optimizer)
53+
set_silent(model)
54+
55+
# forecast model
56+
nn = Chain(Dense(1 => 1; bias=false))
57+
ApplicationDrivenLearning.set_forecast_model(model, nn)
58+
59+
# training and getting solution
60+
solution = ApplicationDrivenLearning.train!(
61+
model,
62+
X,
63+
Y,
64+
ApplicationDrivenLearning.Options(
65+
ApplicationDrivenLearning.NelderMeadMode
66+
)
67+
)
68+
print(solution.params)
69+
```
70+
71+
## Installation
72+
73+
This package is **not yet** registered so if you want to use or test the code clone this repo and include source code from `src` directory.
74+
75+
## Contributing
76+
77+
* PRs such as adding new models and fixing bugs are very welcome!
78+
* For nontrivial changes, you'll probably want to first discuss the changes via issue.

0 commit comments

Comments
 (0)