{"id":21604020,"url":"https://github.com/quentinll/diffqcqp","last_synced_at":"2025-10-19T06:02:25.544Z","repository":{"id":55144881,"uuid":"306396725","full_name":"quentinll/diffqcqp","owner":"quentinll","description":"Implementations of QP/QCQP solvers using ADMM algorithm ","archived":false,"fork":false,"pushed_at":"2023-06-14T08:57:21.000Z","size":1109,"stargazers_count":42,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-25T00:14:59.931Z","etag":null,"topics":["admm-algorithm","differentiable-solvers","pytorch"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quentinll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-22T16:28:18.000Z","updated_at":"2025-02-18T15:04:05.000Z","dependencies_parsed_at":"2024-11-24T19:18:39.745Z","dependency_job_id":"07c195e2-e7e2-46a1-b3a0-0b556db6275e","html_url":"https://github.com/quentinll/diffqcqp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quentinll%2Fdiffqcqp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quentinll%2Fdiffqcqp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quentinll%2Fdiffqcqp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quentinll%2Fdiffqcqp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quentinll","download_url":"https://codeload.github.com/quentinll/diffqcqp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248330925,"owners_count":21085800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admm-algorithm","differentiable-solvers","pytorch"],"created_at":"2024-11-24T19:18:12.619Z","updated_at":"2025-10-19T06:02:20.503Z","avatar_url":"https://github.com/quentinll.png","language":"C++","readme":"\n# diffqcqp\nImplementations of QP/QCQP solvers using ADMM algorithm and their analytical derivatives. This implementation is used in the paper \"Differentiable simulation for physical system identification\" (Q. Le Lidec, I. Kalevatykh, I. Laptev, C. Schmid and J. Carpentier) (https://hal.archives-ouvertes.fr/hal-03025616/). A video presenting our work is available at: https://youtu.be/d248IWMLW9o\n\nWe propose C++ functions and their python interface (which can easily be integrated into any Automatic Differentiation library such as PyTorch or Tensorflow) that allows solving the following QPs/QCQPs:\n```\nminimize        0.5 x' P x + q' x\n\nsubject to      0\u003c= x \n```\nand \n```\nminimize        0.5 x' P x + q' x\n\nsubject to      ||x_(i)|| \u003c= mu(i)*l_n(i) for each contact i \n```\n\n\n## Installation\nThe python package can be installed by running:\n\n```\npython setup.py install\n```\n\n## Usage\nBelow is a usage example showing how our differentiable solver is used and can be integrated into a learning architecture by taking advantage of PyTorch autodiff tool.\n```\nimport torch\nfrom qcqp import QPFn2\n\nB= 10 #batch size\nN = 8 #dimension of the problem\n\nP = torch.rand((B,N),dtype = torch.double)\nP = torch.diag_embed(P) #positive semi-definite matrix of the QP objective function\nP = torch.nn.parameter.Parameter(P, requires_grad= True)\nq = torch.rand((B,N,1),dtype = torch.double) #vector of the QP objective function\nq = torch.nn.parameter.Parameter(q, requires_grad= True)\n\neps = 1e-7 #precision of the solver\nwarm_start = torch.zeros(q.size()) #vector used to warm-start the QP solver\nmax_iter = 1000 #maximum iterations for the solver \n\nqpsolver = QPFn2.apply\noptimizer = torch.optim.Adam([P,q])\nloss = torch.nn.MSELoss()\n\nl = qpsolver(P,q,warm_start,eps,max_iter)\ntarget = torch.rand(q.size())\nL = loss(target,l)\n\noptimizer.zero_grad()\nloss.backward()\nprint(q.gradient) #contains gradient of the loss w.r.t q\noptimizer.step()\n```\n\n## Experiments\nExperiments comparing runtime performances of the solver during forward and backward passes to others differentiable solvers (OptNet: https://arxiv.org/abs/1703.00443 , Cvxpylayers: https://web.stanford.edu/~boyd/papers/diff_dgp.html) can be runned with:\n```\npython test_script.py\n```\n\n![test_results](qcqp_runtime.png)\n\n\n## Citing\nThis work can be cited with:\n```\n@unpublished{lelidec:hal-03025616,\n  TITLE = {{Differentiable simulation for physical system identification}},\n  AUTHOR = {Le Lidec, Quentin and Kalevatykh, Igor and Laptev, Ivan and Schmid, Cordelia and Carpentier, Justin},\n  URL = {https://hal.archives-ouvertes.fr/hal-03025616},\n  NOTE = {working paper or preprint},\n  YEAR = {2020},\n  MONTH = Nov,\n  KEYWORDS = {Contact Modeling ; Simulation and Animation ; Optimization and Optimal Control ; Calibration and Identification},\n  PDF = {https://hal.archives-ouvertes.fr/hal-03025616/file/lelidec2020diffsim.pdf},\n  HAL_ID = {hal-03025616},\n  HAL_VERSION = {v1},\n}\n```\n\n## Acknowledgements\nThis work was partially supported by PRAIRIE 3IA Institute and the HPC resources from GENCI-IDRIS.\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquentinll%2Fdiffqcqp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquentinll%2Fdiffqcqp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquentinll%2Fdiffqcqp/lists"}