<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aniruddha Biswas on Medium]]></title>
        <description><![CDATA[Stories by Aniruddha Biswas on Medium]]></description>
        <link>https://medium.com/@aniruddha.connect?source=rss-cde4bdb8ca9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NQ4T6dz9rx-XF7rWUjhQkw.jpeg</url>
            <title>Stories by Aniruddha Biswas on Medium</title>
            <link>https://medium.com/@aniruddha.connect?source=rss-cde4bdb8ca9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 19:05:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aniruddha.connect/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Possible Role of India’s NQM in Supercharging NLP & PM Gati Shakti]]></title>
            <link>https://medium.com/@aniruddha.connect/the-possible-role-of-indias-nqm-in-supercharging-nlp-pm-gati-shakti-5af87efe2eea?source=rss-cde4bdb8ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5af87efe2eea</guid>
            <category><![CDATA[supply-chain]]></category>
            <category><![CDATA[national-quantum-mission]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[logistics]]></category>
            <category><![CDATA[india]]></category>
            <dc:creator><![CDATA[Aniruddha Biswas]]></dc:creator>
            <pubDate>Mon, 19 May 2025 17:58:10 GMT</pubDate>
            <atom:updated>2025-05-19T17:58:10.259Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PDxFTzm1MlT8PnEuVtry8g.png" /></figure><p>Being 4th largest economy, India rapidly advancing in frontier technologies and strategically overhauling its foundational infrastructure. The National Quantum Mission (NQM) and the National Logistics Policy (NLP) represent two such ambitious national initiatives. The NQM aims to position India as a global leader in quantum technology research and development, while the NLP with PM Gati Shakti Master Plan is focused on enhancing efficiency and significantly reducing the costs associated with the country’s logistics sector and its required infrastructure. While seemingly distinct, the potential for synergy between these two domains is immense. Quantum technologies, with their revolutionary capabilities in computation, communication and sensing can act as a powerful catalyst in achieving the core objectives outlined in the NLP.</p><p>In this article, we aim to delve into the specifics of both policies and explore how the cutting-edge advancements fostered by the NQM can be strategically leveraged to transform India’s logistics landscape.</p><h3>India’s National Logistics Policy (NLP) &amp; PM Gati Shakti Master Plan</h3><p>Launched in September 2022, the National Logistics Policy (NLP) is a comprehensive framework aimed at enhancing efficiency and reducing the cost of logistics operations in India. Its core objective is to bring down logistics costs from the current 13–14% of GDP to a global benchmark of 8% by 2030. Achieving this target is expected to significantly improve India’s position in the World Bank’s Logistics Performance Index (LPI), with an ambition to rank among the top 25 countries globally by 2030. The NLP envisions the creation of an integrated, technology-enabled and reliable logistics ecosystem to enhance the competitiveness of Indian goods in both domestic and international markets. A key enabler of this vision is the PM Gati Shakti National Master Plan (PMGSMP), a digital infrastructure platform designed to facilitate coordinated and data-driven infrastructure planning across ministries and states. By integrating geospatial data from over 44 ministries and all states/UTs, PMGSMP supports the identification of logistics bottlenecks, improves multimodal connectivity, and streamlines project implementation. Together, the NLP and PM Gati Shakti provide a unified policy and execution framework, focusing on regulatory simplification, workforce skilling, and technological modernization — laying the groundwork for a globally competitive, future-ready logistics sector in India.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*eu_ePEcAqEJW-eG5q9dRxQ.png" /></figure><p><em>To learn more about the </em><a href="https://www.youtube.com/watch?v=M9bhCVqGaOI&amp;t=103s&amp;pp=ygUZbmF0aW9uYWwgbG9naXN0aWNzIHBvbGljeQ%3D%3D"><strong><em>National Logistics Policy (NLP)</em></strong></a><em> and </em><a href="https://www.youtube.com/watch?v=py0cfqlhTp8&amp;pp=ygUOcG0gZ2F0aSBzaGFrdGk%3D"><strong><em>PM Gati Shakti Master Plan</em></strong></a><em> watch these videos from </em><strong><em>ThinkSchool</em></strong><em>.</em></p><h3>India’s National Quantum Mission (NQM)</h3><p>Approved on April 2023, with a ₹6000 crore budget over eight years, India’s National Quantum Mission (NQM) aims to position the nation as a leader in quantum technology. It seeks to seed, nurture and scale up quantum research and development for economic growth, enhanced national security, and technological self-reliance, aligning with national priorities like Digital India and Make in India. A key goal is to develop intermediate-scale quantum computers, progressing from 20–50 physical qubits in three years to 50–1000 in eight years. As a PM-STIAC initiative, the NQM underscores India’s commitment to becoming a global quantum hub.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPr3L3e_a0Uo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPr3L3e_a0Uo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPr3L3e_a0Uo%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fab9b775067e7f36a4e0cec1b07c82b/href">https://medium.com/media/1fab9b775067e7f36a4e0cec1b07c82b/href</a></iframe><p>The NQM strategically focuses on four areas with respective Thematic-hubs (T-Hubs): Quantum Computing (IISc Bengaluru), Quantum Communication (IIT Madras &amp; C-DoT), Quantum Sensing &amp; Metrology (IIT Bombay) and Quantum Materials &amp; Devices (IIT Delhi).</p><p>Implementation involves leveraging academic and research institutions through four specialized T-Hubs operating on a Hub-Spoke-Spike model. The Mission Coordination Cell (MCC) oversees implementation under the Mission Technology Research Council (MTRC). The NQM emphasizes indigenous technology development, intellectual property creation, startup support, public-private partnerships and human capital development.</p><h3>A Mini-Status Report on NLP &amp; PM Gati Shakti</h3><p>NLP combined with PM Gati Shakti has already promised <a href="https://www.pib.gov.in/PressReleaseIframePage.aspx?PRID=2117707">35 Multi-Modal Logistics Parks</a>, 11 industrial corridors, increasing the total cargo handled and cargo movement on national waterways, developing state-of-the-art quality air ports, waterdromes etc. Now in 2025, it’s important for us to dive in and check how well the government was fulfilling its promises.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*2uBvbBxKhg2JgYqLykakrQ.png" /><figcaption><a href="https://dpiit.gov.in/sites/default/files/NationalLogisticsPolicy_2022_21September2023.pdf">https://dpiit.gov.in/sites/default/files/NationalLogisticsPolicy_2022_21September2023.pdf</a></figcaption></figure><p>The <a href="https://www.fr8.in/blog/unified-logistics-interface-platform-ulip-india/">Indian logistics market is worth over $200 billion </a>as per government estimates with 20 govt. agencies, 40 govt. partner agencies, 35+ logistics services, 125+ inland container depots, 160+ container freight stations with many other middleware organisations. Hence clearance of paperwork in order to transport goods takes a lot of time. Despite all these issues, the government has made significant strides toward streamlining infrastructure planning and logistics operations. Central to this effort is the PM Gati Shakti digital platform, which, as of October 2024, <a href="https://www.pib.gov.in/PressNoteDetails.aspx?NoteId=153274">has integrated 1600+ data layers from 44 central ministries and all 36 states</a> and union territories. This platform has enabled the identification of 156 critical infrastructure gaps in sectors like coal, steel, ports and food distribution; and has been pivotal in strategic planning — facilitating the development of over 9000 km of roads and 27000 km of railway lines approximately. Complementing this, all states and UTs have established their respective State Master Plan (SMP) portals, supported by regular monitoring through the Empowered Group of Secretaries (EGoS) and the Network Planning Group (NPG). The NLP is significantly focused on developing digital infrastructure through key initiatives such as the <strong>Integration of Digital System (IDS)</strong>, which aims to integrate digital systems across various ministries involved in logistics. The <strong>Unified Logistics Interface Platform (ULIP)</strong> is another crucial component, connecting 44 systems across 11 ministries and offering access to over 2200+ data fields via 130 APIs. To know more about how ULIP is transforming India’s logistics, read this article from YourStory “<a href="https://yourstory.com/2023/11/ulip-game-changer-logistics-ecosystem"><strong><em>How ULIP is revolutionising India’s logistics landscape</em></strong></a>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VZMUvQ_-5cSDj-vZ.png" /><figcaption><a href="https://goulip.in/home">https://goulip.in/home</a></figcaption></figure><p>Innovation is further driven through initiatives like the <a href="https://hackathon.goulip.in/"><strong>ULIP Logixtics Hackathon 2.0</strong></a> launched in September 2024. Alongside infrastructure development, efforts under the <strong>Ease of Logistics (E-Logs)</strong> initiative continue to reduce documentation burdens and promote process standardization. Five <strong>Multi-Modal Logistics Parks </strong>are currently under development and expected to be operational by FY 2025–26 and 2026–27, despite some ongoing land acquisition challenges. Collectively, these measures aim to cut through bureaucratic red tape, lower logistics costs and enhance operational efficiency across the sector while promoting the adoption of technologies like AI, IoT and data analytics to optimize logistics operations, improve real-time tracking and enhance decision-making.</p><blockquote>India stands at 38 in the Logistics Policy Index (2023) with logistics cost of 8.9% of it GDP. Is this growth sustainable?</blockquote><p>Nope mostly. Despite recent advancements, several critical challenges continue to hinder the full realization of India’s logistics potential. High turnaround times at ports have led to underutilization of cargo handling capacity, limiting trade volumes. While AI-enabled project clearance systems have significantly reduced approval times from 200–300 days to just a few days, poor employee and machine scheduling mechanisms still impede timely execution. Additionally, inadequate warehouse and <a href="https://reliefweb.int/report/world/millions-go-hungry-india-eyes-ways-stop-wasting-14-billion-food-year">cold storage infrastructure results in annual losses of around $14 billion</a>, particularly affecting the agriculture and perishable goods sectors. Furthermore, over 70% of freight in India is transported by road — one of the costliest modes — far exceeding the modal share in developed economies, thereby inflating overall logistics costs and reducing competitiveness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*EYXKTX6UvnH8VpITZST64w.png" /><figcaption><a href="https://www.motorindiaonline.in/13-of-gdp-to-8-the-race-to-slash-indias-high-logistics-costs/">https://www.motorindiaonline.in/13-of-gdp-to-8-the-race-to-slash-indias-high-logistics-costs/</a></figcaption></figure><blockquote>Being pretty close to 8% of the global average with our logistics cost, we may not be able to reach the goal.</blockquote><p>The government has demonstrated notable efficiency in implementing digital technologies, which form the backbone of the National Logistics Policy (NLP) and the PM Gati Shakti Master Plan. Significant progress has been made through robust software infrastructure development and AI enablement within the scope of these initiatives. However, many persistent challenges in the logistics ecosystem remain computationally complex and beyond the capabilities of classical computing systems. <strong>In practice, developers may have relied on open-source tools or commercial APIs to address these issues partially, often without delving into the underlying theoretical complexity.</strong> In a large-scale, probabilistic and interconnected system like India’s logistics network, it is expected that certain classes of problems — particularly those involving<strong> large-scale simulation, combinatorial optimization, and advanced machine learning</strong> — will continue to constrain system performance. These are inherently hard problems where classical approaches fall short and quantum computing presents a promising frontier for achieving breakthroughs and driving further optimization across the logistics value chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*MaP2eG8rqtKmvsdwq6V5dw.png" /></figure><h3>Quantum Opportunities within NLP Framework</h3><p>Here it’s very important to mention the European initiative on the “<a href="https://www.picenter.gatech.edu/physical-internet"><strong>Physical Internet</strong></a><strong>” (PI).</strong> The concept of the Physical Internet, spearheaded in Europe by the <a href="https://www.etp-logistics.eu/"><strong>Alliance for Logistics Innovation through Collaboration in Europe (ALICE)</strong></a>, offers a compelling vision for the future of logistics that can inspire India’s approach to leveraging quantum computing. The PI aims to create an open, interconnected and efficient logistics system by drawing inspiration from the architecture of the <strong>digital internet</strong>. This involves standardizing logistics units (like smart, modular containers), creating open networks of logistics facilities (PI nodes) and establishing protocols for a seamless flow of goods across different carriers and modes of transport across Europe.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPJyzFaKOXnY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPJyzFaKOXnY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPJyzFaKOXnY%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/64dbb6f7603f372a833ea318577b3571/href">https://medium.com/media/64dbb6f7603f372a833ea318577b3571/href</a></iframe><blockquote>To know more about the companies and their projects under ALICE initiative please refer to this <a href="https://www.youtube.com/watch?v=Xtox3p2ipCI&amp;list=PLxdsc7eCmCO5KEcnoXzXHW1S2NsBMaWIo">youtube playlist</a>.</blockquote><p>ALICE highlights the vast potential for improvement in logistics and supply chain. While AI can streamline governance by minimizing paperwork, quantum computing holds the key to tackling the incredibly complex computational challenges inherent in interconnected and distributed logistics networks.</p><p>Here it becomes absolutely important to mention that through the ULIP portal, the govt is already addressing a few <strong>quantum-worthy problems</strong> classically,</p><ul><li><strong>Multi-modal Route optimization</strong></li><li><strong>Empty Container positioning</strong></li><li><strong>Real-time Inventory Management</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*O83fEpPyBnBnDZQFTkkxFw.png" /><figcaption><a href="https://goulip.in/home">https://goulip.in/home</a></figcaption></figure><p>There are tons of other problems where quantum could be the better fit. Some of them could be,</p><ul><li>For <strong>Trans-shipment hubs (Vizhinjam seaport, ICTT Kochin, ICTP Andaman &amp; Nicobar </strong>etc.<strong>) </strong>quantum could optimize vessel/vehicle scheduling and berthing/docking, cargo stowage and yard management, crane and equipment scheduling, intermodal connection optimization, the sequence of operations for cargo transfer and real-time disruption management via dynamic rescheduling within transhipment hubs.</li><li>With <strong>CCI (CONCOR) </strong>and the ULIP portal, quantum could be tried to solve bin-packing problems and empty container shipping.</li><li>While with <strong>CRIS (Center of Railway Information System)</strong>, <strong>FOIS (Freight Operation Information System</strong>) and <strong>DFCCIL (Dedicated Freight Corridor Corporation of India Limited) </strong>qubits can help solve critical challenges like optimizing goods train scheduling and routing, predictively maintaining rolling stock and infrastructure, optimize energy consumption for train operations, efficiently allocate resources at interchanges and hubs, rerouting empty wagons, effectively manage disruptions and reschedule operations, strategically plan capacity and many more.</li><li>Despite being a separate entity <strong>ONDC (Open Network for Digiital Commerce) </strong>can also benefit through last-mile delivery and inventory management.</li></ul><p>Besides this Quantum computing offers significant potential across logistics, enabling efficient route optimization by analyzing real-time factors, optimizing the entire supply chain through demand, inventory and cost analysis, determining optimal warehouse storage and picking for space maximization and faster fulfilment, optimizing fleet vehicle usage and maintenance with real-time data to minimize downtime and enhancing dynamic resource allocation within logistics hubs to reduce bottlenecks and maximize throughput.</p><h3>Required Initiatives — The Possible Solution</h3><p>It’s crucial for India to proactively foster the application of quantum computing within its ambitious PM Gati Shakti Master Plan through NLP. To truly leverage this transformative technology, a concerted effort involving the government, private sector and academia is essential. Let’s elaborate on some of the required initiatives:</p><ul><li>For quantum computing to deliver tangible benefits to the PM Gati Shakti initiative, <strong>the identification of relevant use cases is paramount</strong>. This requires a collaborative approach where the practical understanding of government bureaucrats, the cutting-edge knowledge of NQM stakeholders and the real-world operational expertise of logistic and supply chain players.</li><li>Translating promising quantum-centric use cases into real-world solutions through substantial and sustained financial investment <strong>project-centric internships/RA/PhD/Postdoctoral fellowships</strong>. Funding strategies should consider both the long-term transformative potential and the need for tangible short-term progress.</li><li>The <strong>involvement of established Indian industry giants</strong> for the practical implementation and scaling of quantum solutions developed for PM Gati Shakti through paid contracts. These companies possess the engineering capabilities, technological infrastructure and market reach necessary to translate research outcomes into real-world applications.</li><li>To ensure that research efforts translate into practical and deployable solutions, it’s <strong>essential to incentivize researchers in both academia and industry </strong>to achieve higher Technology Readiness Levels (TRL).</li><li>Focus on the infrastructure development realized through quantum-driven solutions.</li></ul><blockquote>As an example one can think of under the PM Gati Shakti plan, the Indian government initiates a project to <strong>optimize railway freight scheduling </strong>on the busy <strong>Delhi-Mumbai Corridor (DFC)</strong>. Quantum computing researchers at a national lab collaborate with <strong>ABC</strong> organization for infrastructure expertise and real operational data. The <strong>NQM</strong> funds the development of a quantum-enhanced scheduling algorithm (short-term goal). As the algorithm shows promise in simulations (TRL 5), <strong>XYZ </strong>organization<strong> </strong>is brought in to design and integrate the algorithm into the existing railway operational workflow and IT systems (<strong>CRIS</strong>). Successful pilot implementation on a section of the corridor, demonstrating reduced transit times and improved punctuality (TRL 7), earns the researchers recognition. ABC and <strong>XYZ</strong> receive incentives for their collaboration in applying advanced technology. Scaling this integrated quantum solution across the entire DFC and other corridors (TRL 8) triggers further government support for continued innovation and nationwide deployment.</blockquote><h3>The Gateway to Quantum Leap in Logistics</h3><p>In conclusion, while the implementation of the National Logistics Policy (NLP) in India’s complex, price-sensitive market poses substantial challenges, the government’s commitment to building a robust digital public infrastructure under the PM Gati Shakti Master Plan has laid a solid foundation for policy realization. However, despite these cutting-edge, data-driven efforts, operational inefficiencies may still persist due to the presence of computationally hard problems — such as complex optimization, simulation, and machine learning — that are inherently intractable for classical systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*GzL9NpqBstEdIHXjrMqxeQ.png" /></figure><p>These challenges represent promising opportunities for quantum computing, which is uniquely equipped to tackle such complexity. To truly harness this potential, it is crucial to establish a collaborative framework that brings together quantum scientists, policymakers, technologists and logistics experts to identify “<strong>quantum-worthy</strong>” problems and develop targeted quantum solutions. Beyond computation, India’s National Quantum Mission also emphasizes quantum communication technologies like Quantum Key Distribution (QKD), which can provide unbreakable security for critical logistics data within LDB 2.0, protecting supply chains from growing cyber threats. With milestones such as the launch of India’s first indigenously developed <strong>25-qubit quantum computer by QPiAI (</strong><a href="https://manufacturing.economictimes.indiatimes.com/news/hi-tech/lt-cloudfiniti-joins-hands-with-qpiai-to-advance-quantum-computing-capabilities/121182740"><strong>L&amp;T-Cloudfiniti joins hands with QpiAI to advance quantum computing capability</strong></a><strong>) </strong>and Andhra Pradesh’s announcement of the first <a href="https://www.hindustantimes.com/india-news/amaravati-to-have-india-s-first-quantum-valley-tech-park-by-january-next-year-101746300527156.html"><strong>Quantum Valley (jointly with IBM, TCS and L&amp;T)</strong></a><strong> in Amravati</strong>, the country is taking bold steps toward quantum readiness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*ao7rWjr8df5mSdgLC7O8RQ.png" /><figcaption><a href="https://qpiai.tech/products/qpiai-indus-quantum">https://qpiai.tech/products/qpiai-indus-quantum</a></figcaption></figure><p>To truly transform the logistics sector and make India “<strong>Atmanirbhar</strong>” in the supply chain it is imperative that stakeholders from NQM, NLP and PM Gati Shakti come together to align strategy, innovation and investment around the transformative potential of quantum technologies.</p><p>Thanks for reading this article. For more articles, please follow me on Medium and <a href="https://www.linkedin.com/in/aniruddhadotconnect/">Linkedin</a>.</p><h4>References</h4><ul><li><a href="https://theprint.in/india/governance/how-gati-shakti-master-plan-has-pulled-ministries-out-of-silos-is-helping-plan-projects-better/881878/">https://theprint.in/india/governance/how-gati-shakti-master-plan-has-pulled-ministries-out-of-silos-is-helping-plan-projects-better/881878/</a></li><li><a href="https://dpiit.gov.in/sites/default/files/Gati-Shakti-FAQ-web_08March2022.pdf">https://dpiit.gov.in/sites/default/files/Gati-Shakti-FAQ-web_08March2022.pdf</a></li><li><a href="https://www.etp-logistics.eu/wp-content/uploads/2022/11/Roadmap-to-Physical-Intenet-Executive-Version_Final-web.pdf">https://www.etp-logistics.eu/wp-content/uploads/2022/11/Roadmap-to-Physical-Intenet-Executive-Version_Final-web.pdf</a></li><li><a href="https://yourstory.com/2023/11/ulip-game-changer-logistics-ecosystem">https://yourstory.com/2023/11/ulip-game-changer-logistics-ecosystem</a></li><li><a href="https://arunpandit.com/wp-content/uploads/2021/08/Draft-National-Logistics-Policy.pdf">https://arunpandit.com/wp-content/uploads/2021/08/Draft-National-Logistics-Policy.pdf</a></li><li><a href="https://cewacor.nic.in/WriteReadData/Centralize/Latest%20News/EN_e-Book15.09.2022v2_1efdc631-4e37-4c50-87c5-05260628910b.pdf">https://cewacor.nic.in/WriteReadData/Centralize/Latest%20News/EN_e-Book15.09.2022v2_1efdc631-4e37-4c50-87c5-05260628910b.pdf</a></li><li><a href="https://www.fr8.in/blog/unified-logistics-interface-platform-ulip-india/">https://www.fr8.in/blog/unified-logistics-interface-platform-ulip-india/</a></li><li><a href="https://aiut.com/en/blog/physical-internet-in-logistics/">https://aiut.com/en/blog/physical-internet-in-logistics/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5af87efe2eea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Portfolio Optimization: The Quantum Monte Carlo (QMC) technique; you should not go for!]]></title>
            <link>https://medium.com/@aniruddha.connect/portfolio-optimization-the-quantum-monte-carlo-qmc-technique-you-should-not-go-for-67d0de5ba8dc?source=rss-cde4bdb8ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/67d0de5ba8dc</guid>
            <category><![CDATA[monte-carlo-simulation]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[quantum-finance]]></category>
            <category><![CDATA[quantum-monte-carlo]]></category>
            <category><![CDATA[portfolio-optimization]]></category>
            <dc:creator><![CDATA[Aniruddha Biswas]]></dc:creator>
            <pubDate>Fri, 24 Jan 2025 19:40:09 GMT</pubDate>
            <atom:updated>2025-01-24T19:40:09.782Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u9LHBLM7Q6gyY2ewRz9ZrA.png" /></figure><p>In the dynamic world of investing, constructing an asset portfolio that maximizes returns while minimizing risk is a constant challenge. This blog post explores how a quantum computer can be used to <strong><em>mimic</em></strong> classical Monte Carlo simulation and provide a semi-realistic framework for assessing risk and identifying optimal asset allocations.</p><h3>Financial Portfolio Optimization (FPO): The Problem</h3><p>Financial Portfolio Optimization (FPO) is a quantitative method used in finance to select the best mix of assets for an investment portfolio, aiming to achieve maximum return while minimizing the risk. Though the problem looks pretty naive, but it quickly gets intractable with a little increase in the number of assets. Hence for a few decades, the problem of FPO has always been of prime interest to quants and computer scientists.</p><p>Even today, researchers are trying to develop new algorithms which can tackle the problem of FPO with polynomial complexity. Besides state-of-art classical algorithms (Genetic algorithm, Simulated Annealing, Branch and Cut etc.) a big focus is also hovering around Hybrid Quantum-Classical approaches like VQE, QAOA or Quantum Annealing, which mostly try to solve the FPO under a workflow of mathematical optimization.</p><h4>Efficient Frontier</h4><p>According to Markowitz, a portfolio is optimal if no other portfolio has a higher expected return for a given level of risk. The concept of Efficient Frontier was also introduced by Markowitz in 1952, and illustrates a set of optimal portfolios that offer the highest expected return for a defined level of risk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*IxCnZVDNagI0DNDE.jpg" /></figure><p>Markowitz assumed investors primarily focus on the expected return and variance of return as key parameters to assess investment opportunities and exhibit risk aversion. Hence we’ll use “<strong><em>Sharpe Ratio</em></strong>” as a performance index at the end.</p><h3>What is Monte Carlo Simulation?</h3><blockquote>It is a computational technique that employs repeated random sampling to model the probability of various outcomes within a system. By generating numerous scenarios with randomly selected inputs, it creates a distribution of potential results, providing valuable insights into the likelihood of different events and their potential impacts. This approach is particularly useful in situations involving uncertainty and complex interdependencies between variables, allowing for a more comprehensive understanding of risk and the exploration of potential consequences.</blockquote><blockquote>To read more about how the Classical Monte Carlo method can be used to optimize portfolio <a href="https://python.plainenglish.io/monte-carlo-simulation-in-python-a0411ac7479e">click here</a>.</blockquote><h3>Let’s Implement</h3><p>The implementation starts with importing the necessary packages and libraries from the data science, quantum computing and quant finance world.</p><pre>import numpy as np<br>import pandas as pd<br>from collections import Counter<br>import matplotlib.pyplot as plt<br>from qiskit import *<br>from qiskit_aer import AerSimulator<br>from qiskit.circuit import QuantumCircuit<br>from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager<br>from qiskit_ibm_runtime import Session, Sampler as Sampler, QiskitRuntimeService, Options<br>from qiskit.visualization import plot_histogram<br>from qiskit_ibm_runtime import SamplerV2 <br>import seaborn as sns <br>import yfinance as yf</pre><p>For a simple demonstration, we have taken historical <strong>closing price data</strong> of only 4 stocks: Microsoft (MSFT), Google (GOOGL), Amazon (AMZN) and Tesla (TSLA) from “<strong>yfinance” </strong>from January 2018 to January 2020.</p><pre>assets = [&#39;MSFT&#39;,&#39;GOOGL&#39;,&#39;AMZN&#39;,&#39;TSLA&#39;]<br>data = yf.download(assets,start=&#39;2018-1-1&#39;,end=&#39;2020-1-31&#39;)[&#39;Close&#39;]<br>data.head()</pre><p>The code below calculates the mean annualized return and annualized volatility of the mentioned assets, as well as a heatmap plot of the correlation matrix.</p><pre>returns = data.pct_change().dropna()<br>prices = data.iloc[-1]<br>mean_returns = returns.mean()*252<br>annual_std = returns.std()*np.sqrt(252)<br>covariance = returns.cov()<br>sns.heatmap(returns.corr())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*ExiKMXwjwjYZe6FRmu5YYw.png" /></figure><h4>Mimicking Monte Carlo Sampling on Quantum Simulator: Our Approach</h4><p>The key inspiration comes from the concept of the “<strong>Binary to Decimal</strong>” conversion of fractions between 0 and 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AFfmwTPFs4-UbmS1.png" /></figure><blockquote>Depending upon the required resolution we allocate ’n’ number of qubits to each of the assets (here n=4 qubits for each of the p=4 assets, total N= n*p = 4*4 =16 qubits) and then apply Hadamard gate to all the qubits for generating uniform superposition. Then, we generate k=N/n sub-bitstrings by making cuts at every ‘n’ bit from each of the bitstrings of length N. Finally, we convert each of the sub-bitstrings to decimal numbers between 0 to 1 following the above convention using the function below.</blockquote><pre>def bitstring_to_frac(bitstring):<br>    num = 0<br>    for i in range(len(bitstring)):<br>        num = num + int(bitstring[i])/2**(i+1)<br>    return num</pre><p>The code below implements the simplest quantum circuit for the above.</p><pre>n = 4 # qubits per asset<br>p = data.shape[1] # number of assets<br><br>qreg = QuantumRegister(n*p)<br>circuit = QuantumCircuit(qreg)<br><br><br>circuit.h(range(len(qreg)))<br>circuit.measure_all()<br>circuit.draw(&#39;mpl&#39;,fold=200)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bjoSD8RY4CnD6PADPnOWpg.png" /></figure><p>As we generate a bunch (<strong>num_simulations</strong>) of random weights in vanilla Monte Carlo methods, similarly we provide the same number of <strong>shots</strong> to our quantum circuits for measurements.</p><pre>num_simulations = 500<br>backend = AerSimulator()<br>sampler = SamplerV2(backend)<br><br><br>job = sampler.run([circuit],shots=num_simulations)<br>result = job.result()<br>pub_result = result[0]<br>sim_results = list(pub_result.data.meas.get_counts().keys())</pre><p>Then we collect all the samples generated by the quantum circuit. Finally, each of the bitstrings is post-processed and normalized to get the random weights for each of the sub-bitstrings. The code snipped below also provides a vanilla/classical implementation of the Monte Carlo method for portfolio optimization in addition to the quantum postprocessing.</p><pre>random_Q_weights = []<br>random_C_weights = []<br>Q_Returns, Q_Risks, Q_Sharpe = [], [], []<br>C_Returns, C_Risks, C_Sharpe = [], [], []<br><br><br>for s in range(len(sim_results)):<br>    state = sim_results[s]<br>    Q_random_numbers = []<br>    for k in range(0,len(state),n):<br>        bitstring = state[k:k+n]<br>        num = bitstring_to_frac(bitstring)<br>        Q_random_numbers.append(num)<br><br>    Q_weights = np.array(Q_random_numbers)/np.array(Q_random_numbers).sum()<br>    random_Q_weights.append(Q_weights)<br>    Q_Returns.append((Q_weights@mean_returns)*100)<br>    Q_Risks.append(np.sqrt(Q_weights@(covariance*252)@Q_weights)*100)<br>    Q_Sharpe.append((Q_weights@mean_returns)/(np.sqrt(Q_weights@(covariance*252)@Q_weights)))<br><br><br>    ########## Classical #######################<br>    C_random_numbers = np.random.random(data.shape[1])<br>    C_weights = C_random_numbers/sum(C_random_numbers)<br>    random_C_weights.append(C_weights)<br>    C_Returns.append((C_weights@mean_returns)*100)<br>    C_Risks.append(np.sqrt(C_weights@(covariance*252)@C_weights)*100)<br>    C_Sharpe.append((C_weights@mean_returns)/(np.sqrt(C_weights@(covariance*252)@C_weights)))<br>    <br>    print(&#39;\nthe quantum State:|{}&gt;&#39;.format(state))<br>    print(&quot;quantum weights  :{}&quot;.format(Q_weights))<br>    print(&quot;classical weights:{}&quot;.format(C_weights))</pre><p>Here are a few samples from classical and quantum approaches using the above code.</p><pre>the quantum State:|0110011010011011&gt;<br>quantum weights  :[0.1875  0.1875  0.28125 0.34375]<br>classical weights:[0.01454763 0.41959389 0.17322651 0.39263197]<br><br>the quantum State:|1101110011110101&gt;<br>quantum weights  :[0.28888889 0.26666667 0.33333333 0.11111111]<br>classical weights:[0.25905008 0.3008803  0.12854553 0.31152409]<br><br>the quantum State:|1110000101011001&gt;<br>quantum weights  :[0.48275862 0.03448276 0.17241379 0.31034483]<br>classical weights:[0.31927557 0.30690259 0.28808769 0.08573415]<br><br>the quantum State:|1110100011000000&gt;<br>quantum weights  :[0.41176471 0.23529412 0.35294118 0.        ]<br>classical weights:[0.1716555  0.14754953 0.21898631 0.46180865]</pre><p>Once we have these randomly generated samples, we can plot them in a <strong>Risk (x)-Return(y) </strong>plot to get the efficient frontier. In the given plot we also have marked the best results obtained from classical MC and our mimicked Q-MC.</p><pre>plt.scatter(C_Risks,C_Returns,alpha=0.5,label=&#39;Classical&#39;)<br>plt.scatter(Q_Risks,Q_Returns,alpha=0.6,label=&#39;Quantum&#39;)<br>plt.scatter(best[&#39;classical&#39;][&#39;Risk&#39;],best[&#39;classical&#39;][&#39;Return&#39;],color=&#39;red&#39;,label=&#39;Best Classical&#39;)<br>plt.scatter(best[&#39;quantum&#39;][&#39;Risk&#39;],best[&#39;quantum&#39;][&#39;Return&#39;],color=&#39;green&#39;,label=&#39;Best Quantum&#39;)<br>plt.xlabel(&quot;Risk&quot;)<br>plt.ylabel(&quot;Return&quot;)<br>plt.legend([&#39;Classical MC&#39;,&#39;Mimicked Q-MC&#39;,&#39;Best Classical&#39;,&#39;Best Quantum&#39;],loc=&#39;lower right&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*Ue0JwpVbgRbBPM46d9TDHA.png" /><figcaption>Risk vs Return Plot</figcaption></figure><p>The above plot essentially shows that the best sample obtained from the quantum method shows a better <strong>Shape ratio</strong> (1.61) than the vanilla classical MC, which is around 1.52.</p><pre>{&#39;classical&#39;: {&#39;Sharpe&#39;: 1.5376464165759325,<br>  &#39;Return&#39;: 37.33601378522685,<br>  &#39;Risk&#39;: 24.281273888939673,<br>  &#39;weights&#39;: array([0.13868   , 0.01839701, 0.72841327, 0.11450972])},<br> &#39;quantum&#39;: {&#39;Sharpe&#39;: 1.4956898631756192,<br>  &#39;Return&#39;: 37.96778782753384,<br>  &#39;Risk&#39;: 25.38479985878983,<br>  &#39;weights&#39;: array([0.125     , 0.04166667, 0.625     , 0.20833333])}}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*UzfeHFB0GlMU8XHceVl1TQ.png" /><figcaption>distribution of weights in pie chart</figcaption></figure><p>There are also a few steps which may improve the results obtained from quantum computers within this approach,</p><ul><li>One can always think of allocating more bits/qubits for each sampled random decimal number.</li><li><strong>num-simulations/shots</strong> can be increased up to 10000 (or more), whichever seems the maximum number of shots allowed by the IBM Qiskit simulator.</li><li>Here the circuit take considers uniform superposition among the samples through Hadamard initiation. However one can always think of sampling from a specific distribution based on the return distribution &amp; correlation among the underlying assets.</li></ul><h3>So what are the key takeaways?</h3><ul><li>This approach shows how one can generate random decimal numbers from a quantum simulator and the samples can be used to solve some Monte Carlo simulation problems.</li><li>Our approach is NOT a real implementation of Quantum Monte Carlo (QMC), it just shows how a quantum simulator can be used to mimic the classical Monte Carlo technique. To get some understanding around actual QMC please have a look here at <a href="https://aws.amazon.com/blogs/quantum-computing/quantum-monte-carlo-on-quantum-computers/">link1</a> and <a href="https://in.mathworks.com/help/matlab/math/quantum-monte-carlo-simulation.html">link2</a>.</li><li>This method of doing MC simulation is not computationally scalable and does NOT provide any so-called “<strong>Quantum Advantage</strong>”. So,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/0*1mDalbe6VR3-2hNU.png" /></figure><ul><li><strong><em>Lastly, this content is purely for educational purposes and is not to be relied on as investment, legal, tax or other advice as it does not take into account the investment objectives, financial situation or particular needs of any specific investor.</em></strong></li></ul><p>Thanks for reading this article. For more such articles please follow me on Medium and <a href="https://www.linkedin.com/in/aniruddhadotconnect/">Linkedin</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67d0de5ba8dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Randomized Kolkata Paise Restaurant (KPR) Game on Quantum Computer]]></title>
            <link>https://medium.com/@aniruddha.connect/randomized-kolkata-paise-restaurant-kpr-game-on-quantum-computer-59328ac1c13c?source=rss-cde4bdb8ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/59328ac1c13c</guid>
            <category><![CDATA[econophysics]]></category>
            <category><![CDATA[restaurant]]></category>
            <category><![CDATA[game-theory]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[kolkata]]></category>
            <dc:creator><![CDATA[Aniruddha Biswas]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 18:30:35 GMT</pubDate>
            <atom:updated>2024-09-29T18:56:08.000Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*z1EhkskznUXrnKfZ.jpg" /><figcaption>A standard Paise/Pice hotel Food (Source Google Images)</figcaption></figure><p>If you have ever been to Kolkata, you know besides being the “<strong><em>City of Joy</em></strong>”, it is also one of the best Indian cities for the finest multi-cuisine foods. Though the city mainly inherits Bengali culture, from historical days people from different parts of the world have contributed to it so well that one can easily find restaurants with different cuisines spread over the entire city. On one side you can see restaurants such as Koshe-Kosha, 6 Ballygunge Place, Kasturi, Bhajahari Manna, and Oh! Calcutta serving traditional Bengali foods on the other end you also get the opportunity to taste different cuisines from famous restaurants such as Arsalan, Mainland China, Oudh 1890, Aminia, Peter Cat etc.</p><p>Wait! Wait! Wait! This is not a food blog, so if you are interested in knowing more about the best food experiences in Kolkata, I’m attaching a<strong> </strong><a href="https://kolkatafoodtalks.wordpress.com/"><strong>link</strong></a> here.</p><p>But the story here goes back to a special type of cheap and fixed-rate Bengali cuisine restaurant in Kolkata, called “<a href="https://www.outlooktraveller.com/experiences/food-and-drink/kolkatas-pice-hotels-where-history-meets-authentic-bengali-food"><strong><em>Paise Restaurants</em></strong></a>” (also known as “Paise/Pice Hotels’’). These restaurants were very popular among the daily labourers in the city. Though we don’t see these restaurants in large numbers in modern days, but they are still very famous in their own vintage style. To know more about these Paise Hotels and their history do watch the video by <strong><em>Foodka </em></strong>attached below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLiEvUs97vP0%3Fstart%3D385%26feature%3Doembed%26start%3D385&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLiEvUs97vP0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FLiEvUs97vP0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b24ad070557697e50fc4c9da6bdd611c/href">https://medium.com/media/b24ad070557697e50fc4c9da6bdd611c/href</a></iframe><blockquote>“Long ago in Kolkata, there were very cheap and fixed price “<a href="https://lbb.in/kolkata/pice-hotels-kolkata/"><strong>Paise Restaurants</strong></a>” (also called “<a href="https://www.getbengal.com/details/kolkatas-pice-hotels"><strong>Paise Hotels</strong></a>”; Paise was the smallest Indian coin) which were very popular among the daily laborers in the city. During lunch hours, these laborers used to walk down (to save the transport costs) from their place of work to one of these restaurants. These Paise Restaurants would prepare every day a fixed (small) number of such dishes, and if several groups of labourers would arrive any day at the same restaurant, only one group perhaps would get their lunch and the rest would miss lunch that day. There were no cheap communication means (mobile phones) for mutual interactions, in order to decide about the respective restaurants of the day. Walking down to the next restaurant would mean failing to report back to work on time.”</blockquote><p>Let there be N Paise restaurants in Kolkata and assume that each can accommodate only one customer. Let there be exactly N customers or labourers in the city.</p><p>We assume</p><ul><li>Each of the restaurants costs the same, hence there is no common preference ranking of these restaurants to the labourers.</li><li>The labourers are non-interacting. Hence, one labourer does not know where the other labourers would go for lunch.</li></ul><p>No matter what happens each of the labourers will try to ensure the food for him/herself. While ensuring the food for each different day, they may come up with different strategies based on each of their own historical experiences. One of the easiest strategies each of them can have is the <strong><em>Randomized-KPR strategy</em></strong>, where each labourer randomly selects one restaurant during their daily lunch hour and visits it with the expectation of getting a meal for the day. <strong><em>As the labourers are independently and randomly choosing restaurants, it may happen that more than one (assume k, k&lt;N) labourer is appearing in the same restaurant and the restaurant is also randomly serving the meal to one of them. If this happens then a few (p) labourers are not getting food for the day and conversely, the ‘p’ restaurants are running out of customers leading to the under-utilization of resources in a dynamic social system</em></strong>. The labourer/restaurant derives a utility from having lunch/customer and if the labourer/restaurant does not get lunch/customer then his/its utility is zero on that particular day. This example shows that despite of having enough resources; different strategies taken by the completely non-interacting agents may lead to an overall under-optimal resource utilization. This <a href="https://www.sciencedirect.com/science/article/abs/pii/S0378437106004535"><strong><em>Minority Game</em></strong></a> is known as the famous ‘<strong><em>Kolkata Paise Restaurant Problem’</em></strong> or ‘<strong><em>KPR Problem’</em></strong>. The author also analytically showed that the Randomized-KPR strategy can only provide the expected utilization (f) of 63%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/0*wmkbZjkB5Q0nxpIt" /></figure><blockquote><strong>Expected Utilization or Utility fraction (f) is 63% -What does it mean?</strong></blockquote><blockquote>It means if the labourers follow the Randomized-KPR strategy (selecting restaurants randomly on each day), on average around <strong>37% </strong>of labourers (<strong>not the same labourers</strong>) will not be getting food on daily basis or conversely <strong>37%</strong> of Paise restaurants (<strong>not the same restaurant</strong>) will have no customers daily.</blockquote><p>Over the last 15 years, scientists around the world have tried to develop many strategies aiming for utility maximization of the KPR game, which made it one of the interesting problems to look at from the perspective of social sciences and businesses. While reading about different strategies I found the authors of “<strong><em>Stochastic Learning in Kolkata Paise Restaurant Problem: Classical and Quantum Strategies</em></strong>” have discussed a <strong><em>3 Player-3 Restaurant</em></strong> <strong><em>Quantum</em></strong> <strong><em>KPR</em></strong> game and in this blog, I’ll show how the same can be implemented using an IBM Quantum Computer.</p><h4>Simulating Randomized KPR Game on Classical Computer</h4><p>Here in this part, I have shown a numerical simulation of an <strong><em>8-labourer-8-restaurant KPR game</em></strong> written using Python on a so-called Classical computer.</p><pre>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>%matplotlib inline<br><br>def empty_cells(y,item):<br>    x = y.flatten()<br>    locs = []<br>    for i in range(x.shape[0]):<br>        if x[i] == 0 and item == &#39;restaurant&#39;:<br>            locs.append(i)<br>        elif x[i] == 1 and item == &#39;labourer&#39;:<br>            locs.append(i)<br>        else:<br>            pass<br>    return locs</pre><p>The database variable defined here keeps track of every single footfall of the labourers for all 100 days.</p><pre>N = 8 #No of players or no of restaurants<br>days = 100<br>labourers, restaurants, crowd = np.ones((days,N)), np.zeros((days,N)), np.zeros((days,N))<br>utils, database = [], {}<br><br>###### i = Labourer id, j = Restaurant id, k = day number<br>for k in range(days):<br>    while labourers[k].sum() &gt; 0:<br>        labourers_left = empty_cells(labourers[k],&#39;labourer&#39;)<br>        i = np.random.choice(labourers_left) # randomly selecting <br><br>        if labourers[k,i] == 1:<br>            j = np.random.randint(0,N)   # selecting a restaurant randomly <br>                                         # Additional criteria can be applied here<br>            if restaurants[k,j] == 0.0:<br>                restaurants[k,j] = restaurants[k,j] + 1<br>                if database.get(i) is None:<br>                    database[i] = [j]<br>                else:<br>                    database[i] = database[i] + [j] <br>            else:<br>                crowd[k,j] = crowd[k,j] + 1                <br>                if database.get(i) is None:<br>                    database[i] = [j]<br>                else:<br>                    database[i] = database[i] + [j]<br>            labourers[k,i] = labourers[k,i] - 1<br>        else:<br>            print(&#39;CAUTION!! No labourers are there.&#39;)<br>        <br>    utility = restaurants[k].sum()*100/N<br>    utils.append(utility)<br>    print(&#39;\n\nThe utility of {}-th day is: {} %&#39;.format(k,utility</pre><pre>The utility of 1-th day is: 50.0 %<br>The utility of 2-th day is: 50.0 %<br>The utility of 3-th day is: 62.5 %<br>The utility of 4-th day is: 62.5 %<br>The utility of 5-th day is: 37.5 %<br>The utility of 6-th day is: 50.0 %<br>The utility of 7-th day is: 50.0 %<br>The utility of 8-th day is: 50.0 %<br>The utility of 9-th day is: 87.5 %<br>The utility of 10-th day is: 75.0 %<br>The utility of 11-th day is: 75.0 %<br>The utility of 12-th day is: 75.0 %<br>The utility of 13-th day is: 50.0 %<br>The utility of 14-th day is: 50.0 %<br>The utility of 15-th day is: 75.0 %</pre><p>All the daily utility values are stored inside ‘<em>utils</em>’ and finally plotted against the number of days on the x-axis. A horizontal red line is also drawn to indicate the expected utilization, which is around <strong>64.62% </strong>and pretty close to the analytically calculated value i.e.<strong> 63%.</strong></p><pre>print(&quot;Classical: The average occupancy or utility is {}% for {} labourers and {} Paise restaurants&quot;.format(np.array(utils).mean(),N,N))<br>plt.figure(figsize=(15,4))<br>plt.plot(utils)<br>plt.ylabel(&quot;Daily Utility in %&quot;)<br>plt.xlabel(&quot;Number of days&quot;)<br>plt.axhline(y = np.array(utils).mean(), color = &#39;r&#39;, linestyle = &#39;-&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXblh9ls1yiy8vwTBl5Q8w.png" /></figure><h4>Simulating Randomized KPR on Quantum Computer</h4><p>This part is mainly for simulating an “<strong><em>8-labourer-8-restaurant KPR game</em></strong>” on a gate-based quantum computer/simulator. I chose <strong>IBM Qiskit </strong>to code it. The implementation is inspired by the paper “<a href="https://www.frontiersin.org/journals/artificial-intelligence/articles/10.3389/frai.2022.874061/full"><strong><em>Stochastic Learning in Kolkata Paise Restaurant Problem: Classical and Quantum Strategies</em></strong></a>” by B.K Chakrabarti, A. Rajak and A. Sinha.</p><pre>import numpy as np<br>import pandas as pd<br>from collections import Counter<br>import matplotlib.pyplot as plt<br>from qiskit import *<br>from qiskit_aer import AerSimulator<br>from qiskit.circuit import QuantumCircuit<br>from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager<br>from qiskit_ibm_runtime import Session, Sampler as Sampler, QiskitRuntimeService, Options<br>from qiskit.visualization import plot_histogram<br>from qiskit_ibm_runtime import SamplerV2</pre><p>This part is a little tricky. One can assume the restaurants are like an empty array of length 8 with ID ranges from 0 to 7 and there are also labourers having individual ID numbers with the same range.</p><blockquote><strong>Encoding Scheme</strong>: Any labourer can visit any restaurant. For example if labourer number 3 visits restaurant number 6, we’ll represent it as array number 6 (restaurant id) having an element 3 (labourer id). As the labourers’ choice of restaurant is not restricted to any specific norms, hence we have encoded the problem in such a way so that any particular cell can take any value during post measurement of the quantum circuit. Since the number of labourers and restaurants are 8 here, we have allocated 3 qubits (2³ = 8) to represent each of the restaurant ids.</blockquote><p>This cell below also helps to calculate how many qubits are needed to play the ‘<strong><em>N-labourer-N-restaurant KPR game’</em></strong>. As this blog only shows the basic implementation, hence I have only considered N=8 to be simulated with 24 qubits on a local quantum simulator.</p><pre>###### Estimting number of Qubits required (Not universal) ###########<br><br>N = 8                    # number of restaurants and number of labourers<br>n = len(format(N-1,&#39;b&#39;)) # number of qubits per restaurants/labourers<br><br>print(N*n,&quot;qubits required&quot;)</pre><pre>24 qubits required</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*lwSkegi9L-2dx23VpH_D7A.png" /></figure><p>Now you can get the logic behind this tricky encoding that enables us to do this KPR game simulation. Here the labourers (L0,L1,L2,L3,L4,L5,L6,L7) are represented via <strong>“L”</strong> and restaurants (R0,R1,R2,R3,R4,R5,R6,R7) are by <strong>“R”</strong>.</p><p>As this blog is only about the simulation of the Randomized-KPR strategy, this makes our quantum circuit construction much easier.</p><blockquote><strong><em>The event of selecting the restaurants randomly by the labourers has been implemented with a series of Hadamard gate to all the 24 qubits followed by measurements.</em></strong></blockquote><pre>#### Quantum Circuit Construction for Randomized KPR Game #############<br><br>qreg = QuantumRegister(N*n)<br>circuit = QuantumCircuit(qreg)<br><br><br>circuit.h(range(len(qreg)))<br>circuit.measure_all()<br>circuit.draw(&#39;mpl&#39;,fold=120)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcRFRXGb3gHMVNPP5_UMlQ.png" /><figcaption>Quantum Circuit of Randomized KPR Game</figcaption></figure><p>As I’ve shown the simulation of the Randomized-KPR game on a classical computer for 100 successive days, here I also have tried to do the same using a quantum simulator/computer. One thing I must say is that the simulation of the<strong><em> ‘d’ number of days</em></strong> for the Randomized-KPR game is very easy in the quantum case.</p><blockquote>Quantum Computer being a natural probabilistic machine it gives power to simulate 100 days of Randomized-KPR game just by taking <strong>100 measurement shots</strong>, and it’s insane.</blockquote><pre>days = 100<br>backend = AerSimulator()<br>sampler = SamplerV2(backend)<br><br><br>job = sampler.run([circuit],shots=days)<br>result = job.result()<br>pub_result = result[0]<br>sim_results = list(pub_result.data.meas.get_counts().keys())<br><br>plt.figure(figsize=(13,3))<br>plt.hist(sim_results,bins=199)<br>plt.ylabel(&quot;All outcomes/State distributions&quot;)<br>plt.xticks(rotation=90)<br>plt.show()</pre><p>We get the bitstring samples from 100 measurements (outcomes of the 100 days) with a histogram plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rGmkJYyDE9y8tNictu93Yg.png" /></figure><h4>Postprocessing of QPU Samples</h4><p>Now we got the samples and possible outcomes for each of the 100 successive days from the Quantum simulator. The next part is the postprocessing of the bitstring samples for the interpretation of the result. The code snippets below do the postprocessing and I have shown results for only 15 days.</p><pre>utility = []<br><br>###################################<br>restaurants = np.arange(2**n)<br>unused_restaurants = list((restaurants[restaurants &gt; (N-1)]).astype(str))<br>###################################<br><br>for s in range(len(sim_results)):<br>    state = sim_results[s]<br>    <br>    ##################  Converting the result into restaurant id  #################<br>    config = [str(int(state[i:i+n],2)) for i in range(0,len(state),n)]<br>    key = &quot;&quot;.join([str(item) for item in config]) # converted into labourer id<br><br>    ##################  Removing outputs with unused restaurants  #########<br>    if not any([x in key for x in unused_restaurants]):<br>        ######### postprocessing: replacing restaurants by X if a #########<br>        ######### labourer is already present there (starting from left) ##<br>        <br>        t = [i for i in key]<br>        counter = dict(Counter(key))<br>        uniques = list(counter.keys())<br>        k_array = np.array([int(i) for i in key])<br><br>        for u in uniques:<br>            locations = np.where(k_array == int(u))<br>            indices = locations[0][1:]<br>            if len(indices) &gt;= 1:<br>                for j in indices:<br>                    t[j] = &#39;X&#39;<br>                    # print(&#39;Replacing {} with X for {}&#39;.format(j,u))<br>            else:<br>                pass<br>        final_config = &#39;&#39;.join(t)<br>        <br>        ########### occupancy calculation #############<br>        occupancy = ((len(final_config) - final_config.count(&#39;X&#39;))/len(final_config))<br>        utility.append(occupancy)<br>        print(&quot;Day number {}:|{}&gt; --&gt; {} --&gt; {} with utility:{}%&quot;.format(s+1,state,key,final_config,occupancy*100))<br>    else:<br>        print(key,&#39;is an invalid cofiguration&#39;)<br>        pass</pre><pre>Day 1:|001111000111001001011111&gt; --&gt; 17071137 --&gt; 170XXX3X with utility:50.0%<br>Day 2:|100110101000010110011011&gt; --&gt; 46502633 --&gt; 46502X3X with utility:75.0%<br>Day 3:|111111110111101001000010&gt; --&gt; 77675102 --&gt; 7X6X5102 with utility:75.0%<br>Day 4:|001000001111000111011011&gt; --&gt; 10170733 --&gt; 10X7XX3X with utility:50.0%<br><strong>Day 5:|101001110011110011000011&gt; --&gt; 51636303 --&gt; 5163XX0X with utility:62.5%<br></strong>Day 6:|010001101010110000110100&gt; --&gt; 21526064 --&gt; 215X60X4 with utility:75.0%<br>Day 7:|000111000011001000010010&gt; --&gt; 07031022 --&gt; 07X31X2X with utility:62.5%<br>Day 8:|000110110011101011011001&gt; --&gt; 06635331 --&gt; 06X35XX1 with utility:62.5%<br>Day 9:|101101010100010111100010&gt; --&gt; 55242742 --&gt; 5X24X7XX with utility:50.0%<br>Day 10:|010010100101011100010011&gt; --&gt; 22453423 --&gt; 2X453XXX with utility:50.0%<br>Day 11:|000000111000101101100110&gt; --&gt; 00705546 --&gt; 0X7X5X46 with utility:62.5%<br>Day 12:|100010010001100000001101&gt; --&gt; 42214015 --&gt; 42X1X0X5 with utility:62.5%<br>Day 13:|110101100010111101111101&gt; --&gt; 65427575 --&gt; 65427XXX with utility:62.5%<br>Day 14:|011000001100011010011111&gt; --&gt; 30143237 --&gt; 3014X2X7 with utility:75.0%<br>Day 15:|111000010010110010011111&gt; --&gt; 70226237 --&gt; 702X6X3X with utility:62.5%</pre><p>Steps for the postprocessing of the bitstrings (<strong><em>** indices of labourer and restaurants are starting from 0</em></strong>),</p><ul><li>24-bit bitstrings to an array of 8 integers, each being represented by 3 bits, as described in the ‘<strong>Encoding</strong>’ section.</li><li>Take the outcome of day 5, ‘<strong>51636303’</strong>. We’ll interpret it as “<strong><em>5th labourer went to 0-th restaurant, 1st labourer went to 1st restaurant, 6th labourer went to 2nd restaurant, and so on…</em></strong>”.</li><li>While interpreting the outcome one can easily notice that ‘6’ appeared two times, on the 2nd and 4th position. That means the 6th labourer went to the 2nd and 4th restaurants on the same day. <strong>This is unrealistic and impossible.</strong></li><li>To handle the above discrepancy we’ve replaced any numbers appearing more than once with <strong><em>“</em>X<em>”</em></strong> starting from the left of the number array. This postprocessing convention turns the number array to “<strong>5163XX0X</strong>” and provides complete explainability with utility fraction calculation.</li><li>It interprets day 5 as only the 5 labourers (with labourer IDs 5,1,6,3 and 0) managed to get the food and 3 restaurants went out of customers resulting in (5/8)*100 = <strong>62.5%</strong> utilization of resources.</li></ul><pre>print(&quot;Quantum: The average occupancy or utility is {}% for {} labourers \\<br>       and {} Paise restaurants&quot;.format(np.array(utility).mean()*100,N,N))<br>plt.figure(figsize=(15,4))<br>plt.plot(np.array(utility)*100)<br>plt.ylabel(&quot;Daily Utility in %&quot;)<br>plt.xlabel(&quot;Number of days&quot;)<br>plt.axhline(y = np.array(utility).mean()*100, color = &#39;r&#39;, linestyle = &#39;-&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-98Sw8reulnNQrOAIcJ6A.png" /></figure><p>Once we plotted the utility for each of the days (each 100 samples from QPU samples) with the code snipped above,</p><blockquote><strong>we observed the expected utility fraction (from Quantum Circuit approach) stands at 65.75% (red line), which is quite close to the analytically (63%) and classically (64.625%) obtained value…… Pretty close! Isn’t it?….. Hooray!!!</strong></blockquote><h3>If you are still reading, then what’s the takeaway?…………..………… The Conclusion</h3><p>You must have observed how can we simply simulate a KPR game on a Quantum Computer and get considerable accuracy. Similarly, you can simulate other strategies as well. If you are interested in exploring other strategies to maximize the utility, do check out my research paper “<a href="https://link.springer.com/article/10.1007/s12648-024-03103-9"><strong><em>Achieving maximum utilization in optimal time for learning or convergence in the Kolkata Paise Restaurant problem</em></strong></a>”.</p><p>Before you get too tired reading this loo…oong blog, let’s discuss a few key takeaways. As you have been reading it all along, you might have noticed</p><ul><li>The encoding technique used here is a little different than that was mentioned in the “<a href="https://www.frontiersin.org/journals/artificial-intelligence/articles/10.3389/frai.2022.874061/full"><strong><em>Stochastic Learning in Kolkata Paise Restaurant Problem: Classical and Quantum Strategies</em></strong></a>”. This is because the authors of the mentioned paper considered a <strong>3-level (Qutrit)</strong> quantum system and we have used a <strong>2-level (Qubit)</strong> based quantum system.</li><li>Though we were able to simulate it on a local classical computer, it took 24 qubits to simulate an <strong><em>8-labourer-8-restaurant KPR. </em></strong>That<strong><em> </em></strong>means it is a <strong>qubit-hungry</strong> thing to play with.</li><li>This is ‘<strong>NOT’</strong> a piece of work that shows “<strong>Quantum Advantage</strong>”. But the way the “<strong><em>Number of measurement shots</em></strong>” used to simulate the “<strong><em>Number of days</em></strong>” really grabbed my attention while implementing it. As the IBM Quantum Computer offers up to 20000–100000, it can help you to simulate the KPR game for a long number of days <strong>just in a Snap</strong>!!!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*43hOJ5TGbe-cfAzp4jjaCg.png" /></figure><p>If you are still reading this then I’ll assume you have a deep interest in Quantum Computing and you want to explore the potential of it for different applications besides natural sciences. Here are a few suggestions where this blog may help you to add some further value,</p><ul><li>KPR is an example of <strong>Minority Game theory</strong> which connects applications like resource allocation, auction mechanisms, ride-hailing, market matching etc. Hence using QPU would really be useful or not in these areas that you may try to find out.</li><li>Another interesting domain is “<a href="https://philippevandenbroeck.medium.com/john-morecroft-strategic-modelling-and-business-dynamics-a-feedback-systems-approach-d811e4de1c63"><strong>Business Dynamics</strong></a>” simulation. These applications are not computationally hard but compute-intensive. You may think of exploring these as well with QC.</li><li>The Randomized KPR we simulated here was not having any learning mechanism (based on historical data) among the labourers. As there is big vast area of <strong><em>Variational Quantum Algorithms, </em></strong>how a quantum circuit can be tuned to induce a learning mechanism among the labourers can also be an area of interest leading to deep applications in <strong>Quantum Game Theory</strong>.</li><li>I feel the area of “<a href="https://medium.com/web-3-digitals/game-theory-and-mechanism-design-in-token-engineering-8a61730bbcd4"><strong>Mechanism Design</strong></a><strong>” </strong>would be able to harness quite a tangible benefit from this kind of simulation. Crucial business decisions like incentive design, product launch, budget designing, service/product pricing and marketing campaign design etc. possess deep thinking that is expected to stand resiliently in any adverse situations. Hence simulations become very important before stepping into the real world. If these real-world business problems excite you do give it a shot as well with it.</li></ul><p>Thanks for reading this article. For more articles, please follow me on Medium and <a href="https://www.linkedin.com/in/aniruddhadotconnect/">Linkedin</a> and don’t forget to check out these <a href="https://www.getbengal.com/details/kolkatas-pice-hotels"><strong><em>Paise restaurants</em></strong></a> if you are around Kolkata.</p><h4>References</h4><ul><li>Ghosh, A. <em>et al.</em> (2013). <em>Kolkata Paise Restaurant Problem: An Introduction</em>. In: Abergel, F., Chakrabarti, B., Chakraborti, A., Ghosh, A. (eds) <em>Econophysics of Systemic Risk and Network Dynamics.</em> New Economic Windows. Springer, Milano. <a href="https://doi.org/10.1007/978-88-470-2553-0_12">https://doi.org/10.1007/978-88-470-2553-0_12</a></li><li><strong><em>Biswas, Aniruddha, et al. “Achieving Maximum Utilization in Optimal Time for Learning or Convergence in the Kolkata Paise Restaurant Problem.” Indian Journal of Physics, vol. 98, no. 11, 15 Feb. 2024, pp. 3795–3801, </em></strong><a href="https://doi.org/10.1007/s12648-024-03103-9."><strong><em>https://doi.org/10.1007/s12648-024-03103-9.</em></strong></a><strong><em> Accessed 28 Sept. 2024.</em></strong></li><li>Chakrabarti, Bikas K., et al. “<em>Stochastic Learning in Kolkata Paise Restaurant Problem: Classical and Quantum Strategies.</em>” <em>Frontiers in Artificial Intelligence</em>, vol. 5, 26 May 2022, <a href="https://doi.org/10.3389/frai.2022.874061.">https://doi.org/10.3389/frai.2022.874061.</a> Accessed 20 Sept. 2022.</li><li>‌Sinha, Antika, and Bikas K. Chakrabarti. “<em>Phase Transition in the Kolkata Paise Restaurant Problem.</em>” <em>Chaos: An Interdisciplinary Journal of Nonlinear Science</em>, vol. 30, no. 8, Aug. 2020, p. 083116, arxiv.org/pdf/1905.13206.pdf, <a href="https://doi.org/10.1063/5.0004816.">https://doi.org/10.1063/5.0004816.</a> Accessed 20 Sept. 2022.‌</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59328ac1c13c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[QRNG: Generating Random Numbers from D-wave Quantum Annealers]]></title>
            <link>https://medium.com/@aniruddha.connect/qrng-generating-random-numbers-from-d-wave-quantum-annealers-fa618198fc14?source=rss-cde4bdb8ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa618198fc14</guid>
            <category><![CDATA[randomness]]></category>
            <category><![CDATA[d-wave-systems]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[quantum-annealing]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Aniruddha Biswas]]></dc:creator>
            <pubDate>Mon, 16 May 2022 15:21:45 GMT</pubDate>
            <atom:updated>2022-05-16T15:45:56.578Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*b8YjBkUmvXgqeNqy4NWTSA.png" /></figure><h4>Introduction</h4><p>Random numbers are such numbers which follow typically two essential conditions:</p><ul><li>These numbers are uniformly distributed over an interval or set.</li><li>Are pretty impossible to predict based on some past or present values.</li></ul><p>Random numbers are very very important in Computer science, Applied Mathematics, Physics, Chemistry and Biology. Which has created a lot of space for practical applications with random numbers. A few of them are,</p><ul><li>Scientific calculations for simulation of financial, weather or biological systems and complex sampling problems use random numbers.</li><li>In cryptography tasks like authentication, OTP verification and secure password construction require random numbers.</li></ul><h4>Why Quantum Random Number Generator?</h4><p>The random number generators we have currently are mostly based on some algorithms. Which does not guarantee true randomness, hence they are called Pseudo-Random Number Generators.</p><p>Due to the inherently probabilistic nature of quantum systems, true randomness can be easily observed in any of the quantum mechanical processes or events. And this is the only reason which is driving researchers to extract True Random Numbers by harnessing the power of quantum systems, a.k.a QRNG (Quantum Random Number Generator).</p><h4>Available QRNG Services</h4><p>A very common quantum circuit-based QRNG protocol is by using the Hadamard gate on a qubit at |0&gt; or |1&gt; state. An experimental linear optical hardware realisation is demonstrated here in the left image and an equivalent circuit representation is on the right-hand side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*LImAE6axBgE2MuGzTRTl0w.png" /><figcaption>Left Image: Linear Optical setup for QRNG service Right Image: Equivalent circuit for Circuit based QPUs</figcaption></figure><p>A Hadamard gate on |0&gt; state or |1&gt; state can produce equal superpositions of |0&gt; and |1&gt;, i.e |+&gt; and |-&gt;, and measuring the state can lead us to a pure random bit (0 or 1). A lot of quantum circuit-based QRNG services are available these days, which pretty much follow this same principle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*tpSg8fNtA8nEc51KESXL9Q.png" /><figcaption>Action of Hadamard gate on qubits</figcaption></figure><p>Some of the available Quantum Random Number Generators are,</p><ul><li>ANU QRNG Service: This product is available in the AWS Marketplace (<a href="https://aws.amazon.com/marketplace/pp/prodview-246kyrfjo3bag">https://aws.amazon.com/marketplace/pp/prodview-246kyrfjo3bag</a>) homepage link: <a href="https://qrng.anu.edu.au/">https://qrng.anu.edu.au/</a>.</li><li>IBM Qiskit QRNG Service (with CQC extractor): <a href="https://qiskit.org/documentation/stable/0.24/apidoc/ibmq_random.html">https://qiskit.org/documentation/stable/0.24/apidoc/ibmq_random.html</a></li><li><a href="http://qrng.physik.hu-berlin.de/download">http://qrng.physik.hu-berlin.de/download</a></li><li>One can easily create their own QRNG service using any of the available quantum computing frameworks like IBM Qiskit, Google Cirq, Microsoft Q#, Rigetti PyQuil etc. Follow: <a href="https://shadab-hussain.medium.com/quantum-random-number-generators-qrngs-using-streamlit-7ca8f043b4c3">https://shadab-hussain.medium.com/quantum-random-number-generators-qrngs-using-streamlit-7ca8f043b4c3</a></li></ul><h3>QRNG on D-wave Quantum Annealer</h3><p>The working principle of D-wave annealing systems is pretty unique. They start with a hamiltonian H1 (whose ground state can be prepared easily). D-wave considers H1 as the initial hamiltonian and the target hamiltonian (H2) is the Ising type. The problem hamiltonian is encoded into H2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*CXvItXUHceSTsGPevgEceA.png" /></figure><p>To know more about how D-wave annealers work please refer to this video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtnikftltqE0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtnikftltqE0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FtnikftltqE0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e57e4fc7f2fc2937562b1db419032e5/href">https://medium.com/media/8e57e4fc7f2fc2937562b1db419032e5/href</a></iframe><p>In gate based circuit model quantum computers, we have seen the application of the Hadamard gate on the |0&gt; or |1&gt; state produces a superposition state and measurement on this equal superposition state (|+&gt; or |-&gt;) produces a random bit. Now if we look back into the quantum information theory we will see that,</p><blockquote>Application of Hadamard gate on |0&gt; or |1&gt; and Hamiltonian evolution from Pauli Z to Pauli X are equivalent as both these operations change the basis from Computational basis to Diagonal basis. A schematic representation can be,</blockquote><blockquote>* |0&gt;/|1&gt; — —— — Hadamard Gate — — — — — |+&gt;/|-&gt;</blockquote><blockquote>* Pauli Z Basis — —— Hadamard Gate— — — — —Pauli X Basis</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*tSDbcCDHCAgETFR26LT26w.gif" /><figcaption>Source: <a href="https://lewisla.gitbook.io/learning-quantum/quantum-circuits/single-qubit-gates">https://lewisla.gitbook.io/learning-quantum/quantum-circuits/single-qubit-gates</a></figcaption></figure><p>In gate based QPUs, we start with the Computational basis (|0&gt; or |1&gt;), hence we need the Hadamard gate to change the basis to the Diagonal basis or Pauli X basis (|+&gt; or |-&gt;) to produce a random bit.</p><blockquote>As D-wave annealers start from H1 (which is the superposition of Pauli X), we can restrict its evolution to H2 and get the random bits by doing the measurements.</blockquote><h4>Experiment with Single D-wave Annealing Qubit</h4><p>To compare our mentioned technique’s equivalency with the action of the Hadamard gate, we tested it on 1 D-wave’s annealing based qubit with 1000 measurement shots. The result we obtained is pretty close to the gate based circuit&#39;s Hadamard probability distribution. This primarily validates our protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*-5G8qow5_omeL-XHMl3CNw.png" /><figcaption>Hadamard equivalency test for 1 D-wave Annealing qubit</figcaption></figure><h4>How to get the random numbers?</h4><p>Let us consider the length of our random bit array is 10. To perform this experiment we will be using D-wave Ocean (a Python-based SDK for Quantum Computing).</p><blockquote>As D-wave inherently take care of the H1, we have to only think about H2, which is an Ising Hamiltonian. As we want to STOP the evolution from H1 to H2, hence we will take the H2 be a 10x10 QUBO matrix having all the terms are zeros. Taking H2 a QUBO matrix of all zeros will help our annealing system to remain under H1 (Pauli X) hamiltonian for longer duration and performing measurement will ensure the randomness of the bits.</blockquote><p>Here we are using open-source libraries named D-wave Ocean, Dimod, Numpy and Pandas with IBM Qiskit’s visualization</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/408aac25f4db3e1de288692f831d3082/href">https://medium.com/media/408aac25f4db3e1de288692f831d3082/href</a></iframe><p>We want to generate 10 different random numbers (each having a 10-bit length) for that we are considering H2 to be a 10x10 square matrix (QUBO) with all elements being zero. Finally sending the quantum job to the D’wave Quantum processor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad7db3851dd32e61f0cef2787326e84c/href">https://medium.com/media/ad7db3851dd32e61f0cef2787326e84c/href</a></iframe><p>After receiving outputs from D-wave Annealing device, a minor post-processing should be done to arrange the output in Pandas dataframe. The random numbers have also been extracted from the bitstrings and added to a Dataframe column named “Numbers”.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30e8d3fc88bc337626f4e9626cb0096e/href">https://medium.com/media/30e8d3fc88bc337626f4e9626cb0096e/href</a></iframe><h4>Experimental Results and Observations</h4><p>Here is the output of the complete experiment and we got 10 random numbers, which are 118,664,108,662,,56,233,534,346,562 and 775. The figure on the right-hand side also shows the probability distribution and that looks uniform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*nHJ0zkB8ghL7THUuOPzX7A.png" /></figure><p>We got few non-uniform distributions for a higher number (shots=1000 or more) of sampling under a lower number (n=4 to 7) of qubits. But for very large size bitstrings (10&lt;n&lt;20) we got pretty uniform distributions for smaller/larger sampling rates.</p><h4>Conclusions</h4><p>Though the above-mentioned protocol is able to produce random numbers from D-wave annealing devices but the True Randomness of the outputs has not been verified with any randomness test suite available in the market.</p><blockquote>If you are thinking of starting a TQRNG service based on this protocol, perform ‘NIST Randomness Test’ before proceding.</blockquote><p>Thanks for reading this article. For more articles, please follow me on Medium and Linkedin.</p><h4>References</h4><ul><li><a href="https://aws.amazon.com/blogs/quantum-computing/generating-quantum-randomness-with-amazon-braket/">https://aws.amazon.com/blogs/quantum-computing/generating-quantum-randomness-with-amazon-braket/</a></li><li><a href="https://journals.aps.org/rmp/abstract/10.1103/RevModPhys.89.015004">https://journals.aps.org/rmp/abstract/10.1103/RevModPhys.89.015004</a></li><li><a href="https://shadab-hussain.medium.com/quantum-random-number-generators-qrngs-using-streamlit-7ca8f043b4c3">https://shadab-hussain.medium.com/quantum-random-number-generators-qrngs-using-streamlit-7ca8f043b4c3</a></li><li><a href="https://arxiv.org/abs/2001.10625">https://arxiv.org/abs/2001.10625</a></li><li><a href="https://quantumcomputinguk.org/tutorials/16-qubit-random-number-generator">https://quantumcomputinguk.org/tutorials/16-qubit-random-number-generator</a></li><li><a href="https://www.sciencedirect.com/science/article/pii/S1319157822000283">https://www.sciencedirect.com/science/article/pii/S1319157822000283</a></li><li><a href="https://qiskit.org/documentation/stable/0.24/apidoc/ibmq_random.html">https://qiskit.org/documentation/stable/0.24/apidoc/ibmq_random.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa618198fc14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving Quantum Annealing based Problems with Gate Model Processors]]></title>
            <link>https://medium.com/@aniruddha.connect/solving-quantum-annealing-based-problems-with-gate-model-processors-92b2f6f2772f?source=rss-cde4bdb8ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/92b2f6f2772f</guid>
            <category><![CDATA[quantum-annealing]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[optimisation]]></category>
            <category><![CDATA[quantum-computer]]></category>
            <category><![CDATA[d-wave]]></category>
            <dc:creator><![CDATA[Aniruddha Biswas]]></dc:creator>
            <pubDate>Tue, 26 Oct 2021 17:32:16 GMT</pubDate>
            <atom:updated>2021-10-26T17:32:16.718Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CK0qknmP0SV4ma9EoPpB9Q.png" /></figure><p>In December 2020 D-wave systems officially launched a software tool named “<a href="https://github.com/dwavesystems/dwave-qiskit-plugin"><strong><em>dwave-qiskit-plugin</em></strong></a>”, using which one could send large scale Quantum Circuit-based Combinatorial Optimisation problems to D-wave quantum processors using IBM Qiskit and get the solutions without installing D-wave dependencies exclusively. This small project was really helpful for quantum computing developers. But since last year I was getting questions like “Can we do the reverse?”, “Can we throw annealing problems to gate model processors?”, ”Is it possible to solve annealing problems with gate model QPUs?”. So finally, thought of writing an article on this.</p><p>In this blog, we will learn how can we translate Quantum Annealing problems(combinatorial optimisation problem) to gate model quantum processors. For example, firstly we have formulated a random problem for Quantum Annealer, then we will convert it into a gate model native format using the IBM Qiskit optimisation module.</p><h3><strong><em>Ising Model and QUBO</em></strong></h3><p>A Combinatorial Optimisation problem can be given input as Ising hamiltonian format or QUBO (Quadratic Unconstrained Binary Optimisation) matrix format in an exchangeable way in a Quantum Annealer. Ising hamiltonian mimics general interaction between magnets.</p><p>Here Sᵢ are spins, hᵢ is bias term and Jᵢⱼ is the interaction between spins. Each spin Sᵢ can take only two values {-1, +1}. This Ising hamiltonian can also be converted in QUBO, which is a typical square symmetric matrix with real numbers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*n3FhgncUHFKlenMkGgkF6Q.png" /><figcaption>Basic Ising-QUBO Relations</figcaption></figure><p>Here Q is the QUBO matrix and X is a boolean vector. Where Xᵢ is either 0 or 1. This Ising hamiltonian and QUBO can be converted into one another using the right bottom relation. All the details about the Ising model and QUBO are beyond the scope of this article. Please visit <a href="http://dwavesys.com/">dwavesys.com</a> for more information.</p><h3>Concepts of Quantum Annealing, QAOA &amp; VQE</h3><p>A lot of things can be discussed about these 3 topics which will unnecessarily make this article longer. So I have given a few good resources which will redirect to these topics. Please follow the hyperlinks below.</p><ul><li><a href="https://medium.com/@quantum_wa/quantum-annealing-cdb129e96601"><strong><em>Quantum Annealing</em></strong></a></li><li><a href="https://www.mustythoughts.com/quantum-approximate-optimization-algorithm-explained"><strong><em>Quantum Approximate Optimisation Algorithm (QAOA)</em></strong></a></li><li><a href="https://www.mustythoughts.com/variational-quantum-eigensolver-explained"><strong><em>Variational Quantum Eigensolver (VQE)</em></strong></a></li></ul><h3>Technical Strategy</h3><p>So the strategy will be, we will start with a random QUBO and solve it with any of the D-wave solvers. Then we will convert the QUBO into Qiskit native Quadratic program using the “Qiskit-Optimization” module. Once the conversion is done we will first solve that Quadratic Program (Ising Model) using QAOA and then with VQE. Finally, we will conclude with a comparison between the solutions.</p><h4><strong><em>Defining Random QUBO Matrix</em></strong></h4><p>The first important step is to import the necessary libraries. Here we are taking a free variable “n” which is helping us to create the random QUBO matrix. One can take a large QUBO to compare the solutions between different stacks. But for simplicity, we will take n=4. So, the code for random QUBO generation is given below,</p><pre>import numpy as np<br>import dimod</pre><pre>from qiskit import Aer<br>from qiskit_optimization import QuadraticProgram<br>from qiskit.algorithms import QAOA, VQE<br>from qiskit.circuit.library import TwoLocal<br>from qiskit.algorithms.optimizers import COBYLA<br>from qiskit.visualization import plot_histogram<br>from qiskit.optimization.applications.ising.common import sample_most_likely</pre><pre>np.random.seed(123)</pre><pre>############  Geneating Random QUBO Matrix  ###################### <br>n = 4 <br>M = np.random.uniform(-2,2,(n,n)) <br>QUBO = M + M.T <br>print(&quot;Random QUBO matrix is:&quot;,QUBO)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*dBydjjQwW8AV85vLWUIfGQ.png" /></figure><h4><strong><em>Solving with Annealer</em></strong></h4><p>Now we got our QUBO, which is basically a square symmetric matrix and we will try to solve it with D-wave solvers. D-wave has several Classical, Quantum and Hybrid solvers which are available through Ocean SDK. But here we will be using a Simulated Annealing solver for our problem.</p><p>First, we will take the QUBO matrix (NumPy array) and convert it to a “Binary Quadratic Model (BQM)”, which is native to D-wave. Then we will send the code to a classical solver (SimulatedAnnealeingSampler). The code looks like,</p><pre>############  Solving with Dwave Simulated Annealing  #############</pre><pre>bqm = dimod.BinaryQuadraticModel.from_numpy_matrix(QUBO)     sampleset = dimod.SimulatedAnnealingSampler().sample(bqm,<br>                                                     num_reads=1000)</pre><pre>print(sampleset.aggregate())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*a9WatvsLIQZ88opIBaYIPw.png" /><figcaption>Samples from D-wave Simulated Annealing</figcaption></figure><p>Finally, we got our answer and we can see the best possible solution is X = [1,0,1,0] with a minimum energy value.</p><p>In the upcoming section, we will convert the QUBO to a Qiskit native Quadratic program.</p><h4>Converting to Quadratic Program</h4><p>For any QUBO the diagonal terms are linear in nature and all the other terms are quadratic. First, we will separate the linear and quadratic terms and then create a QuadraticProgram() model. A Quadratic Program can be converted into Ising hamiltonian (using <em>to_ising()</em> method) and one can construct an equivalent Quantum circuit out of it, which can be fed to both QAOA and VQE.</p><blockquote><strong>to_ising()</strong> method also returns an “<strong>offset</strong>” value which is nothing but a constant.</blockquote><pre>################  QUBO to Ising Model Converter   ################</pre><pre>def qubo2ising(QUBO):     <br>    temp = np.copy(QUBO)     <br>    linear = np.diag(QUBO).tolist()     <br>    np.fill_diagonal(temp,0)     <br>    quadratic = temp.tolist()     <br>    best_sample = None       <br>    model = QuadraticProgram()     <br>    for i in range(QUBO.shape[0]):         <br>        model.binary_var(&#39;x&#39;+str(i))   <br>   <br>    model.minimize(linear=linear, quadratic=quadratic)<br>    print(model.export_as_lp_string())     <br>    operators , offset = model.to_ising()  <br>   <br>    print(&quot;Equivalent circuit:&quot;,operators,&quot;Offset:&quot;,offset)     <br>    return operators, offset</pre><pre>operators, offset = qubo2ising(QUBO)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*k31aAk1-oDC6laky0tfPKQ.png" /><figcaption>DoCPLEX Quadratic Program of QUBO Matrix</figcaption></figure><h4>Solving with QAOA</h4><p>Once our problem Hamiltonian (Hₚ) is ready we can send that as a circuit in the QAOA algorithm. As QAOA is a hybrid algorithm and it requires a classical optimiser, so we will be using COBYLA here with “<em>statevector_simulator</em>”. For this particular case, we have used 5 repetitions of Mixer Hamiltonian (Hₘ) and Hₚ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*OSo2Q6RMdfhrr-xw7CxjcQ.png" /><figcaption>Problem Hamiltonian (Hₚ) for QAOA/VQE</figcaption></figure><p>One can use a lesser or higher number of repetitions of Hₘ and Hₚ layers. The code below takes the built-in QAOA algorithm from Qiskit and finds the minimum eigenvalue and its corresponding Eigen-state using a classical optimiser. (One can also write a custom code for QAOA)</p><pre>########################  Running QAOA   #####################  <br>opt = COBYLA() <br>backend = Aer.get_backend(&#39;statevector_simulator&#39;)    </pre><pre><br>qaoa = QAOA(optimizer = opt, quantum_instance = backend, reps = 5) result = qaoa.compute_minimum_eigenvalue(operators)  </pre><pre><br>print(&#39;Most likely sample:&#39;,sample_most_likely(result.eigenstate))</pre><p>The optimal Eigen-state found by QAOA is [1,0,1,0] (Keeping the very little repetition may lead to sub-optimal solutions).</p><h4>Solving with VQE</h4><p>Here we are solving it with the VQE algorithm. Like QAOA it also requires a classical optimiser and we are also using COBYLA with “<em>statevector_simulator</em>”. The code is written below imports built-in VQE from Qiskit and finds the minimum Eigenvalue of the problem Hamiltonian with the ground state wave-function.</p><pre>########################  Running VQE   #########################  </pre><pre>opt = COBYLA() <br>backend = Aer.get_backend(&#39;statevector_simulator&#39;) </pre><pre><br>ansatz = TwoLocal(operators.num_qubits,&#39;ry&#39;,&#39;cz&#39;,      reps=5,entanglement=&#39;linear&#39;)  </pre><pre><br>vqe = VQE(ansatz, optimizer = opt, quantum_instance=backend) <br>result = vqe.compute_minimum_eigenvalue(operators)  </pre><pre><br>print(&#39;Most likely sample:&#39;,sample_most_likely(result.eigenstate))</pre><p>The choice of ANSATZ is very crucial as it mostly affects the optimisation process and helps to find the solution in minimal time. Here we are using “TwoLocal” Ansatz (consists of Controlled-Z and Rz(θ) gates) with 5 repetitions. The Ansatz looks like,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*APaIUDiFs6PceMVxHLXjTA.png" /><figcaption>Two Local Ansatz (Ry, CZ) with 5 Repetitions</figcaption></figure><p>The Eigen-state corresponding to the minimum Eigen-value is [1,0,1,0], same as QAOA and SA.</p><h4>Results and Conclusion</h4><p>The result we got from different approaches are all same [1,0,1,0] and it is compatible with brute force solution as well. Later we also executed optimal QAOA and VQE circuits with “<em>qasm_simulator</em>” and plotted the probability distribution of the 3 approaches mentioned above, which pretty much indicates the validity and correctness of the technical approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*9r2Wa5R_YX7Nhmd8_DLRGw.png" /><figcaption>Left: Probability distribution of QAOA, VQE, SA………………………………. Right: Brute Force Solution</figcaption></figure><p>In the above article, we tried to develop a complete approach using which one can send Annealing problems to Gate-model QPUs. For that thing, we started with a D-wave native QUBO problem, then converted it to an Ising Hamiltonian using a Quadratic program and finally solved it with QAOA and VQE.</p><p>Following the same approach, one can submit Annealing problems to not only IBMQ devices using Qiskit, but also to Sycamore (using Cirq), IonQ (using AWS BraKet, Microsoft Q#, tket, Qiskit, Pennylane), Rigetti (PyQuil, Pennylane, BraKet) or Honeywell devices. A good direction can be developing an open-source project like “<strong><em>dwave-qiskit-plugin</em></strong>” (for reverse purpose) for Pennylane, Cirq or Rigetti frameworks.</p><p><strong><em>Thanks for reading. Please comment and share. For any queries and suggestions please reach out to me (aniruddha.connect@gmail.com).</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92b2f6f2772f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finding the Smallest Number of an Array with Quantum Computer]]></title>
            <link>https://medium.com/@aniruddha.connect/finding-smallest-number-of-an-array-with-quantum-computer-824386348fe0?source=rss-cde4bdb8ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/824386348fe0</guid>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[quantum-computer]]></category>
            <dc:creator><![CDATA[Aniruddha Biswas]]></dc:creator>
            <pubDate>Fri, 03 Sep 2021 06:09:19 GMT</pubDate>
            <atom:updated>2021-09-03T07:38:42.480Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iujoSkRCOR6t44KX" /><figcaption>Photo by <a href="https://unsplash.com/@nhillier?utm_source=medium&amp;utm_medium=referral">Nick Hillier</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>One of the fundamental problems of Computer Science algorithms is to find the smallest or largest number (Real) from an array of different elements. There are a lot of classical approaches which are available these days and also provides enormous power to sorting methods (like merge sort, bubble sort, quick sort etc). Now the question is, can we solve the same problem with a Quantum computer available these days. Our aim here is to provide a solution to the problem of finding the smallest or largest number from an array of real numbers. In this article, we’ll try to formulate the problem suitable for a quantum processing unit, then discuss the implementation on a real quantum processor and then finally discuss the results and conclusions.</p><p>The complete article is structured like this -<br>* Problem definition<br>* Ising model<br>* Quantum formulation of the problem<br>* Algorithm description<br>* Experiment<br>* Result &amp; Analysis<br>* Conclusions</p><h3>Problem Definition</h3><p>Let us assume we have an array of 3 real numbers. i.e <em>N = [17,3,49]</em>. Now we can easily say that the 2nd element of the array is the smallest number we have in the array, and that is 3. Now we’ll take another bit string (bit array) X of the same length. The mapping will be like,</p><blockquote><em>N = [</em><strong><em>17</em></strong><em>,3,49] — — — — — — — — — — — — — - — → X₀ = [1,0,0]</em></blockquote><blockquote><em>N = [17,</em><strong><em>3</em></strong><em>,49] — — — — — — — — — — —— — — - → </em><strong><em>X₁ = [0,1,0]</em></strong></blockquote><blockquote><em>N = [17,3,</em><strong><em>49</em></strong><em>] — — — — — — — — — — —— — — - → X₂ = [0,0,1]</em></blockquote><p>Here <em>2³=8</em> bit-strings are possible for a 3-bit array and only 3 arrays map the elements of N to 3 distinct numbers. Here the bit-array X₁ will be our required answer, as it maps to the 2nd element of N, which is 3 and it’s the smallest among others numbers present in the array N.</p><blockquote>Other bits arrays like <em>[1,1,0], [1,1,1], [0,1,1], [1,0,1] </em>and<em> [0,0,0]</em> are of no direct importance as they do not map to any distinct number of our primary array N.</blockquote><p>So now we know, if we have an array of “n” elements and we are interested in finding the smallest element of the array, then we will try to find the best bit-string or bit-array <em>Xᵢ</em> among <em>2ⁿ</em> possible bit-arrays (without bothering about <em>(2ⁿ-n)</em> bit-arrays), which maps itself to any distinct element of the “n” elements.</p><h3><em>Quantum Formulation of the Problem</em></h3><p>Here we will try to reformulate the problem in the form of a Combinatorial Optimisation problem. We know that quantum computers are good at solving combinatorial optimisation problems, and we can solve this with Quantum Approximate Optimisation Algorithm (<a href="https://www.mustythoughts.com/quantum-approximate-optimization-algorithm-explained">QAOA</a>), Variational Quantum Eigensolver (<a href="https://www.mustythoughts.com/variational-quantum-eigensolver-explained">VQE</a>) or <a href="https://docs.dwavesys.com/docs/latest/c_gs_2.html">Quantum annealing</a>. To convert our problem of interest into a combinatorial optimisation problem we have to write the hamiltonian in the form of Ising type. (<em>For more details on</em> the <em>Ising model </em><a href="https://en.wikipedia.org/wiki/Ising_model"><em>click here</em></a>)</p><p><strong><em>The Ising Model<br></em></strong>Ising model is a classical model of magnetism given by Lenz in the year 1920, and later in 1925, it was solved by Ernst Ising (1-dimensional problem). This mathematical model incorporates the nearest neighbour interaction between atomic spin variables (sᵢ ∈ [-1,+1]). The general form of Ising hamiltonian is,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*eyfNzUf1sOPvGMsiLKPARw.png" /><figcaption>Figure 1: The general form of Ising hamiltonian</figcaption></figure><p>where hᵢ is the bias and Jᵢⱼ is the coupling strength. The sᵢ and sⱼ are the interacting spin variables in the material. This hamiltonian can be converted into a square symmetric matrix called QUBO (<a href="https://support.dwavesys.com/hc/en-us/community/posts/360017439853-Difference-between-BQM-Ising-and-QUBO-problems-">Quadratic Unconstriant Optimisation problem</a>). The QUBO objective looks like this,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*JxjLIMWgGkfbbZvJMSZ-RA.png" /><figcaption>Figure 2: The general form of QUBO</figcaption></figure><p>where xᵢ ∈ X is a binary variable having a value of either 0 or 1 and Q is the QUBO matrix. Although QUBOs are native to Annealing machines but one can interchangeably use QUBO or Ising model just by replacing <strong><em>xᵢ=(sᵢ+1)/2</em></strong>.</p><p><strong><em>The Objective Function<br></em></strong>Assume we have an array of 3 real numbers (we could have taken a large array of real numbers. But for the sake of simplicity we’ll restrict ourselves to 3 only), <em>N=[n₀,n₁,n₂]</em> and a corresponding boolean bit array <em>X=[x₀,x₁,x₂]</em>. We can define a function <em>f(N,X)</em>,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*1gVIeR4dlzb50MOGWBfD-Q.png" /><figcaption>Figure 3</figcaption></figure><p>If the element nᵢ is the smallest element, then <em>f(N,X)</em> will have the minimum value for a specific Xᵢ. Hence, a quadratic cost hamiltonian can be written as,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*nJxIV8OMxXGR40JExbL9Zg.png" /><figcaption>Figure 4</figcaption></figure><p>As one of the numbers in the array (N) will always be minimum, the sum of all the bits in a valid Xᵢ will always be equals to unity. This helps us to write our constraint (xᵢ ∈ X),</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*CvxOG_FIPi3E83nZ76cKQg.png" /></figure><p>Hence we can construct a penalty function <em>P(X)</em> just squaring up the above equation and simplifying it with <em>xᵢ²=xᵢ</em>,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*zK--1CgxxDwBzAVLb_6Zrw.png" /><figcaption>Figure 5: Penalty function for the constraint</figcaption></figure><p>We can add <em>H(N, X)</em> and <em>P(X)</em> with a scaling factor λ and obtain a global cost function <em>Q(N, X)</em>. Where λ will be the square of the sum of all the elements in the sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*_flWkBqb4jahrbyK4FZeMQ.png" /><figcaption>Figure 6: Complete Objective Function</figcaption></figure><p>The above <em>Q(N, X)</em> is our final <strong><em>Quadratic objective function </em></strong>or<strong><em> QUBO</em></strong>, which is solvable by Gate based quantum computer or quantum annealer.</p><h3><em>Algorithm Description</em></h3><p>Although the algorithmic approach is versatile enough to solve minimisation and maximisation problems interchangeably by putting a negation in the global hamiltonian,</p><blockquote>To find the largest element of an array use -H(N,X)</blockquote><p>If there are any negative numbers as well as positive numbers then some classical preprocessing techniques will be required. There is no requirement for preprocessing if the elements of the sequence are all positive or all negative.</p><p>The classical preprocessing steps follow,<br>1. Sum up the absolute of all the elements in the sequence, <em>Sum=∑ᵢ|nᵢ|</em><br>2. Now, add this Sum with every element of the sequence irrespective of signs and values. These new numbers <em>nᵢ</em> will be taken as the input of the actual algorithm as they are all positive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*rMTnZTmjzNCWEMeKj0s-9w.png" /></figure><p>This scaling method is essential when there are both positive and negative numbers are present in the sequence. The whole steps of the algorithm are distributed into some CPU and QPU. Encoding of the problem into QPU specific tasks and the result extraction process is entirely classical, where the main solution part is quantum and it is sandwiched between classical processes.</p><p>Still, a high-level pseudocode approach can be expressed as,<br>1. Preprocess the inputs using the above equation, if required.<br>2. Construct the cost hamiltonian Q<em>(N, X)</em> using all the input elements.<br>3. Find the best X using Quantum Computer.<br>4. Extract the smallest number using <em>f(N,Xᵢ)</em>.</p><h3>Experiment</h3><p>Let us do an experiment. As we have mentioned already, our problem of interest is <em>N = [17,3,49]</em>. So, our <em>Q(N, X)</em> or <em>QUBO</em> matrix will be,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*4760psYtrMDlEAgZfOk8_w.png" /><figcaption>Figure 7: Left: Circuit from QUBO, Center: Problem QUBO, Right: The Graph on the right side is for an array of 10 elements (NOT FOR THE PROBLEM OF 3 ELEMENTS IN THE ARRAY MENTIONED ABOVE)</figcaption></figure><p>Here the QUBO for this problem will be an <em>N</em> node complete graph. As we know already that a combinatorial optimisation problem can be solved on both Quantum Annealer and Gate model Quantum computer. QUBO is native to Quantum Annealer, but to solve this problem on a Gate based QPU (IBM, Rigetti etc) we need to convert this as a Quadratic program. Then we will be able to solve it via <strong><em>QAOA</em></strong> or <strong><em>VQE</em></strong>. As we are using IBM Qiskit so we have constructed a <strong><em>Quadratic Program (doCPLEX)</em></strong> using the “<strong><em>qiskit.optimisation</em></strong>” module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*Fos4NbnEaCRqhQLMxS3lNw.png" /><figcaption>Figure 8: DoCPLEX Quadratic program for above QUBO</figcaption></figure><p>Again this Quadratic program can be decomposed into equivalent Hamiltonian consisting of <strong><em>Pauli-Z</em></strong> and <strong><em>Identity</em></strong> gates (Figure 7: Left). This program has been solved with <strong><em>QAOA (reps = 2)</em></strong> and <strong><em>VQE (Two_Local ansatz)</em></strong> with <strong><em>1000 shots</em></strong> using IBM Qiskit on the local machine.</p><h3>Results &amp; Analysis</h3><p>The problem here was solved using both Quantum Annealers and Gate-model Quantum Computer. For the Annealing model, we have used both classical simulated annealing and Quantum Annealing. And for Gate-model, the results of QAOA and VQE has been shown. We can see easily the best result by all 4 approaches is <strong><em>[0,1,0]</em></strong>, which basically corresponds to the 2nd element of the array N, i.e 3. One can also evaluate <em>f(N,X)</em> for best X to find the smallest number in the array. Although we can see the quality of the VQE result is much better than any other solution, but we can improve others by tuning few parameters as well. One can also use Path-Integral Monte-Carlo based Simulated Quantum Annealing (SQA) or D-wave’s Leap Hybrid Sampler for large size problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*kzadEqFi2R-ILxd1iy00mg.png" /><figcaption>Figure 9: Results from IBM simulators (QAOA, VQE) and D-wave Simulated Annealing and Quantum Annealing</figcaption></figure><h3>Conclusion</h3><p>The work articulated here gives an approach of finding the smallest (or largest) number of an array using a quantum computer by mapping the actual problem into an optimisation problem. As finding the smallest or largest number of an array does not belong to NP problems, we do not expect any complete quantum advantage over the state of art classical search algorithms, which are extremely faster in this context. Fine-tuning of hardware parameters may significantly uplift the performance, which can be a good direction for further research on this problem. Our method is suitable for any small or large amount size array, but due to limitations in the number of available qubits and their connectivity on real hardware, only a limited number of inputs can be given at once. However, the number of qubits in QPUs is growing year by year in a significant amount, which will help our approach to tackle larger arrays at once.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=824386348fe0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>