From 5ebb658608ed70e6bb666f83f158a1833af52813 Mon Sep 17 00:00:00 2001 From: tmigot Date: Fri, 18 Oct 2024 11:06:35 -0400 Subject: [PATCH] Apply BestieTemplate v0.13.0 --- .JuliaFormatter.toml | 8 +- .all-contributorsrc | 5 + .copier-answers.yml | 28 + .editorconfig | 18 + .github/ISSUE_TEMPLATE/10-bug-report.yml | 60 ++ .github/ISSUE_TEMPLATE/20-feature-request.yml | 41 + .github/ISSUE_TEMPLATE/30-usage.yml | 23 + .github/ISSUE_TEMPLATE/99-general.yml | 21 + .github/ISSUE_TEMPLATE/config.yml | 5 + .github/PULL_REQUEST_TEMPLATE.md | 27 + .github/dependabot.yml | 7 + .github/workflows/Aqua.yml | 4 +- .github/workflows/CI_M1.yml | 6 +- .github/workflows/CompatHelper.yml | 46 +- .github/workflows/Docs.yml | 57 ++ .github/workflows/Documentation.yml | 46 +- .github/workflows/Invalidations.yml | 40 +- .github/workflows/Lint.yml | 60 ++ .github/workflows/PreCommitUpdate.yml | 40 + .github/workflows/ReusableTest.yml | 52 ++ .github/workflows/TagBot.yml | 52 +- .github/workflows/Test.yml | 46 ++ .github/workflows/TestOnPRs.yml | 29 + .github/workflows/ci.yml | 108 +-- .github/workflows/format_pr.yml | 4 +- .gitignore | 13 +- .lychee.toml | 11 + .markdownlint.json | 13 + .pre-commit-config.yaml | 49 ++ .yamllint.yml | 2 + CODE_OF_CONDUCT.md | 133 ++++ LICENSE | 373 ++++++++++ LICENSE.md | 702 +++++++++--------- README.md | 51 +- benchmark/Jenkinsfile | 8 +- docs/assets/example.jl | 12 +- docs/make.jl | 53 +- docs/src/90-contributing.md | 25 + docs/src/91-developer.md | 163 ++++ docs/src/95-reference.md | 17 + docs/src/benchmark.md | 46 +- docs/src/fine-tuneDCI.md | 31 +- docs/src/index.md | 27 +- docs/src/reference.md | 12 +- src/DCISolver.jl | 10 +- .../SymCOOSolverInterface.jl | 2 +- src/SymCOOSolverInterface/hsl.jl | 4 +- .../ldlfactorizations.jl | 10 +- src/dci_feasibility.jl | 8 +- src/dci_normal.jl | 2 +- src/dci_tangent.jl | 25 +- src/factorization.jl | 6 +- src/main.jl | 12 +- src/param_struct.jl | 70 +- src/workspace.jl | 20 +- test/runtests.jl | 9 +- test/symcoo_runtests.jl | 2 +- test/test-basic-test.jl | 3 + 58 files changed, 2107 insertions(+), 650 deletions(-) create mode 100644 .all-contributorsrc create mode 100644 .copier-answers.yml create mode 100644 .editorconfig create mode 100644 .github/ISSUE_TEMPLATE/10-bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/20-feature-request.yml create mode 100644 .github/ISSUE_TEMPLATE/30-usage.yml create mode 100644 .github/ISSUE_TEMPLATE/99-general.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/Docs.yml create mode 100644 .github/workflows/Lint.yml create mode 100644 .github/workflows/PreCommitUpdate.yml create mode 100644 .github/workflows/ReusableTest.yml create mode 100644 .github/workflows/Test.yml create mode 100644 .github/workflows/TestOnPRs.yml create mode 100644 .lychee.toml create mode 100644 .markdownlint.json create mode 100644 .pre-commit-config.yaml create mode 100644 .yamllint.yml create mode 100644 CODE_OF_CONDUCT.md create mode 100644 LICENSE create mode 100644 docs/src/90-contributing.md create mode 100644 docs/src/91-developer.md create mode 100644 docs/src/95-reference.md create mode 100644 test/test-basic-test.jl diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml index 15fa6547..fb228636 100644 --- a/.JuliaFormatter.toml +++ b/.JuliaFormatter.toml @@ -1,7 +1,3 @@ -margin = 100 indent = 2 -whitespace_typedefs = true -whitespace_ops_in_indices = true -remove_extra_newlines = true -annotate_untyped_fields_with_any = false -normalize_line_endings = "unix" \ No newline at end of file +margin = 92 +normalize_line_endings = "unix" diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 00000000..4b06a353 --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,5 @@ +{ + "projectName": "DCISolver", + "projectOwner": "JuliaSmoothOptimizers", + "files": ["README.md", "docs/src/index.md"] +} diff --git a/.copier-answers.yml b/.copier-answers.yml new file mode 100644 index 00000000..a98e34ec --- /dev/null +++ b/.copier-answers.yml @@ -0,0 +1,28 @@ +# Changes here will be overwritten by Copier +AddAllcontributors: true +AddCodeOfConduct: true +AddContributionDocs: true +AddCopierCI: false +AddGitHubTemplates: true +AddMacToCI: true +AddPrecommit: true +AddWinToCI: true +AnswerStrategy: ask +Authors: Abel Soares Siqueira and Tangi Migot +AutoIncludeTests: true +CodeOfConductContact: tangi.migot@gmail.com +ConfigIndentation: 2 +JuliaIndentation: 2 +JuliaMinCIVersion: ^1.10.0 +JuliaMinVersion: ^1.6.0 +License: MPL-2.0 +LicenseCopyrightHolders: Abel Soares Siqueira and Tangi + Migot +MarkdownIndentation: 2 +PackageName: DCISolver +PackageOwner: JuliaSmoothOptimizers +PackageUUID: bee2e536-65f6-11e9-3844-e5bb4c9c55c9 +RunJuliaNightlyOnCI: true +UseCirrusCI: false +_commit: v0.13.0 +_src_path: https://github.com/abelsiqueira/BestieTemplate.jl diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..cbb163ba --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# https://editorconfig.org +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +trim_trailing_whitespace = true + +[*.jl] +indent_size = 2 + +[*.md] +indent_size = 2 + +[*.{yml,toml,json}] +indent_size = 2 diff --git a/.github/ISSUE_TEMPLATE/10-bug-report.yml b/.github/ISSUE_TEMPLATE/10-bug-report.yml new file mode 100644 index 00000000..9ac2b594 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/10-bug-report.yml @@ -0,0 +1,60 @@ +name: Bug Report +description: File a bug report related to running the package +title: "[Bug] " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + + Please, before submitting, make sure that: + + - There is not an [existing issue](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/issues) with the same question + - You have read the [contributing guide](https://JuliaSmoothOptimizers.github.io/DCISolver.jl/dev/90-contributing/) + - You are following the [code of conduct](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/main/CODE_OF_CONDUCT.md) + The form below should help you in filling out this issue. + - type: textarea + id: description + attributes: + label: Description + description: Describe the bug + validations: + required: true + - type: input + id: pkg-version + attributes: + label: Package Version + description: What version of the package are you running? + validations: + required: true + - type: input + id: version + attributes: + label: Julia Version + description: What version of Julia are you running? + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Reproduction steps + description: What steps led to the bug happening? Please provide a minimal reproducible example. + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell + - type: dropdown + id: os + attributes: + label: "Operating System" + description: What is the impacted environment? + multiple: true + options: + - Windows + - Linux + - Mac diff --git a/.github/ISSUE_TEMPLATE/20-feature-request.yml b/.github/ISSUE_TEMPLATE/20-feature-request.yml new file mode 100644 index 00000000..2958ca1b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/20-feature-request.yml @@ -0,0 +1,41 @@ +name: "Feature Request" +description: Suggest a new feature for the package +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this feature request! + + Please, before submitting, make sure that: + + - There is not an [existing issue](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/issues) with the same question + - You have read the [contributing guide](https://JuliaSmoothOptimizers.github.io/DCISolver.jl/dev/90-contributing/) + - You are following the [code of conduct](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/main/CODE_OF_CONDUCT.md) + The form below should help you in filling out this issue. + - type: textarea + id: description + attributes: + label: Description + description: Describe the requested feature + validations: + required: true + - type: textarea + id: validation + attributes: + label: Validation and testing + description: How could we verify that the new feature works? What kind of tests can be done? + - type: textarea + id: motivation + attributes: + label: Motivation + description: Explain why this feature is relevant + - type: textarea + id: target + attributes: + label: Target audience + description: Tell more about the users of this feature, or where it could be useful + - type: textarea + id: can-help + attributes: + label: Can you help? + description: Can you help developing this feature? diff --git a/.github/ISSUE_TEMPLATE/30-usage.yml b/.github/ISSUE_TEMPLATE/30-usage.yml new file mode 100644 index 00000000..3de16c37 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/30-usage.yml @@ -0,0 +1,23 @@ +name: "Usage question" +description: Questions related to the usage +labels: ["documentation"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this question! + + Please, before submitting, make sure that: + + - You have checked the [documentation](https://JuliaSmoothOptimizers.github.io/DCISolver.jl) and haven't found enough information + - There is not an [existing issue](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/issues) with the same question + - You have read the [contributing guide](https://JuliaSmoothOptimizers.github.io/DCISolver.jl/dev/90-contributing/) + - You are following the [code of conduct](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/main/CODE_OF_CONDUCT.md) + The form below should help you in filling out this issue. + - type: textarea + id: description + attributes: + label: Description + description: Write your question + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/99-general.yml b/.github/ISSUE_TEMPLATE/99-general.yml new file mode 100644 index 00000000..2fc024fb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/99-general.yml @@ -0,0 +1,21 @@ +name: "General issue" +description: In case none of the others templates apply +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this issue! + + Please, before submitting, make sure that: + + - There is not an [existing issue](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/issues) with the same question + - You have read the [contributing guide](https://JuliaSmoothOptimizers.github.io/DCISolver.jl/dev/90-contributing/) + - You are following the [code of conduct](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/main/CODE_OF_CONDUCT.md) + The form below should help you in filling out this issue. + - type: textarea + id: description + attributes: + label: Description + description: Describe the issue + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..5e1b55e8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Discussions + url: https://github.com/JuliaSmoothOptimizers/DCISolver.jl/discussions + about: Create and follow discussions here diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..8bedcf3b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ + + +## Related issues + + + + +Closes # + + + + +## Checklist + + + +- [ ] I am following the [contributing guidelines](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/main/docs/src/90-contributing.md) +- [ ] Tests are passing +- [ ] Lint workflow is passing +- [ ] Docs were updated and workflow is passing diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..700707ce --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/Aqua.yml b/.github/workflows/Aqua.yml index 915948db..8389a1b6 100644 --- a/.github/workflows/Aqua.yml +++ b/.github/workflows/Aqua.yml @@ -12,6 +12,6 @@ jobs: - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@latest with: - version: '1' + version: "1" - name: Aqua.jl - run: julia --color=yes -e 'using Pkg; Pkg.add("Aqua"); Pkg.develop(path="."); using Aqua, DCISolver; Aqua.test_all(DCISolver)' \ No newline at end of file + run: julia --color=yes -e 'using Pkg; Pkg.add("Aqua"); Pkg.develop(path="."); using Aqua, DCISolver; Aqua.test_all(DCISolver)' diff --git a/.github/workflows/CI_M1.yml b/.github/workflows/CI_M1.yml index b0587dbf..9d91d779 100644 --- a/.github/workflows/CI_M1.yml +++ b/.github/workflows/CI_M1.yml @@ -13,9 +13,9 @@ jobs: fail-fast: false matrix: version: - - '1.6' - - '1' - - 'nightly' + - "1.6" + - "1" + - "nightly" arch: - x64 steps: diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index a26db5b5..210e56f0 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -1,19 +1,51 @@ +# CompatHelper v3.5.0 name: CompatHelper on: schedule: - - cron: '00 00 * * *' + - cron: 0 0 * * * # Every day at 00:00 UTC + workflow_dispatch: + +permissions: + contents: write + pull-requests: write jobs: CompatHelper: runs-on: ubuntu-latest steps: - - uses: julia-actions/setup-julia@latest + - name: Check if Julia is already available in the PATH + id: julia_in_path + run: which julia + continue-on-error: true + - name: Install Julia, but only if it is not already available in the PATH + uses: julia-actions/setup-julia@v2 with: - version: 1.6 - - name: Pkg.add("CompatHelper") - run: julia -e 'using Pkg; Pkg.add("CompatHelper")' - - name: CompatHelper.main() + version: "1" + arch: ${{ runner.arch }} + if: steps.julia_in_path.outcome != 'success' + - name: Use Julia cache + uses: julia-actions/cache@v2 + - name: "Add the General registry via Git" + run: | + import Pkg + ENV["JULIA_PKG_SERVER"] = "" + Pkg.Registry.add("General") + shell: julia --color=yes {0} + - name: "Install CompatHelper" + run: | + import Pkg + name = "CompatHelper" + uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" + version = "3" + Pkg.add(; name, uuid, version) + shell: julia --color=yes {0} + - name: "Run CompatHelper" + run: | + import CompatHelper + CompatHelper.main() + shell: julia --color=yes {0} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: julia -e 'using CompatHelper; CompatHelper.main()' + COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} + # COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} diff --git a/.github/workflows/Docs.yml b/.github/workflows/Docs.yml new file mode 100644 index 00000000..8b0589bf --- /dev/null +++ b/.github/workflows/Docs.yml @@ -0,0 +1,57 @@ +name: Docs + +on: + push: + branches: + - main + paths: + - "docs/**" + - "src/**" + - "*.toml" + tags: ["*"] + pull_request: + branches: + - main + paths: + - "docs/**" + - "src/**" + - "*.toml" + types: [opened, synchronize, reopened] + +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: "1" + - name: Use Julia cache + uses: julia-actions/cache@v2 + - name: Instantiate environment with development version of the package + run: | + julia --project=docs -e ' + using Pkg + Pkg.develop(PackageSpec(path=pwd())) + Pkg.instantiate()' + - name: Run doctest + run: | + julia --project=docs -e ' + using Documenter: DocMeta, doctest + using DCISolver + DocMeta.setdocmeta!(DCISolver, :DocTestSetup, :(using DCISolver); recursive=true) + doctest(DCISolver)' + - name: Generate and deploy documentation + run: julia --project=docs docs/make.jl + env: + JULIA_PKG_SERVER: "" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} + GKSwstype: "100" # https://discourse.julialang.org/t/generation-of-documentation-fails-qt-qpa-xcb-could-not-connect-to-display/60988 diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index be0b8658..9c62838c 100644 --- a/.github/workflows/Documentation.yml +++ b/.github/workflows/Documentation.yml @@ -1,23 +1,23 @@ -name: Documentation -on: - push: - branches: - - main - tags: '*' - pull_request: - types: [opened, synchronize, reopened] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@latest - with: - version: '1' - - name: Install dependencies - run: julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - - name: Build and deploy - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} - run: julia --project=docs --color=yes docs/make.jl +name: Documentation +on: + push: + branches: + - main + tags: "*" + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@latest + with: + version: "1" + - name: Install dependencies + run: julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' + - name: Build and deploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} + run: julia --project=docs --color=yes docs/make.jl diff --git a/.github/workflows/Invalidations.yml b/.github/workflows/Invalidations.yml index d7d8c1a3..b525c14d 100644 --- a/.github/workflows/Invalidations.yml +++ b/.github/workflows/Invalidations.yml @@ -19,25 +19,25 @@ jobs: if: github.base_ref == github.event.repository.default_branch runs-on: ubuntu-latest steps: - - uses: julia-actions/setup-julia@v1 - with: - version: '1' - - uses: actions/checkout@v3 - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-invalidations@v1 - id: invs_pr + - uses: julia-actions/setup-julia@v1 + with: + version: "1" + - uses: actions/checkout@v3 + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-invalidations@v1 + id: invs_pr - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.repository.default_branch }} - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-invalidations@v1 - id: invs_default + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.repository.default_branch }} + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-invalidations@v1 + id: invs_default - - name: Report invalidation counts - run: | - echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY - echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY - - name: Check if the PR does increase number of invalidations - if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total - run: exit 1 \ No newline at end of file + - name: Report invalidation counts + run: | + echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY + echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY + - name: Check if the PR does increase number of invalidations + if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total + run: exit 1 diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml new file mode 100644 index 00000000..4c1397d7 --- /dev/null +++ b/.github/workflows/Lint.yml @@ -0,0 +1,60 @@ +name: Lint + +on: + push: + branches: + - main + tags: ["*"] + pull_request: + +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + lint: + name: Linting + runs-on: ubuntu-latest + steps: + - name: Clone + uses: actions/checkout@v4 + - name: Setup Julia + uses: julia-actions/setup-julia@v2 + with: + version: "1" + - name: Use Julia cache + uses: julia-actions/cache@v2 + - name: Install JuliaFormatter.jl + run: julia -e 'using Pkg; pkg"add JuliaFormatter"' + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: touch requirements.txt + - name: Setup Python + uses: actions/setup-python@v5 + with: + cache: "pip" + python-version: "3.11" + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: rm requirements.txt + - name: Cache pre-commit + uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }} + - name: Install pre-commit + run: pip install pre-commit + - name: Run pre-commit + run: SKIP=no-commit-to-branch pre-commit run -a + link-checker: + name: Link checker + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v1 + with: + fail: true + args: --config '.lychee.toml' . diff --git a/.github/workflows/PreCommitUpdate.yml b/.github/workflows/PreCommitUpdate.yml new file mode 100644 index 00000000..e5318c55 --- /dev/null +++ b/.github/workflows/PreCommitUpdate.yml @@ -0,0 +1,40 @@ +name: pre-commit Update + +on: + schedule: + - cron: "0 7 1/7 * *" # At 7:00 every 7 days + workflow_dispatch: + +jobs: + pre-commit-update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: touch requirements.txt + - name: Setup Python + uses: actions/setup-python@v5 + with: + cache: pip + python-version: "3.11" + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: rm requirements.txt + - name: Install pre-commit + run: pip install pre-commit + - name: Run pre-commit's autoupdate + run: | + # ignore exit code + pre-commit autoupdate || true + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v7 + with: + commit-message: "chore: :robot: pre-commit update" + title: "[AUTO] pre-commit update" + branch: auto-pre-commit-update + delete-branch: true + labels: chore + - name: Check outputs + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" diff --git a/.github/workflows/ReusableTest.yml b/.github/workflows/ReusableTest.yml new file mode 100644 index 00000000..12431f28 --- /dev/null +++ b/.github/workflows/ReusableTest.yml @@ -0,0 +1,52 @@ +name: Reusable test + +on: + workflow_call: + inputs: + version: + required: false + type: string + default: "1" + os: + required: false + type: string + default: ubuntu-latest + arch: + required: false + type: string + default: x64 + allow_failure: + required: false + type: boolean + default: false + run_codecov: + required: false + type: boolean + default: false + secrets: + codecov_token: + required: true + +jobs: + test: + name: Julia ${{ inputs.version }} - ${{ inputs.os }} - ${{ inputs.arch }} - ${{ github.event_name }} + runs-on: ${{ inputs.os }} + continue-on-error: ${{ inputs.allow_failure }} + + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: ${{ inputs.version }} + arch: ${{ inputs.arch }} + - name: Use Julia cache + uses: julia-actions/cache@v2 + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 + - uses: julia-actions/julia-processcoverage@v1 + if: ${{ inputs.run_codecov }} + - uses: codecov/codecov-action@v4 + if: ${{ inputs.run_codecov }} + with: + file: lcov.info + token: ${{ secrets.codecov_token }} diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index 083baf95..dab9b0b6 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -1,15 +1,37 @@ -name: TagBot -on: - issue_comment: - types: - - created - workflow_dispatch: -jobs: - TagBot: - if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' - runs-on: ubuntu-latest - steps: - - uses: JuliaRegistries/TagBot@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - ssh: ${{ secrets.DOCUMENTER_KEY }} +name: TagBot + +on: + issue_comment: + types: + - created + workflow_dispatch: + inputs: + lookback: + type: number + default: 3 + +permissions: + actions: read + checks: read + contents: write + deployments: read + issues: read + discussions: read + packages: read + pages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read + +jobs: + TagBot: + if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + # Edit the following line to reflect the actual name of the GitHub Secret containing your private key + ssh: ${{ secrets.DOCUMENTER_KEY }} + # ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }} diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml new file mode 100644 index 00000000..86828ecb --- /dev/null +++ b/.github/workflows/Test.yml @@ -0,0 +1,46 @@ +name: Test + +on: + push: + branches: + - main + tags: ["*"] + workflow_dispatch: + +jobs: + test: + uses: ./.github/workflows/ReusableTest.yml + with: + os: ${{ matrix.os }} + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + allow_failure: ${{ matrix.allow_failure }} + run_codecov: ${{ matrix.version == '1' && matrix.os == 'ubuntu-latest' }} + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + strategy: + fail-fast: false + matrix: + version: + - "^1.10.0" + - "1" + os: + - ubuntu-latest + - macOS-latest + - windows-latest + arch: + - x64 + allow_failure: [false] + include: + - version: "nightly" + os: ubuntu-latest + arch: x64 + allow_failure: true + - version: "nightly" + os: macOS-latest + arch: x64 + allow_failure: true + - version: "nightly" + os: windows-latest + arch: x64 + allow_failure: true diff --git a/.github/workflows/TestOnPRs.yml b/.github/workflows/TestOnPRs.yml new file mode 100644 index 00000000..19a1f5a8 --- /dev/null +++ b/.github/workflows/TestOnPRs.yml @@ -0,0 +1,29 @@ +name: Test on PRs + +on: + pull_request: + branches: + - main + paths: + - "src/**" + - "test/**" + - "*.toml" + types: [opened, synchronize, reopened] + +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + test: + uses: ./.github/workflows/ReusableTest.yml + with: + os: ubuntu-latest + version: "1" + arch: x64 + allow_failure: false + run_codecov: true + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 409e0d14..d347be31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,54 +1,54 @@ -name: CI -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -jobs: - test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} - runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.allow_failure }} - strategy: - fail-fast: false - matrix: - version: ['1.6', '1'] - os: [ubuntu-latest, macOS-latest, windows-latest] - arch: [x64] - allow_failure: [false] - include: - - version: 'nightly' - os: ubuntu-latest - arch: x64 - allow_failure: true - - version: 'nightly' - os: macOS-latest - arch: x64 - allow_failure: true - - version: 'nightly' - os: windows-latest - arch: x64 - allow_failure: true - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 - with: - version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - - uses: actions/cache@v1 - env: - cache-name: cache-artifacts - with: - path: ~/.julia/artifacts - key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} - restore-keys: | - ${{ runner.os }}-test-${{ env.cache-name }}- - ${{ runner.os }}-test- - ${{ runner.os }}- - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-runtest@v1 - - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 - with: - file: lcov.info +name: CI +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.allow_failure }} + strategy: + fail-fast: false + matrix: + version: ["1.6", "1"] + os: [ubuntu-latest, macOS-latest, windows-latest] + arch: [x64] + allow_failure: [false] + include: + - version: "nightly" + os: ubuntu-latest + arch: x64 + allow_failure: true + - version: "nightly" + os: macOS-latest + arch: x64 + allow_failure: true + - version: "nightly" + os: windows-latest + arch: x64 + allow_failure: true + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info diff --git a/.github/workflows/format_pr.yml b/.github/workflows/format_pr.yml index c8f53089..b57d82e3 100644 --- a/.github/workflows/format_pr.yml +++ b/.github/workflows/format_pr.yml @@ -22,11 +22,11 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: ":robot: Format .jl files" - title: '[AUTO] JuliaFormatter.jl run' + title: "[AUTO] JuliaFormatter.jl run" branch: auto-juliaformatter-pr delete-branch: true labels: formatting, automated pr, no changelog - name: Check outputs run: | echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" \ No newline at end of file + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" diff --git a/.gitignore b/.gitignore index 39ce60c1..b1d09339 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,16 @@ +*.jl.*.cov +*.jl.cov +*.jl.mem +*.rej +.DS_Store +.benchmarkci Manifest.toml +benchmark/*.json +coverage +docs/build/ +env +node_modules *.jld2 *.png *.mem -/allocs-pack \ No newline at end of file +/allocs-pack diff --git a/.lychee.toml b/.lychee.toml new file mode 100644 index 00000000..99bbb869 --- /dev/null +++ b/.lychee.toml @@ -0,0 +1,11 @@ +exclude = [ + "@ref", + "^https://github.com/.*/releases/tag/v.*$", + "^https://doi.org/FIXME$", + "^https://JuliaSmoothOptimizers.github.io/DCISolver.jl/stable$", + "zenodo.org/badge/DOI/FIXME$" +] + +exclude_path = [ + "docs/build" +] diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..8bf958ad --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,13 @@ +{ + "MD007": { + "indent": 2, + "start_indented": false + }, + "MD013": { + "line_length": 1000, + "tables": false + }, + "MD033": false, + "MD041": false, + "default": true +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..4e4abd2a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,49 @@ +repos: + - repo: local + hooks: + # Prevent committing .rej files + - id: forbidden-files + name: forbidden files + entry: found Copier update rejection files; review them and remove them + language: fail + files: "\\.rej$" + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-json + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: file-contents-sorter + files: .JuliaFormatter.toml + args: [--unique] + - id: mixed-line-ending + args: [--fix=lf] + - id: no-commit-to-branch + - id: pretty-format-json + args: [--autofix, --indent=2] + - id: trailing-whitespace + - id: check-merge-conflict + args: [--assume-in-merge] + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.42.0 + hooks: + - id: markdownlint-fix + - repo: https://github.com/citation-file-format/cffconvert + rev: 054bda51dbe278b3e86f27c890e3f3ac877d616c + hooks: + - id: validate-cff + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v4.0.0-alpha.8" # Use the sha or tag you want to point at + hooks: + - id: prettier + types_or: [yaml, json] + exclude: ".copier-answers.yml" + - repo: https://github.com/adrienverge/yamllint + rev: v1.35.1 + hooks: + - id: yamllint + - repo: https://github.com/domluna/JuliaFormatter.jl + rev: v1.0.61 + hooks: + - id: julia-formatter diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 00000000..5e16e5fb --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,2 @@ +rules: + indentation: { spaces: 2 } diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..e9da99b5 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,133 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement: +`tangi.migot@gmail.com`. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..a612ad98 --- /dev/null +++ b/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/LICENSE.md b/LICENSE.md index 7014087d..b78a3faa 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -4,376 +4,388 @@ DCISolver.jl is licensed under the [MPL version 2.0](https://www.mozilla.org/MPL ## License - Mozilla Public License Version 2.0 - ================================== +Mozilla Public License Version 2.0 + ================================== - 1. Definitions - -------------- + 1. Definitions - 1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. + -------------- - 1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. + 1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. - 1.3. "Contribution" - means Covered Software of a particular Contributor. + 1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. - 1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. + 1.3. "Contribution" + means Covered Software of a particular Contributor. - 1.5. "Incompatible With Secondary Licenses" - means + 1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or + 1.5. "Incompatible With Secondary Licenses" + means - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or - 1.6. "Executable Form" - means any form of the work other than Source Code Form. + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. - 1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. + 1.6. "Executable Form" + means any form of the work other than Source Code Form. - 1.8. "License" - means this document. + 1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. - 1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. + 1.8. "License" + means this document. - 1.10. "Modifications" - means any of the following: + 1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or + 1.10. "Modifications" + means any of the following: - (b) any new file in Source Code Form that contains any Covered - Software. + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or - 1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. + (b) any new file in Source Code Form that contains any Covered + Software. - 1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. + 1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. - 1.13. "Source Code Form" - means the form of the work preferred for making modifications. + 1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. - 1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. + 1.13. "Source Code Form" + means the form of the work preferred for making modifications. - 2. License Grants and Conditions - -------------------------------- + 1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. - 2.1. Grants + 2. License Grants and Conditions - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: + -------------------------------- - (a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and + 2.1. Grants - (b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: - 2.2. Effective Date + (a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and - The licenses granted in Section 2.1 with respect to any Contribution - become effective for each Contribution on the date the Contributor first - distributes such Contribution. + (b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. - 2.3. Limitations on Grant Scope + 2.2. Effective Date - The licenses granted in this Section 2 are the only rights granted under - this License. No additional rights or licenses will be implied from the - distribution or licensing of Covered Software under this License. - Notwithstanding Section 2.1(b) above, no patent license is granted by a - Contributor: - - (a) for any code that a Contributor has removed from Covered Software; - or - - (b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - (c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - - This License does not grant any rights in the trademarks, service marks, - or logos of any Contributor (except as may be necessary to comply with - the notice requirements in Section 3.4). - - 2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this - License (see Section 10.2) or under the terms of a Secondary License (if - permitted under the terms of Section 3.3). - - 2.5. Representation - - Each Contributor represents that the Contributor believes its - Contributions are its original creation(s) or it has sufficient rights - to grant the rights to its Contributions conveyed by this License. - - 2.6. Fair Use - - This License is not intended to limit any rights You have under - applicable copyright doctrines of fair use, fair dealing, or other - equivalents. - - 2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted - in Section 2.1. - - 3. Responsibilities - ------------------- - - 3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under - the terms of this License. You must inform recipients that the Source - Code Form of the Covered Software is governed by the terms of this - License, and how they can obtain a copy of this License. You may not - attempt to alter or restrict the recipients' rights in the Source Code - Form. - - 3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - (a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - - (b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - - 3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for - the Covered Software. If the Larger Work is a combination of Covered - Software with a work governed by one or more Secondary Licenses, and the - Covered Software is not Incompatible With Secondary Licenses, this - License permits You to additionally distribute such Covered Software - under the terms of such Secondary License(s), so that the recipient of - the Larger Work may, at their option, further distribute the Covered - Software under the terms of either this License or such Secondary - License(s). - - 3.4. Notices - - You may not remove or alter the substance of any license notices - (including copyright notices, patent notices, disclaimers of warranty, - or limitations of liability) contained within the Source Code Form of - the Covered Software, except that You may alter any license notices to - the extent required to remedy known factual inaccuracies. - - 3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on - behalf of any Contributor. You must make it absolutely clear that any - such warranty, support, indemnity, or liability obligation is offered by - You alone, and You hereby agree to indemnify every Contributor for any - liability incurred by such Contributor as a result of warranty, support, - indemnity or liability terms You offer. You may include additional - disclaimers of warranty and limitations of liability specific to any - jurisdiction. - - 4. Inability to Comply Due to Statute or Regulation - --------------------------------------------------- - - If it is impossible for You to comply with any of the terms of this - License with respect to some or all of the Covered Software due to - statute, judicial order, or regulation then You must: (a) comply with - the terms of this License to the maximum extent possible; and (b) - describe the limitations and the code they affect. Such description must - be placed in a text file included with all distributions of the Covered - Software under this License. Except to the extent prohibited by statute - or regulation, such description must be sufficiently detailed for a - recipient of ordinary skill to be able to understand it. - - 5. Termination - -------------- - - 5.1. The rights granted under this License will terminate automatically - if You fail to comply with any of its terms. However, if You become - compliant, then the rights granted under this License from a particular - Contributor are reinstated (a) provisionally, unless and until such - Contributor explicitly and finally terminates Your grants, and (b) on an - ongoing basis, if such Contributor fails to notify You of the - non-compliance by some reasonable means prior to 60 days after You have - come back into compliance. Moreover, Your grants from a particular - Contributor are reinstated on an ongoing basis if such Contributor - notifies You of the non-compliance by some reasonable means, this is the - first time You have received notice of non-compliance with this License - from such Contributor, and You become compliant prior to 30 days after - Your receipt of the notice. - - 5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, - counter-claims, and cross-claims) alleging that a Contributor Version - directly or indirectly infringes any patent, then the rights granted to - You by any and all Contributors for the Covered Software under Section - 2.1 of this License shall terminate. - - 5.3. In the event of termination under Sections 5.1 or 5.2 above, all - end user license agreements (excluding distributors and resellers) which - have been validly granted by You or Your distributors under this License - prior to termination shall survive termination. - - ************************************************************************ - * * - * 6. Disclaimer of Warranty * - * ------------------------- * - * * - * Covered Software is provided under this License on an "as is" * - * basis, without warranty of any kind, either expressed, implied, or * - * statutory, including, without limitation, warranties that the * - * Covered Software is free of defects, merchantable, fit for a * - * particular purpose or non-infringing. The entire risk as to the * - * quality and performance of the Covered Software is with You. * - * Should any Covered Software prove defective in any respect, You * - * (not any Contributor) assume the cost of any necessary servicing, * - * repair, or correction. This disclaimer of warranty constitutes an * - * essential part of this License. No use of any Covered Software is * - * authorized under this License except under this disclaimer. * - * * - ************************************************************************ - - ************************************************************************ - * * - * 7. Limitation of Liability * - * -------------------------- * - * * - * Under no circumstances and under no legal theory, whether tort * - * (including negligence), contract, or otherwise, shall any * - * Contributor, or anyone who distributes Covered Software as * - * permitted above, be liable to You for any direct, indirect, * - * special, incidental, or consequential damages of any character * - * including, without limitation, damages for lost profits, loss of * - * goodwill, work stoppage, computer failure or malfunction, or any * - * and all other commercial damages or losses, even if such party * - * shall have been informed of the possibility of such damages. This * - * limitation of liability shall not apply to liability for death or * - * personal injury resulting from such party's negligence to the * - * extent applicable law prohibits such limitation. Some * - * jurisdictions do not allow the exclusion or limitation of * - * incidental or consequential damages, so this exclusion and * - * limitation may not apply to You. * - * * - ************************************************************************ - - 8. Litigation - ------------- - - Any litigation relating to this License may be brought only in the - courts of a jurisdiction where the defendant maintains its principal - place of business and such litigation shall be governed by laws of that - jurisdiction, without reference to its conflict-of-law provisions. - Nothing in this Section shall prevent a party's ability to bring - cross-claims or counter-claims. - - 9. Miscellaneous - ---------------- - - This License represents the complete agreement concerning the subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. Any law or regulation which provides - that the language of a contract shall be construed against the drafter - shall not be used to construe this License against a Contributor. - - 10. Versions of the License - --------------------------- - - 10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section - 10.3, no one other than the license steward has the right to modify or - publish new versions of this License. Each version will be given a - distinguishing version number. - - 10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version - of the License under which You originally received the Covered Software, - or under the terms of any subsequent version published by the license - steward. - - 10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a - modified version of this License if you rename the license and remove - any references to the name of the license steward (except to note that - such modified license differs from this License). - - 10.4. Distributing Source Code Form that is Incompatible With Secondary - Licenses - - If You choose to distribute Source Code Form that is Incompatible With - Secondary Licenses under the terms of this version of the License, the - notice described in Exhibit B of this License must be attached. - - Exhibit A - Source Code Form License Notice - ------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - - If it is not possible or desirable to put the notice in a particular - file, then You may include the notice in a location (such as a LICENSE - file in a relevant directory) where a recipient would be likely to look - for such a notice. - - You may add additional accurate notices of copyright ownership. - - Exhibit B - "Incompatible With Secondary Licenses" Notice - --------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + + 2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + (a) for any code that a Contributor has removed from Covered Software; + or + + (b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + (c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + + 2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + + 2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights + to grant the rights to its Contributions conveyed by this License. + + 2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + + 2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted + in Section 2.1. + + 3. Responsibilities + + ------------------- + + 3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + + 3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + (a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + + (b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + + 3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + + 3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, + or limitations of liability) contained within the Source Code Form of + the Covered Software, except that You may alter any license notices to + the extent required to remedy known factual inaccuracies. + + 3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + + 4. Inability to Comply Due to Statute or Regulation + + --------------------------------------------------- + + If it is impossible for You to comply with any of the terms of this + License with respect to some or all of the Covered Software due to + statute, judicial order, or regulation then You must: (a) comply with + the terms of this License to the maximum extent possible; and (b) + describe the limitations and the code they affect. Such description must + be placed in a text file included with all distributions of the Covered + Software under this License. Except to the extent prohibited by statute + or regulation, such description must be sufficiently detailed for a + recipient of ordinary skill to be able to understand it. + + 5. Termination + + -------------- + + 5.1. The rights granted under this License will terminate automatically + if You fail to comply with any of its terms. However, if You become + compliant, then the rights granted under this License from a particular + Contributor are reinstated (a) provisionally, unless and until such + Contributor explicitly and finally terminates Your grants, and (b) on an + ongoing basis, if such Contributor fails to notify You of the + non-compliance by some reasonable means prior to 60 days after You have + come back into compliance. Moreover, Your grants from a particular + Contributor are reinstated on an ongoing basis if such Contributor + notifies You of the non-compliance by some reasonable means, this is the + first time You have received notice of non-compliance with this License + from such Contributor, and You become compliant prior to 30 days after + Your receipt of the notice. + + 5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + + 5.3. In the event of termination under Sections 5.1 or 5.2 above, all + end user license agreements (excluding distributors and resellers) which + have been validly granted by You or Your distributors under this License + prior to termination shall survive termination. + + ************************************************************************ + +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * + + ************************************************************************ + + ************************************************************************ + +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * + + ************************************************************************ + + 8. Litigation + + ------------- + + Any litigation relating to this License may be brought only in the + courts of a jurisdiction where the defendant maintains its principal + place of business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. + Nothing in this Section shall prevent a party's ability to bring + cross-claims or counter-claims. + + 9. Miscellaneous + + ---------------- + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides + that the language of a contract shall be construed against the drafter + shall not be used to construe this License against a Contributor. + + 10. Versions of the License + + --------------------------- + + 10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + + 10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + + 10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + + 10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses + + If You choose to distribute Source Code Form that is Incompatible With + Secondary Licenses under the terms of this version of the License, the + notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice + ------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at . + + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to look + for such a notice. + + You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + --------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/README.md b/README.md index 33acaca6..8ab4382e 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,17 @@ -# DCISolver - Dynamic Control of Infeasibility Solver - -| **Documentation** | **CI** | **Coverage** | **Release** | **DOI** | -|:-----------------:|:------:|:------------:|:-----------:|:-------:| -| [![docs-stable][docs-stable-img]][docs-stable-url] [![docs-dev][docs-dev-img]][docs-dev-url] | [![build-ci][build-ci-img]][build-ci-url] | [![codecov][codecov-img]][codecov-url] | [![release][release-img]][release-url] | [![doi][doi-img]][doi-url] | - -[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg -[docs-stable-url]: https://JuliaSmoothOptimizers.github.io/DCISolver.jl/stable -[docs-dev-img]: https://img.shields.io/badge/docs-dev-purple.svg -[docs-dev-url]: https://JuliaSmoothOptimizers.github.io/DCISolver.jl/dev -[build-ci-img]: https://github.com/JuliaSmoothOptimizers/DCISolver.jl/workflows/CI/badge.svg?branch=main -[build-ci-url]: https://github.com/JuliaSmoothOptimizers/DCISolver.jl/actions -[codecov-img]: https://codecov.io/gh/JuliaSmoothOptimizers/DCISolver.jl/branch/main/graph/badge.svg -[codecov-url]: https://codecov.io/gh/JuliaSmoothOptimizers/DCISolver.jl -[release-img]: https://img.shields.io/github/v/release/JuliaSmoothOptimizers/DCISolver.jl.svg?style=flat-square -[release-url]: https://github.com/JuliaSmoothOptimizers/DCISolver.jl/releases -[doi-img]: https://joss.theoj.org/papers/10.21105/joss.03991/status.svg -[doi-url]: https://doi.org/10.21105/joss.03991 +# DCISolver + +[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaSmoothOptimizers.github.io/DCISolver.jl/stable) +[![In development documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaSmoothOptimizers.github.io/DCISolver.jl/dev) +[![Build Status](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/workflows/Test/badge.svg)](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/actions) +[![Test workflow status](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/actions/workflows/Test.yml/badge.svg?branch=main)](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/actions/workflows/Test.yml?query=branch%3Amain) +[![Lint workflow Status](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/actions/workflows/Lint.yml/badge.svg?branch=main)](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/actions/workflows/Lint.yml?query=branch%3Amain) +[![Docs workflow Status](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/actions/workflows/Docs.yml/badge.svg?branch=main)](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/actions/workflows/Docs.yml?query=branch%3Amain) +[![Coverage](https://codecov.io/gh/JuliaSmoothOptimizers/DCISolver.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaSmoothOptimizers/DCISolver.jl) +[![Release](https://img.shields.io/github/v/release/JuliaSmoothOptimizers/DCISolver.jl.svg?style=flat-square)](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/releases) +[![DOI](https://joss.theoj.org/papers/10.21105/joss.03991/status.svg)](https://doi.org/10.21105/joss.03991) +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md) +[![All Contributors](https://img.shields.io/github/all-contributors/JuliaSmoothOptimizers/DCISolver.jl?labelColor=5e1ec7&color=c0ffee&style=flat-square)](#contributors) +[![BestieTemplate](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/JuliaBesties/BestieTemplate.jl/main/docs/src/assets/badge.json)](https://github.com/JuliaBesties/BestieTemplate.jl) DCI is a solver for equality-constrained nonlinear problems, i.e., optimization problems of the form @@ -41,7 +37,7 @@ The feasibility steps are factorization-free and use iterative methods from [Kry ## How to Cite -If you use DCISolver.jl in your work, please cite using the format given in [CITATION.cff](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/main/CITATION.cff). +If you use DCISolver.jl in your work, please cite using the reference given in [CITATION.cff](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/main/CITATION.cff). ## Installation @@ -69,3 +65,20 @@ If you think you found a bug, feel free to open an [issue](https://github.com/Ju 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. If you want to ask a question not suited for a bug report, feel free to start a discussion [here](https://github.com/JuliaSmoothOptimizers/Organization/discussions). This forum is for general discussion about this repository and the [JuliaSmoothOptimizers](https://github.com/JuliaSmoothOptimizers), so questions about any of our packages are welcome. + +## Contributing + +If you want to make contributions of any kind, please first that a look into our [contributing guide directly on GitHub](docs/src/90-contributing.md) or the [contributing page on the website](https://JuliaSmoothOptimizers.github.io/DCISolver.jl/dev/90-contributing/) + +--- + +### Contributors + + + + + + + + + diff --git a/benchmark/Jenkinsfile b/benchmark/Jenkinsfile index 70064b57..e15cfa35 100644 --- a/benchmark/Jenkinsfile +++ b/benchmark/Jenkinsfile @@ -12,7 +12,7 @@ pipeline { GenericTrigger( genericVariables: [ [ - key: 'action', + key: 'action', value: '$.action', expressionType: 'JSONPath', //Optional, defaults to JSONPath regexpFilter: '[^(created)]', //Optional, defaults to empty string @@ -100,7 +100,7 @@ pipeline { git fetch origin git pull --ff-only origin master ''' - } + } } } stage('run benchmarks') { @@ -117,13 +117,13 @@ pipeline { dir(WORKSPACE + "/$repo") { sh "mkdir -p $HOME/benchmarks/${org}/${repo}" sh "qsub -N ${repo}_${pullrequest} -V -cwd -o $HOME/benchmarks/${org}/${repo}/${pullrequest}_${BUILD_NUMBER}_bmark_output.log -e $HOME/benchmarks/${org}/${repo}/${pullrequest}_${BUILD_NUMBER}_bmark_error.log ../BenchmarkSetup/benchmark/push_benchmarks.sh ${bmarkFile}" - } + } } } } post { success { - echo "SUCCESS!" + echo "SUCCESS!" } cleanup { sh 'printenv' diff --git a/docs/assets/example.jl b/docs/assets/example.jl index fb8a8d3f..689b57e1 100644 --- a/docs/assets/example.jl +++ b/docs/assets/example.jl @@ -64,7 +64,17 @@ ncon = Gridap.FESpaces.num_free_dofs(Ycon) x0 = zeros(npde + ncon); # Overall, we built a GridapPDENLPModel, which implements the [NLPModels.jl](https://github.com/JuliaSmoothOptimizers/NLPModels.jl) API. -nlp = GridapPDENLPModel(x0, f, trian, Ypde, Ycon, Xpde, Xcon, op, name = "Control elastic membrane") +nlp = GridapPDENLPModel( + x0, + f, + trian, + Ypde, + Ycon, + Xpde, + Xcon, + op, + name = "Control elastic membrane", +) (nlp.meta.nvar, nlp.meta.ncon) diff --git a/docs/make.jl b/docs/make.jl index 036d371e..7bbafec4 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,46 +1,23 @@ -ENV["GKSwstype"] = "100" -using ADNLPModels -using Documenter -using Printf using DCISolver -using Literate - -EXAMPLE = joinpath(@__DIR__, "assets", "example.jl") -OUTPUT = joinpath(@__DIR__, "src") - -# Generate markdown -binder_badge = "# [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/JuliaSmoothOptimizers/DCISolver.jl/gh-pages?labpath=dev%2Fexample.ipynb)" -function preprocess_docs(content) - return string(binder_badge, "\n\n", content) -end - -Literate.markdown(EXAMPLE, OUTPUT; preprocess = preprocess_docs, codefence = "```julia" => "```") +using Documenter -link_to_env = "# The environment used in this tutorial is the following [Project.toml](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/gh-pages/Project.toml) and [Manifest.toml](https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/gh-pages/Manifest.toml). " -function preprocess_notebook(content) - return string(link_to_env, "\n\n", content) -end -Literate.notebook(EXAMPLE, OUTPUT; preprocess = preprocess_notebook) -Literate.script(EXAMPLE, OUTPUT) +DocMeta.setdocmeta!(DCISolver, :DocTestSetup, :(using DCISolver); recursive = true) -pages = [ - "Introduction" => "index.md", - "Benchmark" => "benchmark.md", - "Fine-tune DCI" => "fine-tuneDCI.md", - "Large-scale example" => "example.md", - "Reference" => "reference.md", +const page_rename = Dict("developer.md" => "Developer docs") # Without the numbers +const numbered_pages = [ + file for file in readdir(joinpath(@__DIR__, "src")) if + file != "index.md" && splitext(file)[2] == ".md" ] -makedocs( - sitename = "DCISolver.jl", - strict = true, - format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"), +makedocs(; modules = [DCISolver], - pages = pages, + authors = "Abel Soares Siqueira and Tangi Migot ", + repo = "https://github.com/JuliaSmoothOptimizers/DCISolver.jl/blob/{commit}{path}#{line}", + sitename = "DCISolver.jl", + format = Documenter.HTML(; + canonical = "https://JuliaSmoothOptimizers.github.io/DCISolver.jl", + ), + pages = ["index.md"; numbered_pages], ) -deploydocs( - repo = "github.com/JuliaSmoothOptimizers/DCISolver.jl.git", - push_preview = true, - devbranch = "main", -) +deploydocs(; repo = "github.com/JuliaSmoothOptimizers/DCISolver.jl") diff --git a/docs/src/90-contributing.md b/docs/src/90-contributing.md new file mode 100644 index 00000000..f211e737 --- /dev/null +++ b/docs/src/90-contributing.md @@ -0,0 +1,25 @@ +# [Contributing guidelines](@id contributing) + +First of all, thanks for the interest! + +We welcome all kinds of contribution, including, but not limited to code, documentation, examples, configuration, issue creating, etc. + +Be polite and respectful, and follow the code of conduct. + +## Bug reports and discussions + +If you think you found a bug, feel free to open an [issue](https://github.com/JuliaSmoothOptimizers/DCISolver.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. + +## Working on an issue + +If you found an issue that interests you, comment on that issue what your plans are. +If the solution to the issue is clear, you can immediately create a pull request (see below). +Otherwise, say what your proposed solution is and wait for a discussion around it. + +!!! tip + Feel free to ping us after a few days if there are no responses. + +If your solution involves code (or something that requires running the package locally), check the [developer documentation](91-developer.md). +Otherwise, you can use the GitHub interface directly to create your pull request. diff --git a/docs/src/91-developer.md b/docs/src/91-developer.md new file mode 100644 index 00000000..f4a99358 --- /dev/null +++ b/docs/src/91-developer.md @@ -0,0 +1,163 @@ +# [Developer documentation](@id dev_docs) + +!!! note "Contributing guidelines" + If you haven't, please read the [Contributing guidelines](90-contributing.md) first. + +If you want to make contributions to this package that involves code, then this guide is for you. + +## First time clone + +!!! tip "If you have writing rights" + If you have writing rights, you don't have to fork. Instead, simply clone and skip ahead. Whenever **upstream** is mentioned, use **origin** instead. + +If this is the first time you work with this repository, follow the instructions below to clone the repository. + +1. Fork this repo +2. Clone your repo (this will create a `git remote` called `origin`) +3. Add this repo as a remote: + + ```bash + git remote add upstream https://github.com/JuliaSmoothOptimizers/DCISolver.jl + ``` + +This will ensure that you have two remotes in your git: `origin` and `upstream`. +You will create branches and push to `origin`, and you will fetch and update your local `main` branch from `upstream`. + +## Linting and formatting + +Install a plugin on your editor to use [EditorConfig](https://editorconfig.org). +This will ensure that your editor is configured with important formatting settings. + +We use [https://pre-commit.com](https://pre-commit.com) to run the linters and formatters. +In particular, the Julia code is formatted using [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl), so please install it globally first: + +```julia-repl +julia> # Press ] +pkg> activate +pkg> add JuliaFormatter +``` + +To install `pre-commit`, we recommend using [pipx](https://pipx.pypa.io) as follows: + +```bash +# Install pipx following the link +pipx install pre-commit +``` + +With `pre-commit` installed, activate it as a pre-commit hook: + +```bash +pre-commit install +``` + +To run the linting and formatting manually, enter the command below: + +```bash +pre-commit run -a +``` + +**Now, you can only commit if all the pre-commit tests pass**. + +## Testing + +As with most Julia packages, you can just open Julia in the repository folder, activate the environment, and run `test`: + +```julia-repl +julia> # press ] +pkg> activate . +pkg> test +``` + +## Working on a new issue + +We try to keep a linear history in this repo, so it is important to keep your branches up-to-date. + +1. Fetch from the remote and fast-forward your local main + + ```bash + git fetch upstream + git switch main + git merge --ff-only upstream/main + ``` + +2. Branch from `main` to address the issue (see below for naming) + + ```bash + git switch -c 42-add-answer-universe + ``` + +3. Push the new local branch to your personal remote repository + + ```bash + git push -u origin 42-add-answer-universe + ``` + +4. Create a pull request to merge your remote branch into the org main. + +### Branch naming + +- If there is an associated issue, add the issue number. +- If there is no associated issue, **and the changes are small**, add a prefix such as "typo", "hotfix", "small-refactor", according to the type of update. +- If the changes are not small and there is no associated issue, then create the issue first, so we can properly discuss the changes. +- Use dash separated imperative wording related to the issue (e.g., `14-add-tests`, `15-fix-model`, `16-remove-obsolete-files`). + +### Commit message + +- Use imperative or present tense, for instance: *Add feature* or *Fix bug*. +- Have informative titles. +- When necessary, add a body with details. +- If there are breaking changes, add the information to the commit message. + +### Before creating a pull request + +!!! tip "Atomic git commits" + Try to create "atomic git commits" (recommended reading: [The Utopic Git History](https://blog.esciencecenter.nl/the-utopic-git-history-d44b81c09593)). + +- Make sure the tests pass. +- Make sure the pre-commit tests pass. +- Fetch any `main` updates from upstream and rebase your branch, if necessary: + + ```bash + git fetch upstream + git rebase upstream/main BRANCH_NAME + ``` + +- Then you can open a pull request and work with the reviewer to address any issues. + +## Building and viewing the documentation locally + +Following the latest suggestions, we recommend using `LiveServer` to build the documentation. +Here is how you do it: + +1. Run `julia --project=docs` to open Julia in the environment of the docs. +1. If this is the first time building the docs + 1. Press `]` to enter `pkg` mode + 1. Run `pkg> dev .` to use the development version of your package + 1. Press backspace to leave `pkg` mode +1. Run `julia> using LiveServer` +1. Run `julia> servedocs()` + +## Making a new release + +To create a new release, you can follow these simple steps: + +- Create a branch `release-x.y.z` +- Update `version` in `Project.toml` +- Update the `CHANGELOG.md`: + - Rename the section "Unreleased" to "[x.y.z] - yyyy-mm-dd" (i.e., version under brackets, dash, and date in ISO format) + - Add a new section on top of it named "Unreleased" + - Add a new link in the bottom for version "x.y.z" + - Change the "[unreleased]" link to use the latest version - end of line, `vx.y.z ... HEAD`. +- Create a commit "Release vx.y.z", push, create a PR, wait for it to pass, merge the PR. +- Go back to main screen and click on the latest commit (link: ) +- At the bottom, write `@JuliaRegistrator register` + +After that, you only need to wait and verify: + +- Wait for the bot to comment (should take < 1m) with a link to a RP to the registry +- Follow the link and wait for a comment on the auto-merge +- The comment should said all is well and auto-merge should occur shortly +- After the merge happens, TagBot will trigger and create a new GitHub tag. Check on +- After the release is create, a "docs" GitHub action will start for the tag. +- After it passes, a deploy action will run. +- After that runs, the [stable docs](https://JuliaSmoothOptimizers.github.io/DCISolver.jl/stable) should be updated. Check them and look for the version number. diff --git a/docs/src/95-reference.md b/docs/src/95-reference.md new file mode 100644 index 00000000..96759ff0 --- /dev/null +++ b/docs/src/95-reference.md @@ -0,0 +1,17 @@ +# [Reference](@id reference) + +## Contents + +```@contents +Pages = ["95-reference.md"] +``` + +## Index + +```@index +Pages = ["95-reference.md"] +``` + +```@autodocs +Modules = [DCISolver] +``` diff --git a/docs/src/benchmark.md b/docs/src/benchmark.md index 469a40ff..8062ea80 100644 --- a/docs/src/benchmark.md +++ b/docs/src/benchmark.md @@ -2,13 +2,14 @@ ## CUTEst benchmark -With a JSO-compliant solver, such as DCI, we can run the solver on a set of problems, explore the results, and compare to other JSO-compliant solvers using specialized benchmark tools. +With a JSO-compliant solver, such as DCI, we can run the solver on a set of problems, explore the results, and compare to other JSO-compliant solvers using specialized benchmark tools. We are following here the tutorial in [SolverBenchmark.jl](https://jso.dev/SolverBenchmark.jl/v0.3/tutorial/) to run benchmarks on JSO-compliant solvers. + ``` @example ex1 using CUTEst ``` -To test the implementation of DCI, we use the package [CUTEst.jl](https://github.com/JuliaSmoothOptimizers/CUTEst.jl), which implements `CUTEstModel` an instance of `AbstractNLPModel`. +To test the implementation of DCI, we use the package [CUTEst.jl](https://github.com/JuliaSmoothOptimizers/CUTEst.jl), which implements `CUTEstModel` an instance of `AbstractNLPModel`. ``` @example ex1 using SolverBenchmark @@ -18,11 +19,11 @@ Let us select equality-constrained problems from CUTEst with a maximum of 100 va ``` @example ex1 _pnames = CUTEst.select( - max_var = 100, - min_con = 1, - max_con = 100, - only_free_var = true, - only_equ_con = true, + max_var = 100, + min_con = 1, + max_con = 100, + only_free_var = true, + only_equ_con = true, objtype = 3:6 ) @@ -39,6 +40,7 @@ We compare here DCISolver with [Ipopt](https://link.springer.com/article/10.1007 ``` @example ex1 using DCISolver, NLPModelsIpopt ``` + To make stopping conditions comparable, we set `Ipopt`'s parameters `dual_inf_tol=Inf`, `constr_viol_tol=Inf` and `compl_inf_tol=Inf` to disable additional stopping conditions related to those tolerances, `acceptable_iter=0` to disable the search for an acceptable point. ``` @example ex1 @@ -73,28 +75,34 @@ solvers = Dict( stats = bmark_solvers(solvers, cutest_problems) ``` + The function `bmark_solvers` return a `Dict` of `DataFrames` with detailed information on the execution. This output can be saved in a data file. + ``` @example ex1 using JLD2 @save "ipopt_dcildl_$(string(length(pnames))).jld2" stats ``` + The result of the benchmark can be explored via tables, + ``` @example ex1 pretty_stats(stats[:dcildl]) ``` + or it can also be used to make performance profiles. + ``` @example ex1 using Plots gr() legend = Dict( - :neval_obj => "number of f evals", - :neval_cons => "number of c evals", - :neval_grad => "number of ∇f evals", - :neval_jac => "number of ∇c evals", - :neval_jprod => "number of ∇c*v evals", - :neval_jtprod => "number of ∇cᵀ*v evals", - :neval_hess => "number of ∇²f evals", + :neval_obj => "number of f evals", + :neval_cons => "number of c evals", + :neval_grad => "number of ∇f evals", + :neval_jac => "number of ∇c evals", + :neval_jprod => "number of ∇c*v evals", + :neval_jtprod => "number of ∇cᵀ*v evals", + :neval_hess => "number of ∇²f evals", :elapsed_time => "elapsed time" ) perf_title(col) = "Performance profile on CUTEst w.r.t. $(string(legend[col]))" @@ -102,7 +110,7 @@ perf_title(col) = "Performance profile on CUTEst w.r.t. $(string(legend[col]))" styles = [:solid,:dash,:dot,:dashdot] #[:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] function print_pp_column(col::Symbol, stats) - + ϵ = minimum(minimum(filter(x -> x > 0, df[!, col])) for df in values(stats)) first_order(df) = df.status .== :first_order unbounded(df) = df.status .== :unbounded @@ -110,10 +118,10 @@ function print_pp_column(col::Symbol, stats) cost(df) = (max.(df[!, col], ϵ) + .!solved(df) .* Inf) p = performance_profile( - stats, - cost, - title=perf_title(col), - legend=:bottomright, + stats, + cost, + title=perf_title(col), + legend=:bottomright, linestyles=styles ) end diff --git a/docs/src/fine-tuneDCI.md b/docs/src/fine-tuneDCI.md index 62b5596b..d7b04ccf 100644 --- a/docs/src/fine-tuneDCI.md +++ b/docs/src/fine-tuneDCI.md @@ -12,6 +12,7 @@ It is also possible to fine-tune the parameters used in the implementation in tw ## Examples DCISolver.jl exports the function `dci`: + ``` dci(nlp :: AbstractNLPModel) dci(nlp :: AbstractNLPModel, x :: AbstractVector) @@ -19,6 +20,7 @@ DCISolver.jl exports the function `dci`: solve!(workspace :: DCIWorkspace, nlp :: AbstractNLPModel) solve!(workspace :: DCIWorkspace, nlp :: AbstractNLPModel, stats :: GenericExecutionStats) ``` + where `MetaDCI` is a structure handling all the parameters used in the algorithm, and `DCIWorkspace` pre-allocates all the memory used during the iterative process. It is therefore possible to either call `dci(nlp, x, kwargs...)` and the keywords arguments are passed to the `MetaDCI` constructor or build an instance of `MetaDCI` directly. @@ -27,27 +29,29 @@ It is therefore possible to either call `dci(nlp, x, kwargs...)` and the keyword using ADNLPModels, DCISolver nlp = ADNLPModel( - x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, + x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0], - x->[x[1] * x[2] - 1], + x->[x[1] * x[2] - 1], [0.0], [0.0], name = "Rosenbrock with x₁x₂=1" ) #The alternative would be: stats = dci( - nlp, nlp.meta.x0, - max_time = 600., - linear_solver = :ldlfact, + nlp, nlp.meta.x0, + max_time = 600., + linear_solver = :ldlfact, TR_compute_step = :TR_lsmr ) ``` + The alternative would be: + ```@example ex1 meta = DCISolver.MetaDCI( - nlp.meta.x0, nlp.meta.y0, - max_time = 600., - linear_solver = :ldlfact, + nlp.meta.x0, nlp.meta.y0, + max_time = 600., + linear_solver = :ldlfact, TR_compute_step = :TR_lsmr ) stats = dci(nlp, meta, nlp.meta.x0) @@ -67,7 +71,9 @@ stats = solve!(workspace, nlp) Find below a list of the main options of `dci`. ### Tolerances on the problem + We use `ϵ = atol + rtol * dualnorm`. + ``` | Parameters | Type | Default | Description | | -------------------- | ------------- | ------------ | ---------------------------------------------- | @@ -82,6 +88,7 @@ We use `ϵ = atol + rtol * dualnorm`. ``` ### Compute Lagrange multipliers + ``` | Parameters | Type | Default | Description | | ----------- | ----------- | ----------------------------------------------- | ----------------------------------------------------- | @@ -90,10 +97,11 @@ We use `ϵ = atol + rtol * dualnorm`. ``` ### Tangent step + ``` | Parameters | Type | Default | Description | | ------------- | ------------- | -------- | --------------------------------------------------------------------------------------------------------- | -| linear_solver | Symbol | :ldlfact | Solver for the factorization. options: :ma57. | +| linear_solver | Symbol | :ldlfact | Solver for the factorization. options: :ma57. | | decrease_γ | AbstractFloat | 0.1 | Regularization for the factorization: reduce γ if possible, > √eps(T), between tangent steps. | | increase_γ | AbstractFloat | 100.0 | Regularization for the factorization: up γ if possible, < 1/√eps(T), during the factorization. | | δmin | AbstractFloat | √eps(T) | Regularization for the factorization: smallest value of δ used for the regularization. | @@ -105,7 +113,9 @@ We use `ϵ = atol + rtol * dualnorm`. | tan_small_d | AbstractFloat | eps(T) | Tangent step trust-region parameters: ||d|| is too small. | | increase_Δtg | AbstractFloat | 10.0 | Tangent step trust-region parameters: increase if possible, < 1 / √eps(T), the Δtg between tangent steps. | ``` + ### Normal step + ``` | Parameters | Type | Default | Description | | ---------------------- | --------------------------------------- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | @@ -120,7 +130,9 @@ We use `ϵ = atol + rtol * dualnorm`. | TR_compute_step | Symbol | :TR_lsmr | Compute the direction in feasibility step: options: :TR_dogleg. | | TR_compute_step_struct | Union{TR_lsmr_struct, TR_dogleg_struct} | TR_lsmr_struct(length(x0), length(y0), typeof(x0)) | Compute the direction in feasibility step: options: TR_dogleg_struct(length(x0), length(y0), typeof(x0)). | ``` + ### Parameters updating ρ (or redefine the function `compute_ρ`) + ``` | Parameters | Type | Default | Description | | ----------- | ------------- | ------- | --------------------------------------------------------------- | @@ -128,4 +140,5 @@ We use `ϵ = atol + rtol * dualnorm`. | compρ_p2 | AbstractFloat | 0.90 | update ρ as `ρ = primalnorm * p2` if not sufficiently feasible. | | ρbar | AbstractFloat | 2.0 | radius of the larger cylinder is `ρbar * ρ`. | ``` + The computation of ρ can also be modified by importing `compute_ρ(dualnorm, primalnorm, norm∇fx, ρmax, ϵ, iter, meta::MetaDCI)` diff --git a/docs/src/index.md b/docs/src/index.md index da76ac3d..0244ebae 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,3 +1,7 @@ +```@meta +CurrentModule = DCISolver +``` + # DCISolver - Dynamic Control of Infeasibility Solver DCI is a solver for equality-constrained nonlinear problems, i.e., @@ -26,6 +30,7 @@ We refer to [jso.dev](https://jso.dev) for tutorials on the NLPModel API. This f ## Installation `DCISolver` is a registered package. To install this package, open the Julia REPL (i.e., execute the julia binary), type `]` to enter package mode, and install `DCISolver` as follows + ``` add DCISolver ``` @@ -38,16 +43,19 @@ The feasibility steps are factorization-free and use iterative methods from [Kry ## Example We consider in this example the minization of the Rosenbrock function over an equality constraint. + ```math \min_x \ 100 * (x₂ - x₁²)² + (x₁ - 1)² \quad \text{s.t.} \quad x₁x₂=1, ``` + The problem is modeled using `ADNLPModels.jl` with `[-1.2; 1.0]` as default initial point, and then solved using `dci`. + ```@example using DCISolver, ADNLPModels, Logging nlp = ADNLPModel( - x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, + x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0], - x -> [x[1] * x[2] - 1], + x -> [x[1] * x[2] - 1], [0.0], [0.0], name = "Rosenbrock with x₁x₂=1" ) @@ -56,9 +64,22 @@ stats = dci(nlp, verbose = 0) println(stats) ``` -# Bug reports and discussions +## Bug reports and discussions If you think you found a bug, feel free to open an [issue](https://github.com/JuliaSmoothOptimizers/DCISolver.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. If you want to ask a question not suited for a bug report, feel free to start a discussion [here](https://github.com/JuliaSmoothOptimizers/Organization/discussions). This forum is for general discussion about this repository and the [JuliaSmoothOptimizers](https://github.com/JuliaSmoothOptimizers), so questions about any of our packages are welcome. + +## Contributors + +```@raw html + + + + + + + + +``` diff --git a/docs/src/reference.md b/docs/src/reference.md index 573d69d9..2987bd12 100644 --- a/docs/src/reference.md +++ b/docs/src/reference.md @@ -1,17 +1,27 @@ # Reference + ​ + ## Contents + ​ + ```@contents Pages = ["reference.md"] ``` + ​ + ## Index + ​ + ```@index Pages = ["reference.md"] ``` + ​ + ```@autodocs Modules = [DCISolver] -``` \ No newline at end of file +``` diff --git a/src/DCISolver.jl b/src/DCISolver.jl index 5259fd67..88ffb199 100644 --- a/src/DCISolver.jl +++ b/src/DCISolver.jl @@ -94,18 +94,18 @@ function dci( end function dci( nlp::AbstractNLPModel, - meta::MetaDCI{T, In, COO}, + meta::MetaDCI{T,In,COO}, x::AbstractVector{T}; callback = (args...) -> nothing, kwargs..., -) where {T, In, COO} +) where {T,In,COO} workspace = DCIWorkspace(nlp, meta, x) return solve!(workspace, nlp; callback = callback) end """ compute_gBg(nlp, rows, cols, vals, ∇ℓzλ) - + Compute `gBg = ∇ℓxλ' * B * ∇ℓxλ`, where `B` is a symmetric sparse matrix whose lower triangular is given in COO-format. """ function compute_gBg( @@ -136,7 +136,7 @@ function regularized_coo_saddle_system!( vals::AbstractVector{T}; γ::T = zero(T), δ::T = zero(T), -) where {S <: Int, T <: AbstractFloat} +) where {S<:Int,T<:AbstractFloat} #n = nlp.meta.nnzh + nlp.meta.nnzj + nlp.meta.nvar + nlp.meta.ncon #Test length rows, cols, vals #@lencheck n rows cols vals @@ -175,7 +175,7 @@ function compute_lx!( ∇fx::AbstractVector{T}, λ::AbstractVector{T}, meta::MetaDCI, -) where {T <: AbstractFloat} +) where {T<:AbstractFloat} l = meta.λ_struct.comp_λ_solver.x stats = meta.λ_struct.comp_λ_solver.stats Krylov.solve!( diff --git a/src/SymCOOSolverInterface/SymCOOSolverInterface.jl b/src/SymCOOSolverInterface/SymCOOSolverInterface.jl index 920e0bbf..3432f117 100644 --- a/src/SymCOOSolverInterface/SymCOOSolverInterface.jl +++ b/src/SymCOOSolverInterface/SymCOOSolverInterface.jl @@ -35,7 +35,7 @@ function success end """ isposdef(M :: SymCOOSolver) -Returns whether `M` is positive definite. +Returns whether `M` is positive definite. """ """ diff --git a/src/SymCOOSolverInterface/hsl.jl b/src/SymCOOSolverInterface/hsl.jl index acc79703..8dc9dedd 100644 --- a/src/SymCOOSolverInterface/hsl.jl +++ b/src/SymCOOSolverInterface/hsl.jl @@ -3,14 +3,14 @@ using HSL export MA57Struct const Ma57Type = if isdefined(HSL, :libhsl_ma57) - Union{Nothing, Ma57} + Union{Nothing,Ma57} else Nothing end mutable struct MA57Struct <: SymCOOSolver factor::Ma57Type - work + work::Any end function MA57Struct(N, rows, cols, vals) diff --git a/src/SymCOOSolverInterface/ldlfactorizations.jl b/src/SymCOOSolverInterface/ldlfactorizations.jl index c0175c16..e4a33946 100644 --- a/src/SymCOOSolverInterface/ldlfactorizations.jl +++ b/src/SymCOOSolverInterface/ldlfactorizations.jl @@ -3,13 +3,13 @@ using LDLFactorizations, LinearAlgebra, SparseArrays export LDLFactorizationStruct # LDLFactorizations -mutable struct LDLFactorizationStruct{T <: AbstractFloat, Ti <: Int} <: SymCOOSolver +mutable struct LDLFactorizationStruct{T<:AbstractFloat,Ti<:Int} <: SymCOOSolver ndim::Int rows::Vector{Ti} cols::Vector{Ti} vals::Vector{T} factorized::Bool #factor.__factorized is for memory allocation - factor #specify the structure + factor::Any #specify the structure end #r1, r2, tol, n_d parameters for the dynamic regularization @@ -22,7 +22,7 @@ function LDLFactorizationStruct( r2::Real = zero(T), tol::Real = zero(T), n_d::Int = 0, -) where {T, Ti} +) where {T,Ti} A = sparse(cols, rows, vals, ndim, ndim) S = ldl_analyze(Symmetric(A, :U)) S.r1 = r1 #-ϵ @@ -47,12 +47,12 @@ function success(M::LDLFactorizationStruct) !isnothing(M.factor) && M.factorized end -function isposdef(M::LDLFactorizationStruct{T, Ti}) where {T, Ti} +function isposdef(M::LDLFactorizationStruct{T,Ti}) where {T,Ti} ϵ = eps(T) success(M) && count(M.factor.d .≤ -ϵ) == 0 end -function num_neg_eig(M::LDLFactorizationStruct{T, Ti}) where {T, Ti} +function num_neg_eig(M::LDLFactorizationStruct{T,Ti}) where {T,Ti} ϵ = eps(T) count(M.factor.d .≤ -ϵ) end diff --git a/src/dci_feasibility.jl b/src/dci_feasibility.jl index 0cfa5c7f..831ded76 100644 --- a/src/dci_feasibility.jl +++ b/src/dci_feasibility.jl @@ -101,7 +101,7 @@ function feasibility_step( Any[ "F", feas_iter, - neval_obj(nlp) + neval_cons(nlp), + neval_obj(nlp)+neval_cons(nlp), Float64, Float64, Float64, @@ -111,7 +111,7 @@ function feasibility_step( status, norm(d), Δ, - time() - start_time, + time()-start_time, ], ) @@ -147,7 +147,7 @@ function feasibility_step( Any[ "F-safe", feas_iter, - neval_obj(nlp) + neval_cons(nlp), + neval_obj(nlp)+neval_cons(nlp), Float64, Float64, Float64, @@ -157,7 +157,7 @@ function feasibility_step( status, norm(d), Δ, - time() - start_time, + time()-start_time, ], ) end diff --git a/src/dci_normal.jl b/src/dci_normal.jl index 4438918d..0977e7b6 100644 --- a/src/dci_normal.jl +++ b/src/dci_normal.jl @@ -87,7 +87,7 @@ function normal_step!( Any[ "N", iter_normal_step, - neval_obj(nlp) + neval_cons(nlp), + neval_obj(nlp)+neval_cons(nlp), fz, ℓzλ, dualnorm, diff --git a/src/dci_tangent.jl b/src/dci_tangent.jl index 1604242f..408c6f87 100644 --- a/src/dci_tangent.jl +++ b/src/dci_tangent.jl @@ -69,8 +69,20 @@ function tangent_step!( while !((normcz ≤ meta.ρbar * ρ && r ≥ η₁) || tired) #Compute a descent direction d (no evals) - d, dBd, status, γ, δ, vals = - compute_descent_direction!(nlp, gBg, g, Δ, LDL, γ, δ, vals, d, meta, workspace, verbose) + d, dBd, status, γ, δ, vals = compute_descent_direction!( + nlp, + gBg, + g, + Δ, + LDL, + γ, + δ, + vals, + d, + meta, + workspace, + verbose, + ) n2d = dot(d, d) if √n2d > Δ d .*= Δ / √n2d #Just in case. @@ -114,7 +126,7 @@ function tangent_step!( Any[ "Tr", iter, - neval_obj(nlp) + neval_cons(nlp), + neval_obj(nlp)+neval_cons(nlp), fz, ℓzλ, Float64, @@ -267,7 +279,12 @@ end Given two directions `dcp` and `dn`, compute the largest `0 ≤ τ ≤ 1` such that `‖dn + τ (dcp -dn)‖ = Δ`. Returns `τ`. """ -function _compute_step_length(norm2dn::T, dotdndcp::T, norm2dcp::T, Δ::T) where {T <: AbstractFloat} +function _compute_step_length( + norm2dn::T, + dotdndcp::T, + norm2dcp::T, + Δ::T, +) where {T<:AbstractFloat} # d = τ dcp + (1 - τ) * dn = dn + τ * (dcp - dn) # ‖d‖² = Δ² => τ² ‖dcp - dn‖² + 2τ dnᵀ(dcp - dn) + ‖dn‖² - Δ² = 0 # Δ = b² - 4ac diff --git a/src/factorization.jl b/src/factorization.jl index 413c6e3c..494694c9 100644 --- a/src/factorization.jl +++ b/src/factorization.jl @@ -32,7 +32,7 @@ function _compute_newton_step!( # When there is room for improvement, we try a dogleg step rhs[1:n] .= -g - rhs[(n + 1):end] .= zero(T) + rhs[(n+1):end] .= zero(T) dnBdn = dcpBdn = zero(T) gnorm = norm(g) slope = NaN @@ -53,11 +53,11 @@ function _compute_newton_step!( if success(LDL) solve!(dζ, LDL, rhs) dn .= dζ[1:n] - dλ = view(dζ, (n + 1):(n + m)) + dλ = view(dζ, (n+1):(n+m)) slope = dot(g, dn) dnBdn = -slope - γ * dot(dn, dn) - δ * dot(dλ, dλ) dcpBdn = -dot(g, dcp) - γ * dot(dcp, dn) # dcpᵀ Aᵀ dλ = 0 - if dnBdn > 0.0 #slope < -1.0e-5 #4 * norm(dn) * gnorm #dnBdn > 0.0 + if dnBdn > 0.0 #slope < -1.0e-5 #4 * norm(dn) * gnorm #dnBdn > 0.0 status = :success descent = true else diff --git a/src/main.jl b/src/main.jl index 3c8428b4..7c802a3e 100644 --- a/src/main.jl +++ b/src/main.jl @@ -1,9 +1,9 @@ function SolverCore.solve!( - workspace::DCIWorkspace{T, S, Si, Op, In, COO}, - nlp::AbstractNLPModel{T, S}, - stats::GenericExecutionStats{T, S, V, Tsp}; + workspace::DCIWorkspace{T,S,Si,Op,In,COO}, + nlp::AbstractNLPModel{T,S}, + stats::GenericExecutionStats{T,S,V,Tsp}; callback = (args...) -> nothing, -) where {T, S, V, Tsp, Si, Op, In, COO} +) where {T,S,V,Tsp,Si,Op,In,COO} meta = get_meta(workspace) if !(nlp.meta.minimize) error("DCI only works for minimization problem") @@ -179,10 +179,10 @@ function SolverCore.solve!( #Update matrix system @views hess_coord!(nlp, z, λ, vals[1:(nlp.meta.nnzh)]) - @views jac_coord!(nlp, z, vals[nlp.meta.nnzh .+ (1:(nlp.meta.nnzj))]) + @views jac_coord!(nlp, z, vals[nlp.meta.nnzh.+(1:(nlp.meta.nnzj))]) if γ != 0.0 γ = max(γ * meta.decrease_γ, √eps(T)) - vals[nlp.meta.nnzh .+ nlp.meta.nnzj .+ (1:(nlp.meta.nvar))] .= γ + vals[nlp.meta.nnzh.+nlp.meta.nnzj.+(1:(nlp.meta.nvar))] .= γ end gBg = compute_gBg(nlp, rows, cols, vals, ∇ℓzλ) diff --git a/src/param_struct.jl b/src/param_struct.jl index 4de63b6a..77d6edc2 100644 --- a/src/param_struct.jl +++ b/src/param_struct.jl @@ -1,18 +1,18 @@ """ - `comp_λ_cgls(m, n, ::DataType; kwargs...)` + `comp_λ_cgls(m, n, ::DataType; kwargs...)` Keyword arguments correspond to input parameters of `cgls` from `Krylov.jl` used in the computation of the Lagrange multipliers. Returns a `comp_λ_cgls` structure. """ -struct comp_λ_cgls{T <: AbstractFloat, S <: AbstractVector{T}} - comp_λ_solver::CglsSolver{T, T, S} - M # =I, - λ::T # =zero(T), - atol::T # =√eps(T), +struct comp_λ_cgls{T<:AbstractFloat,S<:AbstractVector{T}} + comp_λ_solver::CglsSolver{T,T,S} + M::Any # =I, + λ::T # =zero(T), + atol::T # =√eps(T), rtol::T # =√eps(T), - #radius :: T=zero(T), - itmax::Int # =0, - #verbose :: Int=0, + #radius :: T=zero(T), + itmax::Int # =0, + #verbose :: Int=0, #history :: Bool=false end @@ -25,7 +25,7 @@ function comp_λ_cgls( atol::T = √eps(T), rtol::T = √eps(T), itmax::Int = 5 * (m + n), -) where {T, S <: AbstractVector{T}} +) where {T,S<:AbstractVector{T}} comp_λ_solver = CglsSolver(m, n, S) return comp_λ_cgls(comp_λ_solver, M, λ, atol, rtol, itmax) end @@ -49,22 +49,22 @@ else end """ - `TR_lsmr_struct(m, n, ::DataType; kwargs...)` + `TR_lsmr_struct(m, n, ::DataType; kwargs...)` Keyword arguments correspond to input parameters of `lsmr` from `Krylov.jl` used in the computation of the trust-region step. Returns a `TR_lsmr_struct` structure. """ -struct TR_lsmr_struct{T <: AbstractFloat, S <: AbstractVector{T}} - lsmr_solver::LsmrSolver{T, T, S} - M # =I, +struct TR_lsmr_struct{T<:AbstractFloat,S<:AbstractVector{T}} + lsmr_solver::LsmrSolver{T,T,S} + M::Any # =I, #N=I, #unnecessary #sqd :: Bool=false, #unnecessary - λ::T # =zero(T), - axtol::T # =√eps(T), + λ::T # =zero(T), + axtol::T # =√eps(T), btol::T # =√eps(T), - atol::T # =zero(T), + atol::T # =zero(T), rtol::T # =zero(T), - etol::T # =√eps(T), + etol::T # =√eps(T), #window :: Int=5, #unnecessary itmax::Int # =0, #m + n (set in the code if itmax==0) #conlim :: T=1/√eps(T), #set conditioning upper limit @@ -85,22 +85,22 @@ function TR_lsmr_struct( rtol::T = zero(T), etol::T = √eps(T), itmax::Int = m + n, -) where {T, S <: AbstractVector{T}} +) where {T,S<:AbstractVector{T}} lsmr_solver = LsmrSolver(n, m, S) return TR_lsmr_struct(lsmr_solver, M, λ, axtol, btol, atol, rtol, etol, itmax) end """ - `TR_dogleg_struct(m, n, ::DataType; kwargs...)` + `TR_dogleg_struct(m, n, ::DataType; kwargs...)` Keyword arguments correspond to input parameters of `lsmr` from `Krylov.jl` used in the computation of the dogleg for the trust-region step. Returns a `TR_dogleg_struct` structure. """ -struct TR_dogleg_struct{T <: AbstractFloat, S <: AbstractVector{T}} - lsmr_solver::LsmrSolver{T, T, S} # There is another lsmr call here +struct TR_dogleg_struct{T<:AbstractFloat,S<:AbstractVector{T}} + lsmr_solver::LsmrSolver{T,T,S} # There is another lsmr call here end -function TR_dogleg_struct(m, n, ::Type{S}; kwargs...) where {T, S <: AbstractVector{T}} +function TR_dogleg_struct(m, n, ::Type{S}; kwargs...) where {T,S<:AbstractVector{T}} lsmr_solver = LsmrSolver(n, m, S) return TR_dogleg_struct(lsmr_solver) end @@ -157,14 +157,14 @@ The keyword arguments may include: - `tan_small_d::T=eps(T)`: Tangent step trust-region parameters: `||d||` is too small. - `increase_Δtg::T=10`: Tangent step trust-region parameters: increase if possible, `< 1 / √eps(T)`, the `Δtg` between tangent steps. -For more details, we refer to the package documentation [fine-tuneDCI.md](https://juliasmoothoptimizers.github.io/DCISolver.jl/dev/fine-tuneDCI/). +For more details, we refer to the package documentation [fine-tuneDCI.md](https://juliasmoothoptimizers.github.io/DCISolver.jl/dev/fine-tuneDCI/). """ struct MetaDCI{ - T <: AbstractFloat, - In <: Integer, - COO <: SymCOOSolver, - CGLSStruct <: comp_λ_cgls, - TRStruct <: Union{TR_lsmr_struct, TR_dogleg_struct}, + T<:AbstractFloat, + In<:Integer, + COO<:SymCOOSolver, + CGLSStruct<:comp_λ_cgls, + TRStruct<:Union{TR_lsmr_struct,TR_dogleg_struct}, } #Tolerances on the problem: @@ -183,7 +183,7 @@ struct MetaDCI{ #Compute Lagrange multipliers λ_struct::CGLSStruct - #λ_struct_rescue #one idea is to have a 2nd set in case of emergency + #λ_struct_rescue #one idea is to have a 2nd set in case of emergency #good only if we can make a warm-start. # Solver for the factorization @@ -235,7 +235,7 @@ function MetaDCI( rtol::T = T(1e-5), ctol::T = T(1e-5), unbounded_threshold::T = -T(1e5), - verbose::Union{Integer, Bool} = 0, + verbose::Union{Integer,Bool} = 0, max_eval::Integer = 50000, max_time::Float64 = 120.0, max_iter::Integer = 500, @@ -254,7 +254,11 @@ function MetaDCI( bad_steps_lim::Integer = 3, feas_expected_decrease::T = T(0.95), TR_compute_step::Symbol = :TR_lsmr, - TR_struct::Union{TR_lsmr_struct, TR_dogleg_struct} = TR_lsmr_struct(length(x0), length(y0), S), + TR_struct::Union{TR_lsmr_struct,TR_dogleg_struct} = TR_lsmr_struct( + length(x0), + length(y0), + S, + ), compρ_p1::T = T(0.75), compρ_p2::T = T(0.90), ρbar::T = T(2.0), @@ -265,7 +269,7 @@ function MetaDCI( tan_σ₂::T = T(2.0), tan_small_d::T = eps(T), increase_Δtg::T = T(10), -) where {T <: AbstractFloat, S <: AbstractVector{T}} +) where {T<:AbstractFloat,S<:AbstractVector{T}} if !(linear_solver ∈ keys(solver_correspondence)) @warn "linear solver $linear_solver not found in $(collect(keys(solver_correspondence))). Using :ldlfact instead" linear_solver = :ldlfact diff --git a/src/workspace.jl b/src/workspace.jl index b7b00153..8ee9906f 100644 --- a/src/workspace.jl +++ b/src/workspace.jl @@ -4,7 +4,7 @@ Pre-allocate the memory used during the [`dci`](@ref) call. Returns a `DCIWorkspace` structure. """ -struct DCIWorkspace{T, S <: AbstractVector{T}, Si <: AbstractVector{<:Integer}, Op, In, COO} <: +struct DCIWorkspace{T,S<:AbstractVector{T},Si<:AbstractVector{<:Integer},Op,In,COO} <: AbstractOptimizationSolver x0::S x::S @@ -36,14 +36,14 @@ struct DCIWorkspace{T, S <: AbstractVector{T}, Si <: AbstractVector{<:Integer}, dn::S dcp::S rhs::S - meta::MetaDCI{T, In, COO} + meta::MetaDCI{T,In,COO} end function DCIWorkspace( - nlp::AbstractNLPModel{T, S}, - meta::MetaDCI{T, In, COO}, + nlp::AbstractNLPModel{T,S}, + meta::MetaDCI{T,In,COO}, x0::S = nlp.meta.x0, -) where {T, S <: AbstractVector{T}, In <: Integer, COO <: SymCOOSolver} +) where {T,S<:AbstractVector{T},In<:Integer,COO<:SymCOOSolver} n, m = nlp.meta.nvar, nlp.meta.ncon nnz = nlp.meta.nnzh + nlp.meta.nnzj + n + m Jx = jac_op(nlp, x0) @@ -82,13 +82,13 @@ function DCIWorkspace( ) end -get_meta(workspace::DCIWorkspace{T, S, Si, Op, In, COO}) where {T, S, Si, Op, In, COO} = +get_meta(workspace::DCIWorkspace{T,S,Si,Op,In,COO}) where {T,S,Si,Op,In,COO} = workspace.meta function SolverCore.reset!( - workspace::DCIWorkspace{T, S, Si, Op, In, COO}, + workspace::DCIWorkspace{T,S,Si,Op,In,COO}, nlp::AbstractNLPModel, -) where {T, S, Si, Op, In, COO} +) where {T,S,Si,Op,In,COO} workspace.x0 .= nlp.meta.x0 # workspace.Jx .= jac_op(nlp, x0) # workspace.LDL = ... @@ -98,8 +98,8 @@ function SolverCore.reset!( end function SolverCore.reset!( - workspace::DCIWorkspace{T, S, Si, Op, In, COO}, -) where {T, S, Si, Op, In, COO} + workspace::DCIWorkspace{T,S,Si,Op,In,COO}, +) where {T,S,Si,Op,In,COO} workspace.tr.good_grad = false workspace.tr.radius = workspace.tr.initial_radius return workspace diff --git a/test/runtests.jl b/test/runtests.jl index 80ad7943..4a577792 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -175,8 +175,8 @@ end end end -mutable struct DummyModel{T, S} <: AbstractNLPModel{T, S} - meta::NLPModelMeta{T, S} +mutable struct DummyModel{T,S} <: AbstractNLPModel{T,S} + meta::NLPModelMeta{T,S} end nlp = DummyModel(NLPModelMeta(1, minimize = false)) @@ -184,7 +184,10 @@ nlp = DummyModel(NLPModelMeta(1, minimize = false)) #Test if it has equality constraints nlp = ADNLPModel(x -> dot(x, x), zeros(5), zeros(5), ones(5)) -@test_throws ErrorException("DCI only works for equality constrained problems") dci(nlp, zeros(5)) +@test_throws ErrorException("DCI only works for equality constrained problems") dci( + nlp, + zeros(5), +) @testset "Small equality constrained problems II" begin tol = 1e-6 diff --git a/test/symcoo_runtests.jl b/test/symcoo_runtests.jl index 2eb1b1d9..95e22a25 100644 --- a/test/symcoo_runtests.jl +++ b/test/symcoo_runtests.jl @@ -14,7 +14,7 @@ end nvar, ncon = 5, 3 Q = spdiagm(nvar, nvar, 0 => 2 * ones(nvar), -1 => -ones(nvar - 1), 1 => -ones(nvar - 1)) Qt = tril(Q) - A = spdiagm(ncon, nvar, (i => ones(ncon) for i in (0:(nvar - ncon)))...) + A = spdiagm(ncon, nvar, (i => ones(ncon) for i in (0:(nvar-ncon)))...) @testset "Positive definite systems" begin rows, cols, vals = findnz(Qt) diff --git a/test/test-basic-test.jl b/test/test-basic-test.jl new file mode 100644 index 00000000..685f8101 --- /dev/null +++ b/test/test-basic-test.jl @@ -0,0 +1,3 @@ +@testset "DCISolver.jl" begin + @test DCISolver.hello_world() == "Hello, World!" +end