use scirs2_core::ndarray::{Array, Ix2};
use std::collections::HashMap;
use super::super::gpu::ArminSampler;
use super::super::{SampleResult, Sampler, SamplerError, SamplerResult};
#[cfg(feature = "gpu")]
pub struct MIKASAmpler {
armin_sampler: ArminSampler,
optimization_mode: String,
}
#[cfg(feature = "gpu")]
impl MIKASAmpler {
#[must_use]
pub fn new(seed: Option<u64>) -> Self {
Self {
armin_sampler: ArminSampler::new(seed),
optimization_mode: "advanced".to_string(),
}
}
#[must_use]
pub fn with_params(seed: Option<u64>, mode: &str, device: &str, verbose: bool) -> Self {
Self {
armin_sampler: ArminSampler::with_params(seed, mode, device, verbose),
optimization_mode: "advanced".to_string(),
}
}
pub fn with_optimization_mode(mut self, mode: &str) -> Self {
self.optimization_mode = mode.to_string();
self
}
}
#[cfg(feature = "gpu")]
impl Sampler for MIKASAmpler {
fn run_qubo(
&self,
qubo: &(Array<f64, Ix2>, HashMap<String, usize>),
shots: usize,
) -> SamplerResult<Vec<SampleResult>> {
self.armin_sampler.run_qubo(qubo, shots)
}
fn run_hobo(
&self,
hobo: &(
Array<f64, scirs2_core::ndarray::IxDyn>,
HashMap<String, usize>,
),
shots: usize,
) -> SamplerResult<Vec<SampleResult>> {
self.armin_sampler.run_hobo(hobo, shots)
}
}
#[cfg(not(feature = "gpu"))]
pub struct MIKASAmpler {
fallback_sampler: ArminSampler,
}
#[cfg(not(feature = "gpu"))]
impl MIKASAmpler {
#[must_use]
pub const fn new(_seed: Option<u64>) -> Self {
Self {
fallback_sampler: ArminSampler::new(None),
}
}
#[must_use]
pub const fn with_params(
_seed: Option<u64>,
_mode: &str,
_device: &str,
_verbose: bool,
) -> Self {
Self {
fallback_sampler: ArminSampler::new(None),
}
}
}
#[cfg(not(feature = "gpu"))]
impl Sampler for MIKASAmpler {
fn run_qubo(
&self,
_qubo: &(Array<f64, Ix2>, HashMap<String, usize>),
_shots: usize,
) -> SamplerResult<Vec<SampleResult>> {
Err(SamplerError::GpuError(
"GPU support not enabled".to_string(),
))
}
fn run_hobo(
&self,
_hobo: &(
Array<f64, scirs2_core::ndarray::IxDyn>,
HashMap<String, usize>,
),
_shots: usize,
) -> SamplerResult<Vec<SampleResult>> {
Err(SamplerError::GpuError(
"GPU support not enabled".to_string(),
))
}
}