Constrained tuning: Difference between revisions

Update the code
Try incorporating the lagrange multiplier method
Line 4: Line 4:


== Definition ==
== Definition ==
Given a temperament [[mapping]] A, the CTE tuning is equivalent to the following optimization problem:  
Given a temperament [[mapping]] A and the [[JIP]] J<sub>0</sub>, denote the Tenney-weighted temperament mapping by V = AW, and the Tenney-weighted JIP by J = J<sub>0</sub>W. The CTE tuning is equivalent to the following optimization problem:  


Minimize
Minimize
Line 14: Line 14:
<math>(GA - J_0)B = O</math>
<math>(GA - J_0)B = O</math>


where G is the generator list, V = AW the Tenney-weighted temperament mapping, J = J<sub>0</sub>W the Tenney-weighted [[JIP]], and B the monzo list.  
where G is the generator list, B the monzo list, and O the zero matrix.  


The problem is feasible if
The problem is feasible if
Line 21: Line 21:


== Computation ==
== Computation ==
As a standard optimization problem, numerous algorithms exist to solve for this tuning, such as [[Wikipedia: Sequential quadratic programming|sequential quadratic programming]], to name one.  
The tuning can be solved in the [[wikipedia: Lagrange multiplier|method of Lagrange multiplier]]. The solution is almost analytically given by
 
<math>
\begin{bmatrix}
G^{\mathsf T}  \\
\Lambda^{\mathsf T}
\end{bmatrix}
=
\begin{bmatrix}
VV^{\mathsf T} & AB \\
(AB)^{\mathsf T} & O
\end{bmatrix}^{-1}
 
\begin{bmatrix}
VJ^{\mathsf T}\\
J_0 B
\end{bmatrix}
</math>
 
Notice we introduced the vector of lagrange multipliers Λ, with length equal to the number of constraints. The lagrange multipliers have no concrete meaning for the resulting tuning, so they can be ignored.
 
Otherwise, as a standard optimization problem, numerous algorithms exist to solve it, such as [[Wikipedia: Sequential quadratic programming|sequential quadratic programming]], to name one.  


The following [https://www.python.org Python] code is an excerpt from [[Flora Canou]]'s [https://github.com/FloraCanou/te_temperament_measures/blob/54c9ec58acf0ad5adc7c1d96f2deaf1d2a503702/tuning_optimizer.py tuning optimizer]. Note: it depends on [https://scipy.org/ Scipy].  
The following [https://www.python.org Python] code is an excerpt from [[Flora Canou]]'s [https://github.com/FloraCanou/te_temperament_measures/blob/54c9ec58acf0ad5adc7c1d96f2deaf1d2a503702/tuning_optimizer.py tuning optimizer]. Note: it depends on [https://scipy.org/ Scipy].