Skip to content

MKLPardisoKKTSolver not correctly exported in namespace #159

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

Closed
Sage0614 opened this issue Aug 11, 2022 · 2 comments
Closed

MKLPardisoKKTSolver not correctly exported in namespace #159

Sage0614 opened this issue Aug 11, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Sage0614
Copy link

I am trying to use MKLPardisoKKTSolver in JuMP

model = JuMP.Model(optimizer_with_attributes(COSMO.Optimizer, "kkt_solver" => with_options(PardisoDirectKKTSolver, msg_level_on = true));

and getting the error message UndefVarError: MKLPardisoKKTSolver not defined

I think the problem is with this file:

export PardisoDirectKKTSolver, PardisoIndirectKKTSolver, MKLPardisoSolver

MKLPardisoKKTSolver rather than MKLPardisoSolver should be exported to namespace.

Thanks,

@Sage0614 Sage0614 added the bug Something isn't working label Aug 11, 2022
@migarstka
Copy link
Member

migarstka commented Aug 20, 2022

Hi @Sage0614,

You are right, I fixed it in this commit 8d0f108: (will be part of new releave v0.8.6):
If you checkout the commit or the master branch, the following script should work:

(Notice you need to load Pardiso using Pardiso independently.

using Pardiso, COSMO, JuMP, LinearAlgebra, SparseArrays, Test, Random

rng = Random.MersenneTwister(12345);
## create a random test matrix C
n = 8;
C = -1 .+ rand(rng, n, n) .* 2;
c = vec(C);

# Define problem in `JuMP`:
q = -vec(C);
r = 0.5 * vec(C)' * vec(C);
m = JuMP.Model(optimizer_with_attributes(COSMO.Optimizer, "verbose" => true, "kkt_solver" => MKLPardisoKKTSolver));
@variable(m, X[1:n, 1:n], PSD);
x = vec(X);
@objective(m, Min, 0.5 * x' * x  + q' * x + r);
for i = 1:n
  @constraint(m, X[i, i] == 1.);
end

# Solve the `JuMP` model with `COSMO` and query the solution `X_sol`:
status = JuMP.optimize!(m);
obj_val = JuMP.objective_value(m);
X_sol = JuMP.value.(X);

@Sage0614
Copy link
Author

Hi @Sage0614,

You are right, I fixed it in this commit 8d0f108: (will be part of new releave v0.8.6): If you checkout the commit or the master branch, the following script should work:

(Notice you need to load Pardiso using Pardiso independently.

using Pardiso, COSMO, JuMP, LinearAlgebra, SparseArrays, Test, Random

rng = Random.MersenneTwister(12345);
## create a random test matrix C
n = 8;
C = -1 .+ rand(rng, n, n) .* 2;
c = vec(C);

# Define problem in `JuMP`:
q = -vec(C);
r = 0.5 * vec(C)' * vec(C);
m = JuMP.Model(optimizer_with_attributes(COSMO.Optimizer, "verbose" => true, "kkt_solver" => MKLPardisoKKTSolver));
@variable(m, X[1:n, 1:n], PSD);
x = vec(X);
@objective(m, Min, 0.5 * x' * x  + q' * x + r);
for i = 1:n
  @constraint(m, X[i, i] == 1.);
end

# Solve the `JuMP` model with `COSMO` and query the solution `X_sol`:
status = JuMP.optimize!(m);
obj_val = JuMP.objective_value(m);
X_sol = JuMP.value.(X);

That works fine for me, think you can close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants