Luna 1.2.0
Luna 1.2.0
Breaking Changes
Luna 1.2.0 now uses the standalone luna-model package from PyPI. While the core modeling functionality remains the same, several API changes have been introduced to align with Python conventions and improve consistency.
Luna 1.2.0 introduces a significant architectural improvement by migrating to the public luna-model package on PyPI. This transition streamlines dependency management and provides access to enhanced modeling capabilities.
📋 Migration Guide
Enum Value Changes
All enumeration values now follow UPPER_CASE_WITH_UNDERSCORES naming convention (PEP 8 style for constants) instead of PascalCase:
Variable Types (Vtype)
Optimization Sense
Constraint Comparators
ConstraintCollection Indexing
ConstraintCollection can now only be indexed by constraint name, not by integer index.
from luna_quantum import ConstraintCollection
constraints = ConstraintCollection()
constraints.add_constraint(c1, "constraint_1")
constraints.add_constraint(c2, "constraint_2")
# Only name-based indexing works
named = constraints["constraint_1"] # ✅ Name indexing only
# first = constraints[0] # ❌ No longer supported
# Iterate using .items() instead
for name, constraint in constraints.items():
print(f"{name}: {constraint}")
from luna_quantum import ConstraintCollection
constraints = ConstraintCollection()
constraints.add_constraint(c1, "constraint_1")
constraints.add_constraint(c2, "constraint_2")
# Both indexing methods worked
first = constraints[0] # ✅ Integer indexing
named = constraints["constraint_1"] # ✅ Name indexing
Translator Method Renaming
All translator methods have been renamed from to_aq/from_aq to to_lm/from_lm to reflect the migration to luna-model.
Affected Model translator classes (convert to/from Model):
QuboTranslator- QUBO matrix translatorLpTranslator- Linear Programming file translatorBqmTranslator- Binary Quadratic Model translatorCqmTranslator- Constrained Quadratic Model translator
Affected Solution translator classes (convert external results to Solution):
AwsTranslator- AWS Braket results translatorDwaveTranslator- D-Wave results translatorIbmTranslator- IBM Qiskit results translatorNumpyTranslator- NumPy arrays translatorQctrlTranslator- Q-CTRL results translatorZibTranslator- ZIB solver results translator
In addition, you can now call the translation capa
🚀 New Features
New Quantum Backend, IBMQuantum, is now available for use with Luna.
The luna-model package provides enhanced capabilities:
-
Extended Expression Utilities Additional methods for working with expressions, including better iteration and inspection of terms.
-
Improved Type Safety Enhanced type hints and stub files (
.pyi) for better IDE support and static type checking. -
Performance Optimizations Various performance improvements in the modeling layer.
📝 Migration Checklist
When upgrading from luna-quantum < 1.2.0, update your code as follows:
- Replace all enum values with
UPPER_CASE_WITH_UNDERSCORESequivalents:Vtype.Binary→Vtype.BINARYVtype.Spin→Vtype.SPINVtype.Integer→Vtype.INTEGERVtype.Real→Vtype.REALSense.Min→Sense.MINSense.Max→Sense.MAXComparator.Eq→Comparator.EQComparator.Le→Comparator.LEComparator.Ge→Comparator.GE
- Remove integer indexing from
ConstraintCollectionobjects - Update to use
.items()for iterating over constraints - Replace all
to_aq()withto_lm()in translator classes - Replace all
from_aq()withfrom_lm()in translator classes