LP symbol returns incorrect value

Open
#575 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
numpy, python
Domain
backend

Research direction

Run the attached lp.zip reproduction with Python, comparing scipy.optimize.linprog against dwave.optimization.linprog and their res.x/res.fun state values. Trace the LP result from that entry point and verify the reported objective and solution agree with SciPy for the supplied data; done means the reproduction no longer reports 47779.29074832177 versus 33603159.675.

Written by the indexing model from the issue text.

Description

bug

lp.zip


import numpy as np
import scipy.optimize

import dwave.optimization

arrays = np.load("lp.npz")
c = arrays["c"]
A_ub = arrays["A_ub"]
b_ub = arrays["b_ub"]
A_eq = arrays["A_eq"]
b_eq = arrays["b_eq"]
lb = arrays["lb"]
ub = arrays["ub"]

# Solve it with scipy
res = scipy.optimize.linprog(
    c=c,
    A_ub=A_ub,
    b_ub=b_ub,
    A_eq=A_eq,
    b_eq=b_eq,
    bounds=list(zip(lb, ub)),
)
scipy_x = res.x
scipy_fun = res.fun

# Solve it with dwave-optimization
model = dwave.optimization.Model()
res = dwave.optimization.linprog(
    c=model.constant(c),
    A_ub=model.constant(A_ub),
    b_ub=model.constant(b_ub),
    A_eq=model.constant(A_eq),
    b_eq=model.constant(b_eq),
    lb=model.constant(lb),
    ub=model.constant(ub),
)
_ = res.x
__ = res.fun
model.states.resize(1)
with model.lock():
    dwopt_x = res.x.state()
    dwopt_fun = res.fun.state()

print(scipy_fun, dwopt_fun)
47779.29074832177 33603159.675
Dominant language
C++
Stars
31
Forks
36
Avg merge
1d 9h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dwavesystems/dwave-optimization

All issues in dwavesystems/dwave-optimization

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.