#![allow(deprecated)]
#[allow(deprecated)]
use bcinr_cmca::allocator::{
allocate, AdaptiveUpdate, AdmittedControlState, CertificateReceipt, CertifiedLearning,
EnvelopeReceipt, OutcomeReceipt, StabilityRefusal,
};
use bcinr_cmca::fixed::NonNegativeFixed;
use bcinr_cmca::generated::consequence_mass::case_studies::{
ETA, LAMBDA, LENS_REGISTRY, N, OBJECT_REGISTRY, Q,
};
use bcinr_cmca::generated::stability_profile::CERTIFICATE_DIGEST;
#[allow(deprecated)] fn get_proof() -> Option<AdaptiveUpdate<CertifiedLearning>> {
AdaptiveUpdate::admit_adaptive_update(
AdmittedControlState::admit_control_state(0),
CertificateReceipt::admit_certificate(0),
EnvelopeReceipt::admit_envelope(0),
OutcomeReceipt::admit_outcome(0),
NonNegativeFixed::ZERO,
NonNegativeFixed::ONE,
CertifiedLearning::admit_learning(),
)
}
fn main() {
let parent = [-1; N];
let mu = [NonNegativeFixed::ZERO; N];
let costs = [NonNegativeFixed::ZERO; N];
let mut weights = [[NonNegativeFixed::ONE; 2 * Q]; N];
let payoffs = [[NonNegativeFixed::ZERO; 2 * Q]; N];
let mut last_switch_t = 0u32;
let mut prev_mode = 0u32;
let result: Result<[NonNegativeFixed; N], StabilityRefusal> = allocate(
&OBJECT_REGISTRY,
&LENS_REGISTRY,
&LAMBDA,
ETA,
&parent,
&mut weights,
&payoffs,
NonNegativeFixed::ZERO,
NonNegativeFixed::ZERO,
&mu,
&costs,
0,
&mut last_switch_t,
&mut prev_mode,
500,
CERTIFICATE_DIGEST,
get_proof().as_ref(),
);
match result {
Ok(shares) => {
println!("allocate() succeeded -- per-object allocation shares:");
for (i, share) in shares.iter().enumerate() {
println!(" object[{i}] = {share:?}");
}
}
Err(refusal) => {
println!("allocate() refused: {refusal} ({refusal:?})");
}
}
}