Skip to content

Commit

Permalink
Merge pull request #14 from TulipaEnergy/4-package-name
Browse files Browse the repository at this point in the history
Change package name
  • Loading branch information
greg-neustroev authored May 28, 2024
2 parents fc38eaa + d60bb45 commit 9bedca0
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AuthorEmail: m.arnoldus-1@tudelft.nl
AuthorName: Matthijs Arnoldus
JuliaMinVersion: '1.6'
License: Apache-2.0
PackageName: MGA
PackageName: NearOptimalAlternatives
PackageOwner: TulipaEnergy
PackageUUID: a88418a5-8dc5-4f1c-8a3e-d5a75ec49c70
RunJuliaNightlyOnCI: false
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/Docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
- run: |
julia --project=docs -e '
using Documenter: DocMeta, doctest
using MGA
DocMeta.setdocmeta!(MGA, :DocTestSetup, :(using MGA); recursive=true)
doctest(MGA)'
using NearOptimalAlternatives
DocMeta.setdocmeta!(NearOptimalAlternatives, :DocTestSetup, :(using NearOptimalAlternatives); recursive=true)
doctest(NearOptimalAlternatives)'
- run: julia --project=docs docs/make.jl
env:
JULIA_PKG_SERVER: ""
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Go to https://citation-file-format.github.io/cff-initializer-javascript/#/ to finish this
cff-version: 1.2.0
title: MGA.jl
title: NearOptimalAlternatives.jl
message: >-
If you use this software, please cite it using the
metadata from this file.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "MGA"
name = "NearOptimalAlternatives"
uuid = "a88418a5-8dc5-4f1c-8a3e-d5a75ec49c70"
authors = ["Matthijs Arnoldus <m.arnoldus-1@tudelft.nl> and contributors"]
version = "0.1.0"
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# MGA
# NearOptimalAlternatives

