Skip to content

greedy

src

greedy is a combinatorial optimization that greedily selects the phase of each transducer one at a time from a set of discrete candidates. The algorithm is based on the paper by Suzuki et al. (Suzuki et al., 2021).

greedy(&geometry, &foci, wavelength, &option, &mut dst)?;
Parameter Type Description
geometry &Geometry Device layout
foci &[AmplitudeTarget] Sequence of focal points (position and target amplitude)
wavelength Length Wavelength
option &GreedyOption Additional options (see below)
dst &mut [[Emission; _]] Output buffer

For the common elements (AmplitudeTarget / TransducerMask, etc.), see the Holo overview.

GreedyOption {
phase_quantization_levels,
constraint,
directivity,
objective_func,
mask,
}
Field Type Default
phase_quantization_levels NonZeroU8 16
constraint EmissionConstraint Uniform(MAX)
directivity Directivity Sphere
objective_func fn(Complex<f32>, Amplitude) -> f32 abs_objective_func
mask TransducerMask AllEnabled
  • phase_quantization_levels — the number of divisions of the phase candidates. The larger it is, the higher the phase resolution.
  • objective_func — the objective function that evaluates each candidate. The default abs_objective_func returns the absolute value of the difference between the magnitude of the synthesized sound pressure and the target amplitude.
    • Configurable only in the Rust version. In other languages, the default objective function is used.
  • For the meaning of constraint / directivity / mask, see the Holo overview.
use std::num::NonZeroU8;
use autd3_rs::geometry::{Autd3, Geometry, offset};
use autd3_rs::units::{m, mm, s};
use autd3_rs::value::Intensity;
use autd3_rs_pattern::wavelength;
use autd3_rs_pattern_holo::{
AmplitudeTarget, Directivity, EmissionConstraint, GreedyOption, Pa, TransducerMask,
abs_objective_func, greedy,
};
let geometry = Geometry::new(vec![Autd3::default()]);
let mut dst = geometry.pattern_buffer();
greedy(
&geometry,
&[
AmplitudeTarget {
point: geometry.center() + offset(-30.0 * mm, 0.0 * mm, 150.0 * mm),
amplitude: 2.5e3 * Pa,
},
AmplitudeTarget {
point: geometry.center() + offset(30.0 * mm, 0.0 * mm, 150.0 * mm),
amplitude: 2.5e3 * Pa,
},
],
wavelength(340.0 * m / s),
&GreedyOption {
phase_quantization_levels: NonZeroU8::new(16).unwrap(),
constraint: EmissionConstraint::Uniform(Intensity::MAX),
directivity: Directivity::Sphere,
objective_func: abs_objective_func,
mask: TransducerMask::AllEnabled,
},
&mut dst,
)?;