Code Monkey home page Code Monkey logo

piqp's People

Contributors

freyjo avatar rschwan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

piqp's Issues

Ability to provide initial weights

Hi there,

Thanks for this optimiser - in my tests on large scale sparse problems (upwards of 5k variables) it performs very well, better than SQOPT which was previously the best for my use case. One edge that SQOPT has though, is that I can provide initial weights (or a guess), and if these are close to the optimal solution it reduces the runtime dramatically (for my particular use case it was a factor of 10!).

The current python interface doesn't provide a way to provide initial weights - is this something that is possible given the design? I see there is the ability to do an update, but in this case (portfolio optimisation over time) all the inputs have changed (including their dimensions), but the solution will not be far from the initial weights given deliberate friction in the objective.

Thanks!

Charles

Availability on conda-forge?

First of all, I wanted to say big congratulations on your new amazing solver, it's the fastest one I have ever tried!

Could you please also publish it to conda forge as a package? Thank you very much in advance.

Infeasibility for basic QP

Hi, I tried using the library and am getting infeasibility, so I got things down to a small working example. I can't understand why this solution is yielding infeasibility. Any help would be greatly appreciated. Here's the code I have:

import numpy as np
import osqp  # type: ignore
import piqp  # type: ignore
from scipy import sparse  # type: ignore

P = np.array(
    [
        [1.0, 0.0, 0.0, 0.0],
        [0.0, 1.0, 0.0, 0.0],
        [0.0, 0.0, 1.0, 0.0],
        [0.0, 0.0, 0.0, 1.0],
    ]
)
c = np.array([1.0, 1.0, 1.0, 1.0])

A = np.array([[0.0, 0.0, 0.0, 0.0]])
b = np.array([0.0])

G = np.array(
    [
        [1.0, 0.0, 0.0, 0.0],
        [1.0, 0.0, -1.0, 0.0],
        [-1.0, 0.0, -1.0, 0.0],
        [-1.0, 0.0, 0.0, 0.0],
        [-1.0, 0.0, 1.0, 0.0],
        [1.0, 0.0, 1.0, 0.0],
    ]
)
h = np.array([1.0, 1.0, 1.0, 1.0, np.inf, np.inf])

problem = piqp.DenseSolver()
problem.settings.verbose = True
problem.settings.compute_timings = True
problem.setup(
    P=P,
    c=c,
    A=A,
    b=b,
    G=G,
    h=h,
)
problem.solve()
x = problem.result.x

easy_answer = np.array([0.0, 0.0, 0.0, 0.0])
assert A @ easy_answer == b
assert (G @ easy_answer <= h).all()


def loss(answer: np.ndarray) -> float:
    return 0.5 * answer.T @ P @ answer + c.T @ answer


print("easy loss", loss(easy_answer))
print("solved loss", loss(x))

print("x", x)

problem = osqp.OSQP()
lower = np.array([-np.inf, -np.inf, -np.inf, -np.inf, -np.inf, -np.inf])
problem.setup(sparse.csc_matrix(P), c, sparse.csc_matrix(G), lower, h)
r = problem.solve()
print("x", r.x)

Multi-threading

I can see 8 CPU cores in use while solving using PIQP. I was wondering where that parallelism is coming from and is it possible to control it? E.g. use more than 8 threads to improve performance?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.