#include "ppl.hh"
#include "pwl.hh"
#include "sicstus_cfli.h"
#include "../exceptions.hh"
#include <cassert>
#include <sstream>
#include "../ppl_prolog.icc"
Go to the source code of this file.
Defines | |
#define | SP_STUB_0(name) |
#define | SP_STUB_1(name) |
#define | SP_STUB_2(name) |
#define | SP_STUB_3(name) |
#define | SP_STUB_4(name) |
#define | SP_STUB_5(name) |
#define | SP_STUB_6(name) |
#define | SP_DEFINE_C_PREDICATE(name, arity) SP_define_c_predicate(#name, arity, "user", sp_stub_##name, NULL) |
Functions | |
void | ppl_Prolog_sysdep_init () |
void | ppl_Prolog_sysdep_deinit () |
PPL::Coefficient | integer_term_to_Coefficient (Prolog_term_ref t) |
Prolog_term_ref | Coefficient_to_integer_term (const PPL::Coefficient &n) |
void | ppl_sicstus_init (int) |
void | ppl_sicstus_deinit (int) |
Variables | |
bool | Prolog_has_unbounded_integers |
long | Prolog_min_integer |
long | Prolog_max_integer |
#define SP_STUB_0 | ( | name | ) |
Value:
extern "C" Prolog_foreign_return_type \ sp_stub_##name(Prolog_term_ref /* goal */, void*) { \ return name(); \ }
Definition at line 105 of file ppl_sicstus_sd.cc.
#define SP_STUB_1 | ( | name | ) |
Definition at line 111 of file ppl_sicstus_sd.cc.
#define SP_STUB_2 | ( | name | ) |
Definition at line 120 of file ppl_sicstus_sd.cc.
#define SP_STUB_3 | ( | name | ) |
Definition at line 132 of file ppl_sicstus_sd.cc.
#define SP_STUB_4 | ( | name | ) |
Definition at line 147 of file ppl_sicstus_sd.cc.
#define SP_STUB_5 | ( | name | ) |
Definition at line 165 of file ppl_sicstus_sd.cc.
#define SP_STUB_6 | ( | name | ) |
Definition at line 186 of file ppl_sicstus_sd.cc.
Prolog_term_ref @201::Coefficient_to_integer_term | ( | const PPL::Coefficient & | n | ) | [static] |
Definition at line 86 of file ppl_sicstus_sd.cc.
References Parma_Polyhedra_Library::assign_r(), and Prolog_new_term_ref().
00086 { 00087 Prolog_term_ref t = Prolog_new_term_ref(); 00088 long l = 0; 00089 if (PPL::assign_r(l, n, PPL::ROUND_NOT_NEEDED) == PPL::V_EQ) { 00090 if (SP_put_integer(t, l) == 0) 00091 throw unknown_interface_error("Coefficient_to_integer_term()"); 00092 } else { 00093 std::ostringstream s; 00094 s << n; 00095 if (SP_put_number_chars(t, s.str().c_str()) == 0) 00096 throw unknown_interface_error("Coefficient_to_integer_term()"); 00097 } 00098 return t; 00099 }
PPL::Coefficient @201::integer_term_to_Coefficient | ( | Prolog_term_ref | t | ) | [static] |
Definition at line 71 of file ppl_sicstus_sd.cc.
00071 { 00072 assert(SP_is_integer(t)); 00073 long v; 00074 if (SP_get_integer(t, &v) != 0) 00075 return PPL::Coefficient(v); 00076 else { 00077 char* s; 00078 if (SP_get_number_chars(t, &s) != 0) 00079 return PPL::Coefficient(s); 00080 else 00081 throw unknown_interface_error("integer_term_to_Coefficient"); 00082 } 00083 }
void @201::ppl_Prolog_sysdep_deinit | ( | ) | [static] |
void @201::ppl_Prolog_sysdep_init | ( | ) | [static] |
Performs system-dependent initialization.
Definition at line 57 of file ppl_sicstus_sd.cc.
References Prolog_has_unbounded_integers, Prolog_max_integer, and Prolog_min_integer.
00057 { 00058 Prolog_has_unbounded_integers = true; 00059 Prolog_min_integer = 0; 00060 Prolog_max_integer = 0; 00061 }
void ppl_sicstus_deinit | ( | int | ) |
Definition at line 468 of file ppl_sicstus_sd.cc.
References p_atom, ppl_finalize(), and prolog_atoms.
00468 { 00469 for (size_t i = 0; i < sizeof(prolog_atoms)/sizeof(prolog_atoms[0]); ++i) 00470 // SP_unregister_atom can fail. 00471 // We ignore such failures: what else can we do? 00472 (void) SP_unregister_atom(*prolog_atoms[i].p_atom); 00473 ppl_finalize(); 00474 }
void ppl_sicstus_init | ( | int | ) |
Definition at line 333 of file ppl_sicstus_sd.cc.
References p_atom, ppl_banner(), ppl_Coefficient_is_bounded(), ppl_Coefficient_max(), ppl_Coefficient_min(), ppl_delete_LP_Problem(), ppl_delete_Polyhedron(), ppl_finalize(), ppl_initialize(), ppl_LP_Problem_add_constraint(), ppl_LP_Problem_add_constraints(), ppl_LP_Problem_clear(), ppl_LP_Problem_constraints(), ppl_LP_Problem_evaluate_objective_function(), ppl_LP_Problem_feasible_point(), ppl_LP_Problem_is_satisfiable(), ppl_LP_Problem_objective_function(), ppl_LP_Problem_OK(), ppl_LP_Problem_optimal_value(), ppl_LP_Problem_optimization_mode(), ppl_LP_Problem_optimizing_point(), ppl_LP_Problem_set_objective_function(), ppl_LP_Problem_set_optimization_mode(), ppl_LP_Problem_solve(), ppl_LP_Problem_space_dimension(), ppl_LP_Problem_swap(), ppl_max_space_dimension(), ppl_new_C_Polyhedron_from_bounding_box(), ppl_new_C_Polyhedron_from_C_Polyhedron(), ppl_new_C_Polyhedron_from_constraints(), ppl_new_C_Polyhedron_from_generators(), ppl_new_C_Polyhedron_from_NNC_Polyhedron(), ppl_new_C_Polyhedron_from_space_dimension(), ppl_new_LP_Problem(), ppl_new_LP_Problem_from_LP_Problem(), ppl_new_LP_Problem_trivial(), ppl_new_NNC_Polyhedron_from_bounding_box(), ppl_new_NNC_Polyhedron_from_C_Polyhedron(), ppl_new_NNC_Polyhedron_from_constraints(), ppl_new_NNC_Polyhedron_from_generators(), ppl_new_NNC_Polyhedron_from_NNC_Polyhedron(), ppl_new_NNC_Polyhedron_from_space_dimension(), ppl_Polyhedron_add_constraint(), ppl_Polyhedron_add_constraint_and_minimize(), ppl_Polyhedron_add_constraints(), ppl_Polyhedron_add_constraints_and_minimize(), ppl_Polyhedron_add_generator(), ppl_Polyhedron_add_generator_and_minimize(), ppl_Polyhedron_add_generators(), ppl_Polyhedron_add_generators_and_minimize(), ppl_Polyhedron_add_space_dimensions_and_embed(), ppl_Polyhedron_add_space_dimensions_and_project(), ppl_Polyhedron_affine_dimension(), ppl_Polyhedron_affine_image(), ppl_Polyhedron_affine_preimage(), ppl_Polyhedron_BHRZ03_widening_assign(), ppl_Polyhedron_BHRZ03_widening_assign_with_tokens(), ppl_Polyhedron_bounded_affine_image(), ppl_Polyhedron_bounded_affine_preimage(), ppl_Polyhedron_bounded_BHRZ03_extrapolation_assign(), ppl_Polyhedron_bounded_BHRZ03_extrapolation_assign_with_tokens(), ppl_Polyhedron_bounded_H79_extrapolation_assign(), ppl_Polyhedron_bounded_H79_extrapolation_assign_with_tokens(), ppl_Polyhedron_bounds_from_above(), ppl_Polyhedron_bounds_from_below(), ppl_Polyhedron_concatenate_assign(), ppl_Polyhedron_contains_Polyhedron(), ppl_Polyhedron_equals_Polyhedron(), ppl_Polyhedron_expand_space_dimension(), ppl_Polyhedron_fold_space_dimensions(), ppl_Polyhedron_generalized_affine_image(), ppl_Polyhedron_generalized_affine_image_lhs_rhs(), ppl_Polyhedron_generalized_affine_preimage(), ppl_Polyhedron_generalized_affine_preimage_lhs_rhs(), ppl_Polyhedron_get_bounding_box(), ppl_Polyhedron_get_constraints(), ppl_Polyhedron_get_generators(), ppl_Polyhedron_get_minimized_constraints(), ppl_Polyhedron_get_minimized_generators(), ppl_Polyhedron_H79_widening_assign(), ppl_Polyhedron_H79_widening_assign_with_tokens(), ppl_Polyhedron_intersection_assign(), ppl_Polyhedron_intersection_assign_and_minimize(), ppl_Polyhedron_is_bounded(), ppl_Polyhedron_is_disjoint_from_Polyhedron(), ppl_Polyhedron_is_empty(), ppl_Polyhedron_is_topologically_closed(), ppl_Polyhedron_is_universe(), ppl_Polyhedron_limited_BHRZ03_extrapolation_assign(), ppl_Polyhedron_limited_BHRZ03_extrapolation_assign_with_tokens(), ppl_Polyhedron_limited_H79_extrapolation_assign(), ppl_Polyhedron_limited_H79_extrapolation_assign_with_tokens(), ppl_Polyhedron_map_space_dimensions(), ppl_Polyhedron_maximize(), ppl_Polyhedron_maximize_with_point(), ppl_Polyhedron_minimize(), ppl_Polyhedron_minimize_with_point(), ppl_Polyhedron_OK(), ppl_Polyhedron_poly_difference_assign(), ppl_Polyhedron_poly_hull_assign(), ppl_Polyhedron_poly_hull_assign_and_minimize(), ppl_Polyhedron_relation_with_constraint(), ppl_Polyhedron_relation_with_generator(), ppl_Polyhedron_remove_higher_space_dimensions(), ppl_Polyhedron_remove_space_dimensions(), ppl_Polyhedron_space_dimension(), ppl_Polyhedron_strictly_contains_Polyhedron(), ppl_Polyhedron_swap(), ppl_Polyhedron_time_elapse_assign(), ppl_Polyhedron_topological_closure_assign(), ppl_reset_timeout(), ppl_set_timeout(), ppl_set_timeout_exception_atom(), ppl_timeout_exception_atom(), ppl_version(), ppl_version_beta(), ppl_version_major(), ppl_version_minor(), ppl_version_revision(), prolog_atoms, Prolog_new_term_ref(), Prolog_put_atom_chars(), Prolog_raise_exception(), and SP_DEFINE_C_PREDICATE.
00333 { 00334 ppl_initialize(); 00335 for (size_t i = 0; i < sizeof(prolog_atoms)/sizeof(prolog_atoms[0]); ++i) { 00336 if (SP_register_atom(*prolog_atoms[i].p_atom) == 0) { 00337 Prolog_term_ref et = Prolog_new_term_ref(); 00338 Prolog_put_atom_chars(et, "Cannot initialize the PPL interface"); 00339 Prolog_raise_exception(et); 00340 return; 00341 } 00342 } 00343 SP_DEFINE_C_PREDICATE(ppl_version_major, 1); 00344 SP_DEFINE_C_PREDICATE(ppl_version_minor, 1); 00345 SP_DEFINE_C_PREDICATE(ppl_version_revision, 1); 00346 SP_DEFINE_C_PREDICATE(ppl_version_beta, 1); 00347 SP_DEFINE_C_PREDICATE(ppl_version, 1); 00348 SP_DEFINE_C_PREDICATE(ppl_banner, 1); 00349 SP_DEFINE_C_PREDICATE(ppl_max_space_dimension, 1); 00350 SP_DEFINE_C_PREDICATE(ppl_Coefficient_is_bounded, 0); 00351 SP_DEFINE_C_PREDICATE(ppl_Coefficient_max, 1); 00352 SP_DEFINE_C_PREDICATE(ppl_Coefficient_min, 1); 00353 SP_DEFINE_C_PREDICATE(ppl_initialize, 0); 00354 SP_DEFINE_C_PREDICATE(ppl_finalize, 0); 00355 SP_DEFINE_C_PREDICATE(ppl_set_timeout_exception_atom, 1); 00356 SP_DEFINE_C_PREDICATE(ppl_timeout_exception_atom, 1); 00357 SP_DEFINE_C_PREDICATE(ppl_set_timeout, 1); 00358 SP_DEFINE_C_PREDICATE(ppl_reset_timeout, 0); 00359 SP_DEFINE_C_PREDICATE(ppl_new_C_Polyhedron_from_space_dimension, 3); 00360 SP_DEFINE_C_PREDICATE(ppl_new_NNC_Polyhedron_from_space_dimension, 3); 00361 SP_DEFINE_C_PREDICATE(ppl_new_C_Polyhedron_from_C_Polyhedron, 2); 00362 SP_DEFINE_C_PREDICATE(ppl_new_C_Polyhedron_from_NNC_Polyhedron, 2); 00363 SP_DEFINE_C_PREDICATE(ppl_new_NNC_Polyhedron_from_C_Polyhedron, 2); 00364 SP_DEFINE_C_PREDICATE(ppl_new_NNC_Polyhedron_from_NNC_Polyhedron, 2); 00365 SP_DEFINE_C_PREDICATE(ppl_new_C_Polyhedron_from_constraints, 2); 00366 SP_DEFINE_C_PREDICATE(ppl_new_NNC_Polyhedron_from_constraints, 2); 00367 SP_DEFINE_C_PREDICATE(ppl_new_C_Polyhedron_from_generators, 2); 00368 SP_DEFINE_C_PREDICATE(ppl_new_NNC_Polyhedron_from_generators, 2); 00369 SP_DEFINE_C_PREDICATE(ppl_new_C_Polyhedron_from_bounding_box, 2); 00370 SP_DEFINE_C_PREDICATE(ppl_new_NNC_Polyhedron_from_bounding_box, 2); 00371 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_swap, 2); 00372 SP_DEFINE_C_PREDICATE(ppl_delete_Polyhedron, 1); 00373 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_space_dimension, 2); 00374 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_affine_dimension, 2); 00375 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_get_constraints, 2); 00376 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_get_minimized_constraints, 2); 00377 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_get_generators, 2); 00378 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_get_minimized_generators, 2); 00379 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_relation_with_constraint, 3); 00380 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_relation_with_generator, 3); 00381 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_get_bounding_box, 3); 00382 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_is_empty, 1); 00383 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_is_universe, 1); 00384 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_is_bounded, 1); 00385 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_bounds_from_above, 2); 00386 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_bounds_from_below, 2); 00387 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_maximize, 5); 00388 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_maximize_with_point, 6); 00389 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_minimize, 5); 00390 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_minimize_with_point, 6); 00391 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_is_topologically_closed, 1); 00392 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_contains_Polyhedron, 2); 00393 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_strictly_contains_Polyhedron, 2); 00394 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_is_disjoint_from_Polyhedron, 2); 00395 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_equals_Polyhedron, 2); 00396 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_OK, 1); 00397 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_constraint, 2); 00398 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_constraint_and_minimize, 2); 00399 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_generator, 2); 00400 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_generator_and_minimize, 2); 00401 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_constraints, 2); 00402 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_constraints_and_minimize, 2); 00403 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_generators, 2); 00404 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_generators_and_minimize, 2); 00405 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_intersection_assign, 2); 00406 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_intersection_assign_and_minimize, 2); 00407 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_poly_hull_assign, 2); 00408 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_poly_hull_assign_and_minimize, 2); 00409 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_poly_difference_assign, 2); 00410 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_affine_image, 4); 00411 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_affine_preimage, 4); 00412 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_bounded_affine_image, 5); 00413 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_bounded_affine_preimage, 5); 00414 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_generalized_affine_image, 5); 00415 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_generalized_affine_preimage, 5); 00416 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_generalized_affine_image_lhs_rhs, 4); 00417 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_generalized_affine_preimage_lhs_rhs, 4); 00418 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_time_elapse_assign, 2); 00419 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_topological_closure_assign, 1); 00420 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_BHRZ03_widening_assign_with_tokens, 4); 00421 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_BHRZ03_widening_assign, 2); 00422 SP_DEFINE_C_PREDICATE( 00423 ppl_Polyhedron_limited_BHRZ03_extrapolation_assign_with_tokens, 5); 00424 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_limited_BHRZ03_extrapolation_assign, 3); 00425 SP_DEFINE_C_PREDICATE( 00426 ppl_Polyhedron_bounded_BHRZ03_extrapolation_assign_with_tokens, 5); 00427 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_bounded_BHRZ03_extrapolation_assign, 3); 00428 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_H79_widening_assign_with_tokens, 4); 00429 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_H79_widening_assign, 2); 00430 SP_DEFINE_C_PREDICATE( 00431 ppl_Polyhedron_limited_H79_extrapolation_assign_with_tokens, 5); 00432 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_limited_H79_extrapolation_assign, 3); 00433 SP_DEFINE_C_PREDICATE( 00434 ppl_Polyhedron_bounded_H79_extrapolation_assign_with_tokens, 5); 00435 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_bounded_H79_extrapolation_assign, 3); 00436 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_space_dimensions_and_project, 2); 00437 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_add_space_dimensions_and_embed, 2); 00438 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_concatenate_assign, 2); 00439 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_remove_space_dimensions, 2); 00440 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_remove_higher_space_dimensions, 2); 00441 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_expand_space_dimension, 3); 00442 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_fold_space_dimensions, 3); 00443 SP_DEFINE_C_PREDICATE(ppl_Polyhedron_map_space_dimensions, 2); 00444 SP_DEFINE_C_PREDICATE(ppl_new_LP_Problem_trivial, 1); 00445 SP_DEFINE_C_PREDICATE(ppl_new_LP_Problem, 4); 00446 SP_DEFINE_C_PREDICATE(ppl_new_LP_Problem_from_LP_Problem, 2); 00447 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_swap, 2); 00448 SP_DEFINE_C_PREDICATE(ppl_delete_LP_Problem, 1); 00449 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_space_dimension, 2); 00450 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_constraints, 2); 00451 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_objective_function, 2); 00452 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_optimization_mode, 2); 00453 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_clear, 1); 00454 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_add_constraint, 2); 00455 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_add_constraints, 2); 00456 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_set_objective_function, 2); 00457 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_set_optimization_mode, 2); 00458 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_is_satisfiable, 1); 00459 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_solve, 2); 00460 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_feasible_point, 2); 00461 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_optimizing_point, 2); 00462 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_optimal_value, 3); 00463 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_evaluate_objective_function, 4); 00464 SP_DEFINE_C_PREDICATE(ppl_LP_Problem_OK, 1); 00465 }
bool Prolog_has_unbounded_integers [static] |
True if and only if the Prolog engine supports unbounded integers.
Definition at line 37 of file ppl_sicstus_sd.cc.
long Prolog_max_integer [static] |
If Prolog_has_unbounded_integers
is false, holds the maximum integer value representable by a Prolog integer. Holds zero otherwise.
Definition at line 51 of file ppl_sicstus_sd.cc.
long Prolog_min_integer [static] |
If Prolog_has_unbounded_integers
is false, holds the minimum integer value representable by a Prolog integer. Holds zero otherwise.
Definition at line 44 of file ppl_sicstus_sd.cc.