Package: dann5
dann5.ocean version 2 (d5o2)This project aims to simplify the programming of quantum computing models and demonstrates ways of faster development of interactive examples, which will help you learn to formulate and solve problems on quantum computers by usingdann5 d5o libraryquantum programing types and operations. The d5o library provides means of converting operational assignments into QUBO, which then can be executed on various quantum solvers, being analog quantum gate computers using IBM Qiskit for example, or quantum annealers or hybrid computers using DWave Ocean, or quantum simulators using Azure Quantum. Dann5 d5o library provides means of specifying undefined and defined variables in python of programming types such as q-bit, q-boolean, q-binary, q-whole, q-integer, quantum non-negative rational and q-rational. The specified quantum variables then can be linked into quantum logic assignments by applying appropriate operational expression to describe the problem that needs to be solved. In a way dann5 d5o library is an extension of D-Wave Ocean's stack of tools, which will allow you to develop integrated code, and to submit it to run in a quantum annealing computer (QAC), either D-Wave Advantage, 2000Q or Hybrid Solver.The goal of Dann5 project and d5o framework is to provide QAC developers with programming constructs, such as:standard types:Qbit† – quantum bit, whereQbit x ϵ { 0, 1, S(uperposition) }Qbool† – quantum boolean, whereQbool x ϵ { T(rue), F(alse), S(uperposition) }Qbin† – quantum binary, as an array of Qbit’sQbin x ≡ Qbit[ xi; where xi ϵ Qbit & 0 <= i <= n ]Qwhole– quantum whole numbers (non-negative integer), whereQwhole x ∈ { n | n ≥ 0                                         }
           {   | n = U(nknown) if ni = S | ni ϵ Qbit & ni ϵ n} }Qint† – quantum integer numbers, whereQint x ∈ Qwhole U -Qwhole                                         }Qnnr†† – quantum non-negative rational numbers, whereQnnr x ∈ { r | r ∈ R(ational) & n≥0                          }
         {   | r = U(nknown) if ri = S | ri ϵ Qbit & ri ϵ r} }Qrat†† – quantum rational numbers, whereQreal x ∈ Qnnr U -Qnnr                                         }definitions:Quantum variableexamplesQbit x(“x”) ⇛ initialize a Q bit variable with the bit in S(uperpostion) stateQbool y(“z”, d5o.Qbool.false()) ⇛ initialize a defined Q binary variable with bit z = 0Qbin a(3, “a”) ⇛ initialize an undefined Q binary variable with 3 quantum bits in S(uperpostion) stateQwhole b(“b”, 6) ⇛ initialize a defined Q whole variable b with value 6, i.e. contains 3 qbits with deterministic values: b0 = 0, b1 = 1 and b2 = 1Qint i(3, “i”, -1) ⇛ initialize a defined Q whole variable i with value -1, i.e. contains 3 qbits with deterministic values: i0 = 1 i1 = 1 and i2 = 1Qnnr c(“c”, 2.5) ⇛ initialize a defined Q non-negative rational variable c with binary value 10.1, i.e. c-1 = 1, c0 = 0 and c1 = 1 ††Qrat a(1.2, “d”) ⇛ initialize a Q rational variable d with 3 quantum bits, as an unknown rational number, i.e. d-2 = S, d-1 = S and d0 = S ††Qassignment- quantum assignment defines an operational interaction between predefined variableseX = Qwhole(“X”, 15).assign(a * a) ⇛ for Q variable a (defined above) assigns multiplication expression with expected result X -= 15 to eX Q quantum assignmentQUBO integration into D-Wave Ocean, Azure Quantum or Qiskit:qubo()– returns QUBO binary quadratic model (BQM) of the assignmenteX.qubo() ⇛ for eX Q assignment (defined above) returns a QUBO dictionary object for execution on an exact or QAC solveradd()– receives a dictionary of samples returned by a solvereX.add(lowSamples) ⇛ sets resulting samples returned from a solver into eX Q equation, which has been used to create QUBO BQMsolutions()– returns string representation of the assignments solutions based on added sampleseX.solutions() ⇛ for eX Q assignment (defined above) with expected result 15 and b set to 6 returns solutions for undefined Q variable areset()– resets teh assignment into its inital state, i.e. without any solutionseX.reset() ⇛ for eX Q assignment (defined above) is set into its initial stateQcondition†† - quantum condition statementQcondition cA(a > b) ⇛ creates a Q condition cA that compares (above defined) Q variables a and bcA << eX ⇛ adds the (above defined) eX Q equation to be calculated under condition cA, i.e. a is bigger than bQroutine†† - quantum routineQroutine program(“my Q program”) ⇛ creates a Q routine program, which allows correlation of programming Q statementsprogram << cA << eB ⇛ adds the (above defined) cA Q condition and a predefined eB Q equation into my Q programQfunction†† - quantum function routineQfunction myF(“my F”, a) ⇛ creates a Q function routine my F with Q variable a as a return variablemyF << cA << a + b ⇛ adds the (above defined) cA Q condition and addition Q equation of a and b into myFeB *= myF ⇛ updates eB Q equation with a multiplication of its existing expression with a return from myF Q functionQpow††,Qmod††,Qgcd†† - specialized quantum functionQpow a_x3(a, 3) ⇛ creates a power Q function routine a_x3 with Q variable a as a base and exponent 3Qmod b_m3(b, 3) ⇛ creates a modulo Q function routine b_m3 with Q variable b as a dividend and divisor 3Qgcd a_b(a, b) ⇛ creates a greatest common divisor Q function routine a_b for Q variables a and bstandard operations:assignment– of quantum variable or expression to the Q equationunary operators: ~ (inversion)binary operators: +, *, -, /logical operators: &, |, ^, nand, norcomparison operators †: ==, !=, >, >=, <, <=Note:  † features in development, †† planned features.For additional information on how to use features of d5o refer toexamples.Install & UseInstallation prerequisitesTo install and use Dann5 d5o precompiled libraryinstallPython 3.9.9 (64-bit), which has been used to test released functionalityinstall D-Wave Ocean Tools into python environment; followInstalling Ocean Toolsinstall pybind11 into the same python environment; followInstalling the libraryTo compile Dann5 d5o source code in addition to above prerequisitesinstallEigenby followingdownload instructionsInstallationDann5 d5o library is in active development on Windows x64 as a primary OS. A Mac OS X/Linux version and package installation will be released in the future.Install Windows x64 version from this repository into python project or environmentpip install --upgrade dann5#####Install manuallyDownload dann5 folder with d5o.cp38-win_amd64.pyd library fromexamples folderMake dann5 a sub-folder ofyour python project folder; orsite-packages folder for your python environment, e.g. for anaconda distribution, on windows, the path should be:C:\Users<user_name>\AppData\Local\Continuum\anaconda3\envs<env_name>\Lib\site-packagesCopy d5o.cp38-win_amd64.pyd into Dann5 sub-folder#####Install package from source codeSimply clone or download the dann5 repository
-	If using the MS Visual Studio dann5.ocean.sln, make sure dann5 and Eigen are sub-folders in the same folder.Build
-	d5o.cp38-win_amd64.pyd for windows and python x64
-	d5o.cp38-win_amd32.pyd for windows and python x32
-	d5o.so for Mac OS X or LinuxDeploy d5o library into dann5 folder within your python project or environment as described above in Windows x64 version installationUseAfter installing d5o library as per instructions above, use released features in your python source code:import dann5.d5o2 as d5oa = Qwhole(4, "a")b = Qwhole(3, "b")A = Qwhole("A", 15))eA = A.assign( a + b )print(eA.toString())print(eA.toString(True))print(eA.qubo())Or use Jupyter Notebookexamplesto review Dann5 d50 version 2 functionality.Bugs, issues and contributingContributions to this project are welcome.Note: if you have an issue, please send me the code example.