Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 612553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:54:22+00:00 2026-05-13T17:54:22+00:00

Is there a good library to numericly solve an LCP in python ? Edit:

  • 0

Is there a good library to numericly solve an LCP in python ?

Edit: I need a working python code example because most libraries seem to only solve quadratic problems and i have problems converting an LCP into a QP.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:54:23+00:00Added an answer on May 13, 2026 at 5:54 pm

    For quadratic programming with Python, I use the qp-solver from cvxopt (source). Using this, it is straightforward to translate the LCP problem into a QP problem (see Wikipedia). Example:

    from cvxopt import matrix, spmatrix
    from cvxopt.blas import gemv
    from cvxopt.solvers import qp
    
    def append_matrix_at_bottom(A, B):
        l = []
        for x in xrange(A.size[1]):
            for i in xrange(A.size[0]):
                l.append(A[i+x*A.size[0]])
            for i in xrange(B.size[0]):
                l.append(B[i+x*B.size[0]])
        return matrix(l,(A.size[0]+B.size[0],A.size[1]))
    
    M = matrix([[ 4.0, 6,   -4,    1.0 ],
                [ 6,   1,    1.0   2.0 ],
                [-4,   1.0,  2.5, -2.0 ],
                [ 1.0, 2.0, -2.0,  1.0 ]])
    q = matrix([12, -10, -7.0, 3])
    
    I = spmatrix(1.0, range(M.size[0]), range(M.size[1]))
    G = append_matrix_at_bottom(-M, -I)   # inequality constraint G z <= h
    h = matrix([x for x in q] + [0.0 for _x in range(M.size[0])])
    
    sol = qp(2.0 * M, q, G, h)      # find z, w, so that w = M z + q
    if sol['status'] == 'optimal':
        z = sol['x']
        w = matrix(q)
        gemv(M, z, w, alpha=1.0, beta=1.0)   # w = M z + q
        print(z)
        print(w)
    else:
        print('failed')
    

    Please note:

    • the code is totally untested, please check carefully;
    • there surely are better solution techniques than transforming LCP into QP.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 300k
  • Answers 300k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer "which is embeded in XUL" How? I bet you use… May 13, 2026 at 7:59 pm
  • Editorial Team
    Editorial Team added an answer Depending on what you're trying to do outside of OpenGL,… May 13, 2026 at 7:59 pm
  • Editorial Team
    Editorial Team added an answer Disjoint sets structure is also called "union-find structure". So union,… May 13, 2026 at 7:59 pm

Related Questions

I need to calculate averages, standard deviations, medians etc for a bunch of numerical
I'm trying to create Excel 2007 Documents programmatically. Now, there are two ways I've
I'm looking for a good (well-tested, fully-featured, and ideally with a nice interface) matrix
I've been thinking lately about the question of DSLs vs. libraries. In my field,
I would like to produce nicely formatted tabular text from arbitrary dataset object models.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.