123456789101112131415161718192021222324252627282930313233343536373839404142434445(** Solver, which delegates at runtime to the configured solver. *)openBatteriesopenConstrSysopenGobConfig(* Registered solvers. *)letsolvers=ref[](** Register your solvers here!!! *)letadd_solverx=solvers:=x::!solvers(** Dynamically choose the solver. *)letchoose_solversolver=tryList.assocsolver!solverswithNot_found->raise@@ConfigError("Solver '"^solver^"' not found. Abort!")(** The solver that actually uses the implementation based of [GobConfig.get_string "solver"]. *)moduleMake=functor(Arg:IncrSolverArg)->functor(S:EqConstrSys)->functor(VH:Hashtbl.Swithtypekey=S.v)->structtypemarshal=Obj.t(* cannot use Sol.marshal because cannot unpack first-class module in applicative functor *)letcopy_marshal(marshal:marshal)=letmoduleSol=(valchoose_solver(get_string"solver"):GenericEqIncrSolver)inletmoduleF=Sol(Arg)(S)(VH)inObj.repr(F.copy_marshal(Obj.objmarshal))letrelift_marshal(marshal:marshal)=letmoduleSol=(valchoose_solver(get_string"solver"):GenericEqIncrSolver)inletmoduleF=Sol(Arg)(S)(VH)inObj.repr(F.relift_marshal(Obj.objmarshal))letsolvexsvs(old_data:marshaloption)=letmoduleSol=(valchoose_solver(get_string"solver"):GenericEqIncrSolver)inletmoduleF=Sol(Arg)(S)(VH)inlet(vh,marshal)=F.solvexsvs(Option.mapObj.objold_data)in(vh,Obj.reprmarshal)endlet_=letmoduleT1:GenericEqIncrSolver=Makein()