Skip to content

Fix conic error #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
name: CI
on:
- push
- pull_request
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
# needed to allow julia-actions/cache to delete old caches that it has created
permissions:
actions: write
contents: read
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
Expand All @@ -17,21 +24,12 @@ jobs:
os: windows-latest
arch: x64
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
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/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
Expand All @@ -48,23 +46,17 @@ jobs:
# Fix for Plots with GR backend, see https://github.com/jheinen/GR.jl/issues/422
GKSwstype: nul
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- shell: bash
run: julia --project=docs -e "using Pkg; Pkg.develop(PackageSpec(path=pwd()))"
- shell: bash
run: julia --project=docs -e "using Pkg; Pkg.instantiate()"
- shell: bash
env:
DATADEPS_ALWAYS_ACCEPT: true # For MLDatasets.MNIST
- name: Install dependencies
shell: julia --color=yes --project=docs/ {0}
run: |
julia --project=docs -e '
using Documenter: doctest
using DiffOpt
doctest(DiffOpt)'
- run: julia --project=docs docs/make.jl
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
- run: julia --project=docs --color=yes docs/make.jl
env:
DATADEPS_ALWAYS_ACCEPT: true # For MLDatasets.MNIST
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ JuMP = "1"
LazyArrays = "0.21, 0.22, 1"
MathOptInterface = "1.18"
MathOptSetDistances = "0.2.9"
ParametricOptInterface = "0.9.0"
ParametricOptInterface = "0.11"
julia = "1.6"
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Documenter = "0.27"
Documenter = "1"
8 changes: 3 additions & 5 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ end
literate_directory(_EXAMPLE_DIR)

makedocs(;
authors = "JuMP Community",
sitename = "DiffOpt.jl",
repo = "https://github.com/jump-dev/DiffOpt.jl",
modules = [DiffOpt],
doctest = false,
clean = true,
format = Documenter.HTML(;
prettyurls = get(ENV, "CI", nothing) == "true",
Expand All @@ -61,10 +63,6 @@ makedocs(;
f in readdir(_EXAMPLE_DIR) if endswith(f, ".md")
],
],
strict = true, # See https://github.com/JuliaOpt/JuMP.jl/issues/1576
repo = "https://github.com/jump-dev/DiffOpt.jl",
sitename = "DiffOpt.jl",
authors = "JuMP Community",
)

deploydocs(; repo = "github.com/jump-dev/DiffOpt.jl.git", push_preview = true)
1 change: 1 addition & 0 deletions src/ConicProgram/ConicProgram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function DiffOpt.forward_differentiate!(model::Model)
dAj,
dAv,
)
dAv .*= -1.0
dA = SparseArrays.sparse(dAi, dAj, dAv, lines, cols)

m = size(A, 1)
Expand Down
24 changes: 24 additions & 0 deletions src/bridges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

function MOI.get(
model::MOI.ModelLike,
attr::ObjectiveFunctionAttribute{ReverseObjectiveFunction,G},
::MOI.Bridges.Objective.FunctionConversionBridge{T,F,G},
) where {T,F,G}
return MOI.get(
model,
ObjectiveFunctionAttribute{ReverseObjectiveFunction,F}(attr.attr),
)
end

function MOI.set(
model::MOI.ModelLike,
attr::ObjectiveFunctionAttribute{ForwardObjectiveFunction,G},
::MOI.Bridges.Objective.FunctionConversionBridge{T,F,G},
value,
) where {T,F,G}
return MOI.set(
model,
ObjectiveFunctionAttribute{ForwardObjectiveFunction,F}(attr.attr),
value,
)
end

function MOI.get(
model::MOI.ModelLike,
::ObjectiveFunctionAttribute{ReverseObjectiveFunction},
Expand Down
Loading