{"id":452,"date":"2023-04-27T13:48:51","date_gmt":"2023-04-27T13:48:51","guid":{"rendered":"https:\/\/nag.com\/?page_id=452"},"modified":"2023-04-27T13:54:29","modified_gmt":"2023-04-27T13:54:29","slug":"qcqp-problems-tutorial","status":"publish","type":"page","link":"https:\/\/nag.com\/qcqp-problems-tutorial\/","title":{"rendered":"QCQP problems tutorial"},"content":{"rendered":"\n<div class=\"gbc-title-banner ta ta-lg ta-xl\" style='border-radius: 0px; '>\n    <div class=\"container\" style='border-radius: 0px; '>\n        <div class=\"row justify-content--center\" >\n            <div class=\"col-12\"  >\n                <div class=\"wrap pv-4 \" style=\"0pxbackground-color: \">\n                                <div class=\"col-12 col-md-12 col-lg-12 col-xl-12  banner-content\"  >\n    \n                                             <h1><span style=\"color: #082d48;\">Solving Quadratically constrained quadratic Programming (QCQP) problems<\/span><\/h1>\n                    \n                    <div class=\"mt-1 mb-1 content\"><\/div>\n\n                    \n                                    <\/div>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n\n\n\n<div class=\"content-image-split pv-4  ph-1 \" style=\"background-color: ;\" >\n    <div class=\"container\">\n        <div class=\"row ph-1\">\n            <div class=\"col-12 \" >\n\n                <div class=\"row fdir-cr fdir-r-lg \">\n                    <div class=\"content-side df pv-3 ph-1 ph-lg-5 ph-xl-8 c-primary--white col-12 col-lg-6\" style=\"\n                    background-color: ;\n                    color: #082d48ff;\n                    align-items: center; \">\n\n                        <div>\n                                                            <h3 class=\"mb-1\">Quadratic optimization modelling<\/h3>\n                                                        <p>Quadratic functions are a powerful modelling construct in mathematical programming and appear in various disciplines such as statistics, machine learning (Lasso regression), finance (portfolio optimization), engineering (OPF) and control theory. At Mark 27.1 of the <span class=\"nag-n-override\" style=\"margin-left: 0 !important;\"><i>n<\/i><\/span>AG Library, <span class=\"nag-n-override\" style=\"margin-left: 0 !important;\"><i>n<\/i><\/span>AG introduced two new additions to the <span class=\"nag-n-override\" style=\"margin-left: 0 !important;\"><i>n<\/i><\/span>AG Optimization Modelling Suite to help users easily define quadratic objective functions and\/or constraints, seamlessly integrate them with other constraints and solve the resulting problems using compatible solvers without the need of a reformulation or any extra effort.<\/p>\n<p>Formally, a QCQP problem can be written in its pure form with only quadratic functions in both objective and constraints as follows:<\/p>\n<p>\\[<br \/>\\begin{array}{ll}<br \/>\\underset{x \\in \\mathbb{R}^n}{\\mathrm{minimize}}<br \/>&amp; \\frac{1}{2} x^T Q_0 x + r_0^T x + s_0 \\\\<br \/>\\mathrm{subject\\ to}<br \/>&amp; \\frac{1}{2} x^T Q_i x + r_i^T x + s_i \\le 0, \\quad i = 1, \\dots, p,<br \/>\\end{array}<br \/>\\]<\/p>\n<p>where Qi\u2208\u211cn\u00d7n,i=0,\u2026,p, are symmetric matrices, ri\u2208\u211cn,i=0,\u2026,p, are vectors and si scalars. However, in practice it will often be stated with linear constraints and simple bounds as well. The two new routines are handle_set_qconstr (e04rs) which defines quadratic functions in assembled form as above and handle_set_qconstr_fac (e04rt) which uses factored form 12xTFTiFix+rTix+si. The latter form is useful in many applications where the factors Fi appear naturally, such as in data fitting \u2225Fx\u2212b\u22252<\/p>\n                                                    <\/div>\n\n                    <\/div>\n                    <div class=\"img-side small-image-holder col-12 col-lg-6 ph-0 df\" style=\"align-items: center; background-color: ;  color: #082d48ff; \">\n                        <img loading=\"lazy\" decoding=\"async\" width=\"1110\" height=\"1320\" src=\"https:\/\/nag.com\/wp-content\/uploads\/2023\/04\/QCQP-Problems.jpg\" class=\"bg-media contain-lg\" alt=\"\" style=\"object-position: % %;\" \/>\n                        <div class=\"wrap \">\n                                                    <\/div>\n\n                    <\/div>\n                <\/div>\n\n\n            <\/div>\n\n        <\/div>\n    <\/div>\n<\/div>\n\n\n<div class=\"content-image-split pv-4  ph-1 \" style=\"background-color: ;\" >\n    <div class=\"container\">\n        <div class=\"row ph-1\">\n            <div class=\"col-12  card-rounded\" >\n\n                <div class=\"row fdir-cr fdir-rr-lg \">\n                    <div class=\"content-side df pv-3 ph-1 ph-lg-5 ph-xl-8 c-primary--white col-12 col-lg-6\" style=\"\n                    background-color: #082d48ff;\n                    color: #ffffffff;\n                    align-items: center; \">\n\n                        <div>\n                                                            <h3 class=\"mb-1\">New Routines for QCQP<\/h3>\n                                                        <p>The key question is if the problem is convex or non-convex as it determines if the problem can be solved via conic optimization<\/p>\n<p>(second-order cone programming, SOCP) or only by generic nonlinear programming (NLP). The problem is convex if all Qi,i=0,\u2026,p, are positive semidefinite (the factored form is positive semidefinite by definition).<\/p>\n<p>QCQP problems were solvable even without the new additions in this release but a nontrivial knowledge of reformulation techniques was required if an SOCP solver was to be used or callbacks covering the quadratic functions had to be introduced in the general case. To remove the unnecessary burden from practitioners, the new routines directly provide the quadratic data to the solvers with an appropriate automatic reformulation as the chosen solver from the Suite.<\/p>\n                                                    <\/div>\n\n                    <\/div>\n                    <div class=\"img-side small-image-holder col-12 col-lg-6 ph-0 df\" style=\"align-items: center; background-color: #082d48ff;  color: #ffffffff; \">\n                        <img loading=\"lazy\" decoding=\"async\" width=\"1110\" height=\"1320\" src=\"https:\/\/nag.com\/wp-content\/uploads\/2023\/04\/QCQP-Problems-2-1.jpg\" class=\"bg-media \" alt=\"\" style=\"object-position: % %;\" \/>\n                        <div class=\"wrap \">\n                                                    <\/div>\n\n                    <\/div>\n                <\/div>\n\n\n            <\/div>\n\n        <\/div>\n    <\/div>\n<\/div>\n\n<div class=\"container content-area-default \">\n    <div class=\"row justify-content--center\">\n        <div class=\"col-12 col-md-12 col-lg-6 col-xl-4\">\n            <p>For non-convex QCQP, <span class=\"nag-n-override\" style=\"margin-left: 0 !important;\"><i>n<\/i><\/span>AG will use the input data to automatically assembly first and second derivatives that are used by the nonlinear programming solver (such as handle_solve_ipopt (e04st)).<br \/>Even though convex QCQP problems can also be solved via nonlinear programming, we generally recommend the second-order cone programming solver (handle_solve_socp_ipm (e04pt)) due to its computational efficiency and ability to detect infeasibility. In that case, <span class=\"nag-n-override\" style=\"margin-left: 0 !important;\"><i>n<\/i><\/span>AG will take care of the reformulation of quadratic functions to cones, including the factorization of all Qi matrices in an efficient and numerically robust way. This is particularly helpful in the case of singular or close-to-singular matrices.<\/p>\n<p>By maintaining the consistency of the interface of the solvers within the <span class=\"nag-n-override\" style=\"margin-left: 0 !important;\"><i>n<\/i><\/span>AG Optimization Modelling Suite, e04rs and e04rt become part of the suite that simplifies building models and enhances <span class=\"nag-n-override\" style=\"margin-left: 0 !important;\"><i>n<\/i><\/span>AG\u2019s offering in mathematical optimization. For examples and further reading visit our GitHub Local optimisation page.<\/p>\n        <\/div>\n    <\/div>\n<\/div>\n\n\n<div class=\"gbc-title-banner tac ta-lg ta-xl\" style='border-radius: 0px; '>\n    <div class=\"container\" style='border-radius: 0px; '>\n        <div class=\"row justify-content--center\" >\n            <div class=\"col-12\"  >\n                <div class=\"wrap pv-4 \" style=\"0pxbackground-color: \">\n                                <div class=\"col-12 col-md-12 col-lg-8 col-xl-6  banner-content\"  >\n    \n                                             <h2>Want to know more?<\/h2>\n                    \n                    <div class=\"mt-1 mb-1 content\"><p>The <span class=\"nag-n-override\" style=\"margin-left: 0 !important;\"><i>n<\/i><\/span>AG\u00ae Library is a collection of 1600+ mathematical and statistical algorithms. These provide the building blocks to develop applications and calculate the most complex mathematical problems.<\/p>\n<p>The <span class=\"nag-n-override\" style=\"margin-left: 0 !important;\"><i>n<\/i><\/span>AG\u00ae Library provides Accurate, stable results, improves productivity and efficiency and future-proofs your application.<\/p>\n<\/div>\n\n                    \n                    <a href='#' style='background-color: #ff7d21ff; color: #ffffffff; border-radius: 30px; font-weight: 600; ' class='btn mr-1  ' >Primary CTA <i class='fas fa-angle-right'><\/i><\/a><a href='#' style='border: 2px solid #ff7d21ff; color: #ff7d21ff; border-radius: 30px; font-weight: 600; ' class='btn mr-1 outline ' >Secondary CTA <i class='fas fa-angle-right'><\/i><\/a>                <\/div>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"content-type":"","footnotes":""},"class_list":["post-452","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>QCQP problems tutorial - nAG<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nag.com\/qcqp-problems-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"QCQP problems tutorial - nAG\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nag.com\/qcqp-problems-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"nAG\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-27T13:54:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/nag.com\/wp-content\/uploads\/2024\/02\/NAG-Logo-White-On-Blue.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"12770\" \/>\n\t<meta property=\"og:image:height\" content=\"4353\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@NAGTalk\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/nag.com\/qcqp-problems-tutorial\/\",\"url\":\"https:\/\/nag.com\/qcqp-problems-tutorial\/\",\"name\":\"QCQP problems tutorial - nAG\",\"isPartOf\":{\"@id\":\"https:\/\/nag.com\/#website\"},\"datePublished\":\"2023-04-27T13:48:51+00:00\",\"dateModified\":\"2023-04-27T13:54:29+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/nag.com\/qcqp-problems-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/nag.com\/qcqp-problems-tutorial\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/nag.com\/qcqp-problems-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/nag.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"QCQP problems tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/nag.com\/#website\",\"url\":\"https:\/\/nag.com\/\",\"name\":\"NAG\",\"description\":\"Robust, trusted numerical software and computational expertise.\",\"publisher\":{\"@id\":\"https:\/\/nag.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/nag.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/nag.com\/#organization\",\"name\":\"Numerical Algorithms Group\",\"alternateName\":\"NAG\",\"url\":\"https:\/\/nag.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/nag.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/nag.com\/wp-content\/uploads\/2023\/11\/NAG-Logo.png\",\"contentUrl\":\"https:\/\/nag.com\/wp-content\/uploads\/2023\/11\/NAG-Logo.png\",\"width\":1244,\"height\":397,\"caption\":\"Numerical Algorithms Group\"},\"image\":{\"@id\":\"https:\/\/nag.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/NAGTalk\",\"https:\/\/www.linkedin.com\/company\/nag\/\",\"https:\/\/www.youtube.com\/user\/NumericalAlgorithms\",\"https:\/\/github.com\/numericalalgorithmsgroup\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"QCQP problems tutorial - nAG","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nag.com\/qcqp-problems-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"QCQP problems tutorial - nAG","og_url":"https:\/\/nag.com\/qcqp-problems-tutorial\/","og_site_name":"nAG","article_modified_time":"2023-04-27T13:54:29+00:00","og_image":[{"width":12770,"height":4353,"url":"https:\/\/nag.com\/wp-content\/uploads\/2024\/02\/NAG-Logo-White-On-Blue.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_site":"@NAGTalk","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/nag.com\/qcqp-problems-tutorial\/","url":"https:\/\/nag.com\/qcqp-problems-tutorial\/","name":"QCQP problems tutorial - nAG","isPartOf":{"@id":"https:\/\/nag.com\/#website"},"datePublished":"2023-04-27T13:48:51+00:00","dateModified":"2023-04-27T13:54:29+00:00","breadcrumb":{"@id":"https:\/\/nag.com\/qcqp-problems-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nag.com\/qcqp-problems-tutorial\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nag.com\/qcqp-problems-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nag.com\/"},{"@type":"ListItem","position":2,"name":"QCQP problems tutorial"}]},{"@type":"WebSite","@id":"https:\/\/nag.com\/#website","url":"https:\/\/nag.com\/","name":"NAG","description":"Robust, trusted numerical software and computational expertise.","publisher":{"@id":"https:\/\/nag.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nag.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/nag.com\/#organization","name":"Numerical Algorithms Group","alternateName":"NAG","url":"https:\/\/nag.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nag.com\/#\/schema\/logo\/image\/","url":"https:\/\/nag.com\/wp-content\/uploads\/2023\/11\/NAG-Logo.png","contentUrl":"https:\/\/nag.com\/wp-content\/uploads\/2023\/11\/NAG-Logo.png","width":1244,"height":397,"caption":"Numerical Algorithms Group"},"image":{"@id":"https:\/\/nag.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/NAGTalk","https:\/\/www.linkedin.com\/company\/nag\/","https:\/\/www.youtube.com\/user\/NumericalAlgorithms","https:\/\/github.com\/numericalalgorithmsgroup"]}]}},"_links":{"self":[{"href":"https:\/\/nag.com\/wp-json\/wp\/v2\/pages\/452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nag.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/nag.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/nag.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nag.com\/wp-json\/wp\/v2\/comments?post=452"}],"version-history":[{"count":11,"href":"https:\/\/nag.com\/wp-json\/wp\/v2\/pages\/452\/revisions"}],"predecessor-version":[{"id":468,"href":"https:\/\/nag.com\/wp-json\/wp\/v2\/pages\/452\/revisions\/468"}],"wp:attachment":[{"href":"https:\/\/nag.com\/wp-json\/wp\/v2\/media?parent=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}