<!-- This check was disabled because these links don't exist until you push, create documentation, and create your first release -->
<!-- markdown-link-check-disable -->
[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://TulipaEnergy.github.io/MGA.jl/stable)
[![In development documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://TulipaEnergy.github.io/MGA.jl/dev)
[![Build Status](https://github.com/TulipaEnergy/MGA.jl/workflows/Test/badge.svg)](https://github.com/TulipaEnergy/MGA.jl/actions)
[![Test workflow status](https://github.com/TulipaEnergy/MGA.jl/actions/workflows/Test.yml/badge.svg?branch=main)](https://github.com/TulipaEnergy/MGA.jl/actions/workflows/Test.yml?query=branch%3Amain)
[![Lint workflow Status](https://github.com/TulipaEnergy/MGA.jl/actions/workflows/Lint.yml/badge.svg?branch=main)](https://github.com/TulipaEnergy/MGA.jl/actions/workflows/Lint.yml?query=branch%3Amain)
[![Docs workflow Status](https://github.com/TulipaEnergy/MGA.jl/actions/workflows/Docs.yml/badge.svg?branch=main)](https://github.com/TulipaEnergy/MGA.jl/actions/workflows/Docs.yml?query=branch%3Amain)

[![Coverage](https://codecov.io/gh/TulipaEnergy/MGA.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/TulipaEnergy/MGA.jl)
[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://TulipaEnergy.github.io/NearOptimalAlternatives.jl/stable)
[![In development documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://TulipaEnergy.github.io/NearOptimalAlternatives.jl/dev)
[![Build Status](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/workflows/Test/badge.svg)](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/actions)
[![Test workflow status](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/actions/workflows/Test.yml/badge.svg?branch=main)](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/actions/workflows/Test.yml?query=branch%3Amain)
[![Lint workflow Status](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/actions/workflows/Lint.yml/badge.svg?branch=main)](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/actions/workflows/Lint.yml?query=branch%3Amain)
[![Docs workflow Status](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/actions/workflows/Docs.yml/badge.svg?branch=main)](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/actions/workflows/Docs.yml?query=branch%3Amain)

[![Coverage](https://codecov.io/gh/TulipaEnergy/NearOptimalAlternatives.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/TulipaEnergy/NearOptimalAlternatives.jl)
[![DOI](https://zenodo.org/badge/DOI/FIXME)](https://doi.org/FIXME)

## How to Cite

If you use MGA.jl in your work, please cite using the reference given in [CITATION.cff](https://github.com/TulipaEnergy/MGA.jl/blob/main/CITATION.cff).
If you use NearOptimalAlternatives.jl in your work, please cite using the reference given in [CITATION.cff](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/blob/main/CITATION.cff).

## Contributing

If you want to make contributions of any kind, please first that a look into our [contributing guide directly on GitHub](docs/src/contributing.md) or the [contributing page on the website](https://TulipaEnergy.github.io/MGA.jl/dev/contributing/).
If you want to make contributions of any kind, please first that a look into our [contributing guide directly on GitHub](docs/src/contributing.md) or the [contributing page on the website](https://TulipaEnergy.github.io/NearOptimalAlternatives.jl/dev/contributing/).

---

Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
MGA = "a88418a5-8dc5-4f1c-8a3e-d5a75ec49c70"
NearOptimalAlternatives = "a88418a5-8dc5-4f1c-8a3e-d5a75ec49c70"

[compat]
Documenter = "1"
19 changes: 12 additions & 7 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
using MGA
using NearOptimalAlternatives
using Documenter

DocMeta.setdocmeta!(MGA, :DocTestSetup, :(using MGA); recursive = true)
DocMeta.setdocmeta!(
NearOptimalAlternatives,
:DocTestSetup,
:(using NearOptimalAlternatives);
recursive = true,
)

makedocs(;
modules = [MGA],
modules = [NearOptimalAlternatives],
doctest = true,
linkcheck = true,
authors = "Matthijs Arnoldus <m.arnoldus-1@tudelft.nl> and contributors",
repo = "https://github.com/TulipaEnergy/MGA.jl/blob/{commit}{path}#{line}",
sitename = "MGA.jl",
repo = "https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/blob/{commit}{path}#{line}",
sitename = "NearOptimalAlternatives.jl",
format = Documenter.HTML(;
prettyurls = get(ENV, "CI", "false") == "true",
canonical = "https://TulipaEnergy.github.io/MGA.jl",
canonical = "https://TulipaEnergy.github.io/NearOptimalAlternatives.jl",
assets = ["assets/style.css"],
),
pages = [
Expand All @@ -23,4 +28,4 @@ makedocs(;
],
)

deploydocs(; repo = "github.com/TulipaEnergy/MGA.jl", push_preview = true)
deploydocs(; repo = "github.com/TulipaEnergy/NearOptimalAlternatives.jl", push_preview = true)
2 changes: 1 addition & 1 deletion docs/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Be polite and respectful.

## Bug reports and discussions

If you think you found a bug, feel free to open an [issue](https://github.com/TulipaEnergy/MGA.jl/issues).
If you think you found a bug, feel free to open an [issue](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl/issues).
Focused suggestions and requests can also be opened as issues.
Before opening a pull request, start an issue or a discussion on the topic, please.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ If this is the first time you work with this repository, follow the instructions
3. Add this repo as a remote:

```bash
git remote add orgremote https://github.com/TulipaEnergy/MGA.jl
git remote add orgremote https://github.com/TulipaEnergy/NearOptimalAlternatives.jl
```

## Working on a new issue
Expand Down
6 changes: 3 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```@meta
CurrentModule = MGA
CurrentModule = NearOptimalAlternatives
```

# MGA
# NearOptimalAlternatives

Documentation for [MGA](https://github.com/TulipaEnergy/MGA.jl).
Documentation for [NearOptimalAlternatives](https://github.com/TulipaEnergy/NearOptimalAlternatives.jl).
2 changes: 1 addition & 1 deletion docs/src/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Pages = ["reference.md"]
```

```@autodocs
Modules = [MGA]
Modules = [NearOptimalAlternatives]
```
2 changes: 1 addition & 1 deletion src/MGA.jl → src/NearOptimalAlternatives.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module MGA
module NearOptimalAlternatives

# Packages

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MGA
using NearOptimalAlternatives
using Test
using Ipopt
using JuMP
Expand Down
18 changes: 14 additions & 4 deletions test/test-alternative-optimisation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
x_1_res = value(x_1)
x_2_res = value(x_2)

MGA.create_alternative_generating_problem!(model, 0.1, SqEuclidean(), VariableRef[])
NearOptimalAlternatives.create_alternative_generating_problem!(
model,
0.1,
SqEuclidean(),
VariableRef[],
)
# Test that the correct alternative problem is created and that `x_2` is fixed.
@test objective_sense(model) == MAX_SENSE &&
constraint_object(model[:original_objective]).set ==
Expand All @@ -32,7 +37,12 @@
x_1_res = value(x_1)
x_2_res = value(x_2)

MGA.create_alternative_generating_problem!(model, 0.1, SqEuclidean(), VariableRef[])
NearOptimalAlternatives.create_alternative_generating_problem!(
model,
0.1,
SqEuclidean(),
VariableRef[],
)
# Test that the correct alternative problem is created.
@test objective_sense(model) == MAX_SENSE &&
objective_function(model) == QuadExpr(
Expand All @@ -58,7 +68,7 @@
x_1_res = value(x_1)
x_2_res = value(x_2)

MGA.create_alternative_generating_problem!(model, 0.1, SqEuclidean(), [x_2])
NearOptimalAlternatives.create_alternative_generating_problem!(model, 0.1, SqEuclidean(), [x_2])
# Test that the correct alternative problem is created and that `x_2` is fixed.
@test objective_sense(model) == MAX_SENSE &&
objective_function(model) == QuadExpr(
Expand Down Expand Up @@ -87,7 +97,7 @@ end
x_1_res = value(x_1)
x_2_res = value(x_2)

MGA.add_solution!(model, SqEuclidean())
NearOptimalAlternatives.add_solution!(model, SqEuclidean())
# Test that the correct alternative problem is created and that `x_2` is fixed.
@test objective_sense(model) == MAX_SENSE &&
objective_function(model) == QuadExpr(
Expand Down
19 changes: 12 additions & 7 deletions test/test-generate-alternatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@variable(model, 0 x_2 1)
@objective(model, Max, x_1 + x_2)

@test_throws ArgumentError MGA.generate_alternatives!(model, 0.1, 5)
@test_throws ArgumentError NearOptimalAlternatives.generate_alternatives!(model, 0.1, 5)
end

@testset "Make sure error is thrown when incorrect optimality_gap." begin
Expand All @@ -21,7 +21,7 @@
@objective(model, Max, x_1 + x_2)
optimize!(model)

@test_throws ArgumentError MGA.generate_alternatives!(model, -0.1, 5)
@test_throws ArgumentError NearOptimalAlternatives.generate_alternatives!(model, -0.1, 5)
end

@testset "Make sure error is thrown when incorrect n_alternatives." begin
Expand All @@ -34,7 +34,7 @@
@objective(model, Max, x_1 + x_2)
optimize!(model)

@test_throws ArgumentError MGA.generate_alternatives!(model, 0.1, 0)
@test_throws ArgumentError NearOptimalAlternatives.generate_alternatives!(model, 0.1, 0)
end

@testset "Test regular run with one alternative." begin
Expand All @@ -47,7 +47,7 @@
@objective(model, Max, x_1 + x_2)
optimize!(model)

results = MGA.generate_alternatives!(model, 0.1, 1)
results = NearOptimalAlternatives.generate_alternatives!(model, 0.1, 1)

# Test that `results` contains one solution with 2 variables, and an objective value between 1.8 and 2.0.
@test length(results.solutions) == 1 &&
Expand All @@ -67,7 +67,7 @@
@objective(model, Max, x_1 + x_2)
optimize!(model)

results = MGA.generate_alternatives!(model, 0.1, 1, fixed_variables = [x_2])
results = NearOptimalAlternatives.generate_alternatives!(model, 0.1, 1, fixed_variables = [x_2])

# Test that `results` contains one solution with 2 variables, and an objective value between 1.8 and 2.0. Also, `x_2` should remain around 1.0 and `x_1` should be between 0.8 and 1.0.
@test length(results.solutions) == 1 &&
Expand All @@ -90,7 +90,7 @@
@objective(model, Max, x_1 + x_2)
optimize!(model)

results = MGA.generate_alternatives!(model, 0.1, 2)
results = NearOptimalAlternatives.generate_alternatives!(model, 0.1, 2)
println(results)

# Test that `results` contains 2 solutions with two variables each, where the objective values of both solutions are between 1.8 and 2.0.
Expand All @@ -113,7 +113,12 @@
@objective(model, Max, x_1 + x_2)
optimize!(model)

results = MGA.generate_alternatives!(model, 0.1, 1, metric = WeightedSqEuclidean([0.5, 1]))
results = NearOptimalAlternatives.generate_alternatives!(
model,
0.1,
1,
metric = WeightedSqEuclidean([0.5, 1]),
)
println(results)

# Test that `results` contains one solution with two variables. Logically, due to the weights this solution should return around 0.8 for `x_2` and 1.0 for `x_1`.
Expand Down
16 changes: 8 additions & 8 deletions test/test-results.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@testset "Update solutions of MGA optimisation" begin
@testset "Make sure using an unsolved MGA model fails." begin
@testset "Update solutions of NearOptimalAlternatives optimisation" begin
@testset "Make sure using an unsolved NearOptimalAlternatives model fails." begin
optimizer = Ipopt.Optimizer
model = JuMP.Model(optimizer)
results = MGA.AlternativeSolutions([], [])
@test_throws ErrorException MGA.update_solutions!(results, model)
results = NearOptimalAlternatives.AlternativeSolutions([], [])
@test_throws ErrorException NearOptimalAlternatives.update_solutions!(results, model)
end

@testset "Test error when no `original_objective` constraint present." begin
Expand All @@ -16,9 +16,9 @@
@objective(model, Max, (x_1 - 1)^2 + (x_2 - 1)^2)
@constraint(model, x_1 + x_2 1.8)

results = MGA.AlternativeSolutions([], [])
results = NearOptimalAlternatives.AlternativeSolutions([], [])
JuMP.optimize!(model)
@test_throws ErrorException MGA.update_solutions!(results, model)
@test_throws ErrorException NearOptimalAlternatives.update_solutions!(results, model)
end

@testset "Test correct flow for updating the set of results using a solved JuMP model." begin
Expand All @@ -31,9 +31,9 @@
@objective(model, Max, (x_1 - 1)^2 + (x_2 - 1)^2)
@constraint(model, original_objective, x_1 + x_2 1.8)

results = MGA.AlternativeSolutions([], [])
results = NearOptimalAlternatives.AlternativeSolutions([], [])
JuMP.optimize!(model)
MGA.update_solutions!(results, model)
NearOptimalAlternatives.update_solutions!(results, model)

# Test that only one solution is generated for 2 variables. Result should be approximately between 1.8 and 2.0 (with room for computational error).
@test length(results.solutions) == 1 &&
Expand Down

0 comments on commit 9bedca0

Please sign in to comment.