Skip to content
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
20 changes: 20 additions & 0 deletions .github/workflows/cancel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This workflow cancels existing CI runs that are on the same branch, so
# only the latest one runs.
name: Cancel
on:
push:
jobs:
cancel:
name: 'Cancel Previous Runs'
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#permissions
# we only need actions write:
permissions:
actions: write
timeout-minutes: 3
steps:
- uses: styfle/[email protected]
with:
workflow_id: ci.yml, docs.yml, nightly_ci.yml
access_token: ${{ github.token }}
all_but_latest: true
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ on:
- 'Project.toml'
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: Julia ${{ matrix.version }} - MOI ${{ matrix.moi-version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
moi-version:
- '0.9'
- '0.10'
version:
- '1'
- '1.0'
Expand All @@ -37,6 +40,11 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- name: "Install MOI version"
shell: julia --color=yes --project=. {0}
run: |
using Pkg
Pkg.add(Pkg.PackageSpec(; name="MathOptInterface", version="${{ matrix.moi-version }}"))
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/nightly_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
arch:
- x64
steps:
Expand Down
4 changes: 1 addition & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Changes in v0.14.17

* Updated to become compatible with MathOptInterface v0.10, which enables compatibility with the latest version of many solvers
([#467](https://github.com/jump-dev/Convex.jl/pull/467)).
This release drops compatibility with MathOptInterface v0.9, so if you need to use solvers which have not been updated yet,
please stick with an Convex v0.14.16 or earlier.
([#467](https://github.com/jump-dev/Convex.jl/pull/467), [#468](https://github.com/jump-dev/Convex.jl/pull/468)).

# Changes in v0.14.16

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
AbstractTrees = "0.2, 0.3"
BenchmarkTools = "^0.4, 0.5, 0.6, 0.7, 1.0"
LDLFactorizations = "0.8.1"
MathOptInterface = "0.10"
MathOptInterface = "0.9, 0.10"
OrderedCollections = "^1.0"
julia = "^1.0"

Expand Down
21 changes: 17 additions & 4 deletions src/solution.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
### MOI compatibility hacks
# Here, we hack in compatibility for both MOI v0.9 and v0.10.
# When we drop MOI v0.9 compat, we should drop these
# (in favor of only the changes from https://github.com/jump-dev/Convex.jl/pull/467).
if !isdefined(MOI, :SingleVariable) || MOI.SingleVariable isa Function
# MOI v0.10: should not use `SingleVariable` and instead `VariableIndex` directly.
const SV_OR_VI, SV_OR_IDENTITY = MOI.VariableIndex, identity
else
# MOI v0.9: need to use `SingleVariable`
const SV_OR_VI, SV_OR_IDENTITY = MOI.SingleVariable, MOI.SingleVariable
end
###

# Convert from sets used within Convex to MOI sets
function get_MOI_set(cone, length_inds)
if cone == :SDP
Expand Down Expand Up @@ -151,11 +164,11 @@ function load_MOI_model!(model, problem::Problem{T}) where {T}

# the objective: maximize or minimize a scalar variable
objective_index = var_to_indices[objective_var_id][] # get the `MOI.VariableIndex` corresponding to the objective
MOI.set(model, MOI.ObjectiveFunction{MOI.VariableIndex}(), objective_index)
MOI.set(model, MOI.ObjectiveFunction{SV_OR_VI}(), SV_OR_IDENTITY(objective_index))
MOI.set(model, MOI.ObjectiveSense(), problem.head == :maximize ? MOI.MAX_SENSE : MOI.MIN_SENSE)

# Constraints: Generate a MOI function and a MOI sets for each `ConicConstr` object in the problem
MOI_constr_fn = Union{MOI.VectorAffineFunction{T},MOI.VariableIndex}[]
MOI_constr_fn = Union{MOI.VectorAffineFunction{T},SV_OR_VI}[]
MOI_sets = Any[]
for conic_constr in conic_constraints
set, constr_fn = make_MOI_constr(conic_constr, var_to_indices, id_to_variables, T)
Expand All @@ -169,13 +182,13 @@ function load_MOI_model!(model, problem::Problem{T}) where {T}
if vartype(variable) == IntVar
var_indices = var_to_indices[var_id]
for idx = eachindex(var_indices)
push!(MOI_constr_fn, var_indices[idx])
push!(MOI_constr_fn, SV_OR_IDENTITY(var_indices[idx]))
push!(MOI_sets, MOI.Integer())
end
elseif vartype(variable) == BinVar
var_indices = var_to_indices[var_id]
for idx in eachindex(var_indices)
push!(MOI_constr_fn, var_indices[idx])
push!(MOI_constr_fn, SV_OR_IDENTITY(var_indices[idx]))
push!(MOI_sets, MOI.ZeroOne())
end
end
Expand Down
6 changes: 4 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ end
# MacOS, and have passed on ubuntu in the past). Disabling
# them for now; once COSMO or Hypatia is on MOI v0.10, we can
# try using them, or hope SCS starts solving them again.
run_tests(; exclude=[r"mip", r"sdp_lieb_ando"]) do p
#
# "sdp_sdp_constraints" is failing with MOI v0.9 on ubuntu.
run_tests(; exclude=[r"mip", r"sdp_lieb_ando", r"sdp_sdp_constraints"]) do p
solve!(p, () -> SCS.Optimizer(verbose=0, eps=1e-6); warmstart = true)
end
end

@testset "SCS" begin
run_tests(; exclude=[r"mip", r"sdp_lieb_ando"]) do p
run_tests(; exclude=[r"mip", r"sdp_lieb_ando", r"sdp_sdp_constraints"]) do p
solve!(p, () -> SCS.Optimizer(verbose=0, eps=1e-6))
end
end
Expand Down