Greedy

Source

Greedy Algorithm with Brute-Force Search, 鈴木らの論文1に基づく多焦点Gain.

use autd3::prelude::*;
use autd3_gain_holo::{EmissionConstraint, Pa, Greedy, GreedyOption, Sphere, AbsGreedyObjectiveFn};
use std::num::NonZeroU8;

fn main() {
let x1 = 0.;
let y1 = 0.;
let z1 = 0.;
let x2 = 0.;
let y2 = 0.;
let z2 = 0.;
let _ = 
Greedy::<Sphere, _> {
    foci: vec![
        (Point3::new(x1, y1, z1), 5e3 * Pa),
        (Point3::new(x2, y2, z2), 5e3 * Pa),
    ],
    option: GreedyOption {
        phase_quantization_levels: NonZeroU8::new(16).unwrap(),
        constraint: EmissionConstraint::Uniform(Intensity::MAX),
        objective_func: AbsGreedyObjectiveFn,
        ..Default::default()
    },
};
}
#include <autd3.hpp>
#include "autd3/gain/holo.hpp"

using namespace autd3;
using gain::holo::Pa;

int main() {
const auto x1 = 0.0;
const auto y1 = 0.0;
const auto z1 = 0.0;
const auto x2 = 0.0;
const auto y2 = 0.0;
const auto z2 = 0.0;
auto g = gain::holo::Greedy(
    std::vector<std::pair<Point3, gain::holo::Amplitude>>{
        {Point3(x1, y1, z1), 5e3 * Pa},
        {Point3(x2, y2, z2), 5e3 * Pa},
    },
    gain::holo::GreedyOption{
        .phase_quantization_levels = 16,
        .constraint = gain::holo::EmissionConstraint::Uniform(
            std::numeric_limits<Intensity>::max())});
  return 0;
}
using AUTD3Sharp.Gain.Holo;

using AUTD3Sharp;
using AUTD3Sharp.Utils;
using static AUTD3Sharp.Units;
var x1 = 0.0f;
var y1 = 0.0f;
var z1 = 0.0f;
var x2 = 0.0f;
var y2 = 0.0f;
var z2 = 0.0f;
new Greedy(
    foci: [
             (new Point3(x1, y1, z1), 5e3f * Pa),
             (new Point3(x2, y2, z2), 5e3f * Pa)
    ],
    option: new GreedyOption
    {
        PhaseQuantizationLevels = 16,
        EmissionConstraint = EmissionConstraint.Uniform(Intensity.Max),
    }
);
import numpy as np
from pyautd3 import Intensity
from pyautd3.gain.holo import Greedy, EmissionConstraint, GreedyOption, Pa

x1 = 0.0
y1 = 0.0
z1 = 0.0
x2 = 0.0
y2 = 0.0
z2 = 0.0
Greedy(
    foci=[(np.array([x1, y1, z1]), 5e3 * Pa), (np.array([x2, y2, z2]), 5e3 * Pa)],
    option=GreedyOption(
        phase_quantization_levels=16,
        constraint=EmissionConstraint.Uniform(Intensity.MAX),
    ),
)

phase_quantization_levelsは位相の離散化深度, デフォルトは上記の通り. パラメータの詳細は論文1を参照されたい.

Rust版のみ, 目的関数を変更できる. デフォルトは以下のように, 目標音圧との絶対誤差を使用する.

use autd3_gain_holo::*;
use nalgebra::ComplexField;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct AbsGreedyObjectiveFn;

impl GreedyObjectiveFn for AbsGreedyObjectiveFn {
    fn objective_func(current: Complex, target: Amplitude) -> f32 {
        (target.pascal() - current.abs()).abs()
    }
}
fn main() {}
1

Suzuki, Shun, et al. “Radiation Pressure Field Reconstruction for Ultrasound Midair Haptics by Greedy Algorithm with Brute-Force Search.” IEEE Transactions on Haptics (2021).