Skip to content

Commit

Permalink
added all the material used for XPs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonca Emmanuel committed Oct 18, 2023
1 parent c0d8ea7 commit 473ee6e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ipafair_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use crustabri::{
DummyDynamicConstraintsEncoder, DynamicCompleteSemanticsSolver,
DynamicPreferredSemanticsSolver, DynamicSolver, DynamicStableSemanticsSolver,
},
dynamics_attacks::{
DynamicCompleteSemanticsSolverAttacks, DynamicStableSemanticsSolverAttacks,
},
solvers::{CredulousAcceptanceComputer, SkepticalAcceptanceComputer},
};
use ipafair_sys::semantics;
Expand Down Expand Up @@ -43,6 +46,8 @@ impl IpafairAcceptanceSolver for DynamicCompleteSemanticsSolver<usize> {}
impl IpafairAcceptanceSolver for DynamicStableSemanticsSolver<usize> {}
impl IpafairAcceptanceSolver for DynamicPreferredSemanticsSolver<usize> {}
impl IpafairAcceptanceSolver for DummyDynamicConstraintsEncoder<usize> {}
impl IpafairAcceptanceSolver for DynamicCompleteSemanticsSolverAttacks<usize> {}
impl IpafairAcceptanceSolver for DynamicStableSemanticsSolverAttacks<usize> {}

impl IpafairSolverSemantics {
fn new_acceptance_solver<'a>(&self) -> Box<dyn IpafairAcceptanceSolver + 'a> {
Expand Down
42 changes: 42 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<FactoryType> = 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<FactoryType> = 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<FactoryType> = 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());
Expand Down

0 comments on commit 473ee6e

Please sign in to comment.