From 473ee6e9451152b45ac4f3a032fdc4abb057233b Mon Sep 17 00:00:00 2001 From: Lonca Emmanuel Date: Wed, 18 Oct 2023 10:01:05 +0200 Subject: [PATCH] added all the material used for XPs --- src/ipafair_solver.rs | 5 +++++ src/lib.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/ipafair_solver.rs b/src/ipafair_solver.rs index 631d058..a2d4b93 100644 --- a/src/ipafair_solver.rs +++ b/src/ipafair_solver.rs @@ -3,6 +3,9 @@ use crustabri::{ DummyDynamicConstraintsEncoder, DynamicCompleteSemanticsSolver, DynamicPreferredSemanticsSolver, DynamicSolver, DynamicStableSemanticsSolver, }, + dynamics_attacks::{ + DynamicCompleteSemanticsSolverAttacks, DynamicStableSemanticsSolverAttacks, + }, solvers::{CredulousAcceptanceComputer, SkepticalAcceptanceComputer}, }; use ipafair_sys::semantics; @@ -43,6 +46,8 @@ impl IpafairAcceptanceSolver for DynamicCompleteSemanticsSolver {} impl IpafairAcceptanceSolver for DynamicStableSemanticsSolver {} impl IpafairAcceptanceSolver for DynamicPreferredSemanticsSolver {} impl IpafairAcceptanceSolver for DummyDynamicConstraintsEncoder {} +impl IpafairAcceptanceSolver for DynamicCompleteSemanticsSolverAttacks {} +impl IpafairAcceptanceSolver for DynamicStableSemanticsSolverAttacks {} impl IpafairSolverSemantics { fn new_acceptance_solver<'a>(&self) -> Box { diff --git a/src/lib.rs b/src/lib.rs index 6839c46..ed76e8b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,9 @@ use const_cstr::const_cstr; use crustabri::{ dynamics::DummyDynamicConstraintsEncoder, + dynamics_attacks::{ + DynamicCompleteSemanticsSolverAttacks, DynamicStableSemanticsSolverAttacks, + }, solvers::{CompleteSemanticsSolver, StableSemanticsSolver}, }; use ipafair_solver::{FactoryType, IpafairSolver, IpafairSolverSemantics}; @@ -42,6 +45,45 @@ pub extern "C" fn ipafair_init_dummy() -> *mut ::std::os::raw::c_void { Box::into_raw(Box::new(IpafairSolver::new_with_factory(factory))) as *mut _ } +#[no_mangle] +pub extern "C" fn ipafair_init_attacks_2_0() -> *mut ::std::os::raw::c_void { + let factory: Box = Box::new(move |s| match s { + IpafairSolverSemantics::CO => Box::new( + DynamicCompleteSemanticsSolverAttacks::new_with_arg_factor(2.), + ), + IpafairSolverSemantics::ST => Box::new( + DynamicStableSemanticsSolverAttacks::new_with_arg_factor(2.), + ), + }); + Box::into_raw(Box::new(IpafairSolver::new_with_factory(factory))) as *mut _ +} + +#[no_mangle] +pub extern "C" fn ipafair_init_attacks_1_5() -> *mut ::std::os::raw::c_void { + let factory: Box = Box::new(move |s| match s { + IpafairSolverSemantics::CO => Box::new( + DynamicCompleteSemanticsSolverAttacks::new_with_arg_factor(1.5), + ), + IpafairSolverSemantics::ST => Box::new( + DynamicStableSemanticsSolverAttacks::new_with_arg_factor(1.5), + ), + }); + Box::into_raw(Box::new(IpafairSolver::new_with_factory(factory))) as *mut _ +} + +#[no_mangle] +pub extern "C" fn ipafair_init_attacks_1_25() -> *mut ::std::os::raw::c_void { + let factory: Box = Box::new(move |s| match s { + IpafairSolverSemantics::CO => Box::new( + DynamicCompleteSemanticsSolverAttacks::new_with_arg_factor(1.25), + ), + IpafairSolverSemantics::ST => Box::new( + DynamicStableSemanticsSolverAttacks::new_with_arg_factor(1.25), + ), + }); + Box::into_raw(Box::new(IpafairSolver::new_with_factory(factory))) as *mut _ +} + #[no_mangle] pub extern "C" fn ipafair_release(solver_ptr: *mut ::std::os::raw::c_void) { debug_assert!(!solver_ptr.is_null());