Skip to content

Commit

Permalink
Merge pull request #133 from eclipse-qrisp/tutorial_bugfix_for06
Browse files Browse the repository at this point in the history
Tutorial bugfix for06
  • Loading branch information
positr0nium authored Feb 5, 2025
2 parents aa3fcc0 + 2660414 commit fed0eb4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 23 additions & 12 deletions documentation/source/general/thinq_qrisp/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Quantum computers are associated with the hope of achieving enormous leaps in co

This will change with the Thinq Qrisp Community!
''''''''''''''''''''''''''''''''''''''''''''''''
The offical Thinq-Qrisp website [REF]

The community will offer a platform where developers can work on new ideas for programming quantum computers. Newly developed technologies will be quickly integrated into the open-source project Qrisp. The Thinq Qrisp Community is the central meeting place for all those who want to engage in quantum and pull it from the realm of abstract science into application oriented software development. For this we want to bundle and network the activities of the quantum software engineering community.

Expand Down Expand Up @@ -71,26 +72,36 @@ Joining our community offers numerous advantages, including access to exclusive
How to join?
''''''''''''

The community will start with the Kick-Off event:
.. figure:: Quantum-Computer_Berlin_Ai-generated_korr.jpg
:width: 325
:align: right
:class: image-class-value
:figclass: figure-class-value

.. grid::

.. grid-item-card:: Thinq Qrisp Kick-Off
**To join the community you can get in touch with us!**

.. dropdown:: :fa:`eye me-1` Event Details
We will launch exclusive membership access to the Thinq Qrisp Community starting April 1st.
To ensure the sustainability of the community, we will implement a participant model tied to a minimal annual participation fee.

If you have any questions, don't hestiate to reach out!
We are happy to answer any question regarding the community's services, sign-up form and contract!

Send us an E-Mail under **[email protected]**.

Or contact our team member and developer Sebastian under **[email protected]**.

| **Date:** 10. September 2024.
| **Location:** Fraunhofer FOKUS (Kaiserin-Augusta-Allee 31, 10589 Berlin).
| **How?** Registration will be opened soon.
Planned activities
''''''''''''''''''

Prior to the launch event you will have the chance to exchange with us to learn more details about our plans and how you can benefit from a membership. For that, we welcome you to our initial Webinar:
On the 12th of Febuary we will have a new free webinar, which will revolve around the integration of `JAX <https://jax.readthedocs.io/en/latest/quickstart.html>`_ in Qrisp. We will introduce you to our high-performance module **Jasp**, which leaverages the compilation speed-ups of JAX.

.. grid::

.. grid-item-card:: Initial Webinar
.. grid-item-card:: Jasp: the Jax integration in Qrisp,

.. dropdown:: :fa:`eye me-1` Event Details

| **Date:** 5. August 2024, 10:30.
| **Location:** Online.
| **How?** Please register `here <https://www.fokus.fraunhofer.de/en/akademie/schulungen/qrisp-quantum-programming-language>`_.
| **Date:** 12. Febuary 2025.
| **Location:** Microsoft Teams.
| **How?** `Registrate here <https://www.thinq-qrisp.eu/en/news/fokus/sqc/jasp_webinar>`_
10 changes: 6 additions & 4 deletions documentation/source/general/tutorial/QIROtutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ As you might have noticed in the code above, we add the nodes that are included
This allows us to directly use the same ideas for the ``cost_operator``, ``mixer`` and ``init_function`` of the original unconstrained QAOA theory with minor adjustments.

Since we have to consider nodes that are already asigned to be in the solution set, or exluded from the algorithm, we do not want to apply ``cost_operator`` or ``mixer`` to said nodes.
We therefore include some simple lines of code into the functions to take this into account, for example the ``if not``-statement in the ``qiro_RXMixer``:
We therefore include some simple lines of code into the functions to take this into account, for example the ``if not``-statement in the ``qiro_rx_mixer``:

::

def qiro_RXMixer(solutions = [], exclusions = []):
def qiro_rx_mixer(solutions = [], exclusions = []):
union = solutions + exclusions
def RX_mixer(qv, beta):
for i in range(len(qv)):
Expand Down Expand Up @@ -236,7 +236,7 @@ With this, we can directly throw everything that is relevant at the :ref:`QIROPr
qiro_instance = QIROProblem(G,
replacement_routine=create_max_indep_replacement_routine,
cost_operator=create_max_indep_cost_operator_reduced,
mixer=qiro_RXMixer,
mixer=qiro_rx_mixer,
cl_cost_function=create_max_indep_set_cl_cost_function,
init_function=qiro_init_function
)
Expand Down Expand Up @@ -288,12 +288,14 @@ As a final caveat, we can look at the graph we are left with after all reduction
Constrained mixer implementation
--------------------------------

Before we end this tutorial we want to show you what the constrained mixer implementation looks like for the MIS QIRO algorithm. In analogy to our :ref:` general QAOA implementation for the MIS problem <maxIndepSetQAOA>`
Before we end this tutorial we want to show you what the constrained mixer implementation looks like for the MIS QIRO algorithm. In analogy to our :ref:`general QAOA implementation for the MIS problem <maxIndepSetQAOA>`
we use the :ref:`qiro_rz_mixer <QIRO>` as the mixer and the :ref:`create_max_indep_controlled_mixer_reduced <maxIndependentSetQIRO>` as the cost operator. In principle, these functions do the exact same thing as the general implementations,
but they respect the solutions and exclusions chosen via the update routine. We suggest to try this instance with larger graph sizes (more than 20 nodes).

::

from qrisp.algorithms.qiro import qiro_rz_mixer, create_max_indep_controlled_mixer_reduced, qiro_max_indep_set_init_function

# assign the correct update functions for constrained qiro
qiro_instance = QIROProblem(G,
create_max_indep_replacement_routine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,23 @@ Example implementation
Let us now look at what these building blocks look like in working code example. We start off by defining the relevant parameters for a portfolio rebalancing instance, namely the number of assets and lots, the asset covariance matrix, the previous portfolio positions, the risk return factor, the normalized asset returns and the trading cost.

::
#imports
import sklearn
import numpy as np

# assign problem definitions
# number of assets
n_assets = 4

# lots
lots = 2

# old positions
old_pos = [1, 1, 0, 1, 0, 0]
# risk return factor
risk_return = 0.9
# trading costs
T = 0
tc = 0.01

# covariance between assets -- create covar_matrix
covar_string = "99.8 42.5 37.2 40.3 38.0 30.0 46.8 14.9 42.5 100.5 41.1 15.2 71.1 27.8 47.5 12.7 37.2 41.1 181.3 17.9 38.4 27.9 39.0 8.3 40.3 15.2 17.9 253.1 12.4 48.7 33.3 3.8 38.0 71.1 38.4 12.4 84.7 28.5 42.0 13.1 30.0 27.8 27.9 48.7 28.5 173.1 28.9 -12.7 46.8 47.5 39.0 33.3 42.0 28.9 125.8 14.6 14.9 12.7 8.3 3.8 13.1 -12.7 14.6 179.0"
Expand Down

0 comments on commit fed0eb4

Please sign in to comment.