Skip to content
This is the development version of the documentation. It may change before the next release. See 0.9.x for the latest release.

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 phases,
&mut intensities,
)?;
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)
phases &mut [Vec<Phase>] Phase output buffer
intensities &mut [Vec<Intensity>] Intensity output buffer

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

GreedyOption {
phase_quantization_levels,
constraint,
directivity,
objective_func,
mask,
..Default::default()
}
Field Type Default
phase_quantization_levels NonZeroU8 16
constraint IntensityConstraint 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, TransducerMask, 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, IntensityConstraint, GreedyOption, Pa, abs_objective_func,
greedy,
};
let geometry = Geometry::new(vec![Autd3::default()]);
let mut phases = geometry.phase_buffer();
let mut intensities = geometry.intensity_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: IntensityConstraint::Uniform(Intensity::MAX),
directivity: Directivity::Sphere,
objective_func: abs_objective_func,
mask: TransducerMask::AllEnabled,
..Default::default()
},
&mut phases,
&mut intensities,
)?;