Constrained tuning: Difference between revisions

m Added internal link for TWE tuning
Rework for constrained tunings in general
Line 1: Line 1:
'''Constrained tunings''' are tuning optimization techniques under the constraints of some purely tuned intervals (i.e. [[eigenmonzo]]s). The '''CTE tuning''' ('''constrained Tenney-Euclidean tuning''') is the most typical instance and will be the focus of this article. Otherwise normed tunings can be defined and computed analogously.  
'''Constrained tunings''' are tuning [[optimization]] techniques using the constraint of some purely tuned intervals (i.e. [[eigenmonzo]]s). '''CTE tuning''' ('''constrained Tenney-Euclidean tuning''') is the most typical instance. It has a more sophisticated variant, '''CTWE tuning''' ('''constrained Tenney-Weil-Euclidean tuning'''), aka '''KE tuning''' ('''Kees-Euclidean tuning'''). These two tunings will be the focus of this article. Otherwise normed tunings can be defined and computed analogously.  


While the TE tuning can be viewed as a [[Wikipedia: Least squares|least squares problem]], the CTE tuning can be viewed as an equality-constrained least squares problem. For a rank-''r'' temperament, specifying ''m'' eigenmonzos will yield ''r'' - ''m'' [[Wikipedia: Degrees of freedom|degrees of freedom]] to be optimized.  
All constrained tunings are standard temperament optimization problems. Specifically, as [[TE tuning]] can be viewed as a [[Wikipedia: Least squares|least squares problem]], CTE tuning can be viewed as an equality-constrained least squares problem.  


The most significant form of CTE tuning is pure-octave constrained, which is assumed unless specified otherwise. For higher-rank temperaments, it may make sense to add multiple constraints, such as the pure-{2, 3} CTE tuning.  
The most common subject of constraint is the octave, which is assumed unless specified otherwise. For higher-rank temperaments, it may make sense to add multiple constraints, such as a pure-2.3 constrained tuning. For a rank-''r'' temperament, specifying ''m'' eigenmonzos will yield ''r'' - ''m'' [[Wikipedia: Degrees of freedom|degrees of freedom]] to be optimized.  


== Definition ==
== Definition ==
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. If the tuning is contrained by the eigenmonzo list B, the CTE tuning is equivalent to the following optimization problem:
Given a temperament [[mapping]] A and the [[JIP]] J<sub>0</sub>, denote the weight-skewed mapping V = AWX and the weight-skewed JIP J = J<sub>0</sub>WX. Suppose the tuning is constrained by the eigenmonzo list B<sub>C</sub>. The goal is to find the generator list G by


Minimize
Minimize


<math>\lVert GV - J \rVert</math>
<math>\displaystyle \lVert GV - J \rVert_p </math>


subject to
subject to


<math>(GA - J_0)B = O</math>
<math>\displaystyle (GA - J_0)B_{\rm C} = O </math>


where G is the generator list, and O the zero matrix.  
where O is the zero matrix.  


The problem is feasible if
The problem is feasible if
# rank (B) ≤ rank (A), and
# rank (B<sub>C</sub>) ≤ rank (A), and
# The subspaces of B and N (A) are [[Wikipedia:linear independence|linearly independent]].
# The subspaces of B<sub>C</sub> and N (A) are [[Wikipedia:linear independence|linearly independent]].


== Computation ==
== Computation ==
The tuning can be solved in the [[wikipedia: Lagrange multiplier|method of Lagrange multiplier]]. The solution is given by
As a standard optimization problem, numerous algorithms exist to solve it, such as [[Wikipedia: Sequential quadratic programming|sequential quadratic programming]], to name one. [[Flora Canou]]'s [https://github.com/FloraCanou/temperament_evaluator/blob/55859971e5db037f5353267c328ca4a20f515ecd/te_optimizer_legacy.py tuning optimizer] is such an implementation in [https://www.python.org Python]. Note: it depends on [https://scipy.org/ Scipy].  
 
<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)^{\mathsf T}
\end{bmatrix}
</math>
 
which is almost an analytical solution. 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 discarded.
 
Otherwise, as a standard optimization problem, numerous algorithms exist to solve it, such as [[Wikipedia: Sequential quadratic programming|sequential quadratic programming]], to name one. [[Flora Canou]]'s [https://github.com/FloraCanou/temperament_evaluator/blob/55859971e5db037f5353267c328ca4a20f515ecd/te_optimizer_legacy.py tuning optimizer] is such an implementation in [https://www.python.org Python]. Note: it depends on [https://scipy.org/ Scipy].  


{{Databox| Code |
{{Databox| Code |
Line 159: Line 138:
</pre>
</pre>


== Versus CTWE and POTE tuning ==
Analytical solutions exist for Euclidean (''L''<sup>2</sup>) tunings, see [[Analytical solution to constrained Euclidean tunings]].
Consider the fact that TE tuning does not treat divisive ratios as more important than multiplicative ratios – 5/3 and 15/1 are taken as equally important, for example. To address that, a skew on the space may be introduced, resulting in [[TWE tuning]]. Constraining the equave to pure on top of TWE gives CTWE aka KE tuning. POTE works as a quick approximation to CTWE. As POTE destretches the equave, it keeps the angle in the tuning space unchanged, and thus sacrifices multiplicative ratios for divisive ratios. On the contrary, CTE sticks to the original design book of TE as its result remains TE optimal.
 
For CTE in particular, it can be solved in the [[wikipedia: Lagrange multiplier|method of Lagrange multiplier]]. The solution is 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)^{\mathsf T}
\end{bmatrix}
</math>
 
which is almost an analytical solution. 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 discarded.
 
== CTE tuning vs CTWE tuning ==
Consider the fact that TE tuning does not treat divisive ratios as more important than multiplicative ratios – 5/3 and 15/1 are taken as equally important, for example. To address that, a skew on the space may be introduced, resulting in [[TWE tuning]]. Constraining the equave to pure on top of TWE gives CTWE aka KE tuning.  
 
[[POTE tuning]] works as a quick approximation to CTWE. As POTE destretches the equave, it keeps the angle in the tuning space unchanged, and thus sacrifices multiplicative ratios for divisive ratios. On the contrary, CTE sticks to the original design book of TE as its result remains TE optimal.


These tunings can be very different from each other. Take 7-limit meantone as an example. The POTE [[tuning map]] is a little bit flatter than [[quarter-comma meantone]], with all the primes tuned flat:  
These tunings can be very different from each other. Take 7-limit meantone as an example. The POTE [[tuning map]] is a little bit flatter than [[quarter-comma meantone]], with all the primes tuned flat:  
Line 175: Line 179:


== Special constraint ==
== Special constraint ==
The special eigenmonzo Wj removes the weighted tuning bias, where j is the all-ones monzo:
The special eigenmonzo WXj removes the weight-skewed tuning bias, where j is the all-ones monzo.
 
For CTE, it can be easily shown to be


<math>\displaystyle W \vec j = [ \begin{matrix} 1 & 1/\log_2 (3) & \ldots & 1/\log_2 (p) \end{matrix} \rangle </math>
<math>\displaystyle W \vec j = [ \begin{matrix} 1 & 1/\log_2 (3) & \ldots & 1/\log_2 (p) \end{matrix} \rangle </math>