OKlibrary  0.2.1.6
satz215.2.c File Reference

Updated and corrected version. More...

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>
#include <sys/times.h>
#include <unistd.h>

Go to the source code of this file.

Classes

struct  node
struct  ressource
struct  var_node

Defines

#define WORD_LENGTH   100
 The maximal length of words to be read (otherwise segmentation fault!)
#define TRUE   1
#define FALSE   0
#define NONE   -1
#define WEIGTH   5
#define T   10
#define EXITCODE_PARAMETER_FAILURE   100
#define EXITCODE_INPUT_ERROR   101
#define EXITCODE_VERIFICATION_FAILED   102
#define EXITCODE_SAT   10
#define EXITCODE_UNSAT   20
#define MAX_NUMBER_VARIABLES   200000
#define MAX_NUMBER_CLAUSES   800000
#define MAX_CLAUSE_LENGTH   1000
#define tab_variable_size   MAX_NUMBER_VARIABLES
#define tab_clause_size   MAX_NUMBER_CLAUSES
#define tab_unitclause_size   ((tab_clause_size/4<2000) ? 2000 : tab_clause_size/4)
#define my_tab_variable_size   ((tab_variable_size/2<1000) ? 1000 : tab_variable_size/2)
#define my_tab_clause_size   ((tab_clause_size/2<2000) ? 2000 : tab_clause_size/2)
#define my_tab_unitclause_size   ((tab_unitclause_size/2<1000) ? 1000 : tab_unitclause_size/2)
#define tab_literal_size   2*tab_variable_size
#define double_tab_clause_size   2*tab_clause_size
#define positive(literal)   literal<NB_VAR
#define negative(literal)   literal>=NB_VAR
#define get_var_from_lit(negative_literal)   negative_literal-NB_VAR
#define RESOLVANT_LENGTH   3
#define RESOLVANT_SEARCH_THRESHOLD   5000
#define complement(lit1, lit2)   ((lit1<lit2) ? lit2-lit1 == NB_VAR : lit1-lit2 == NB_VAR)
#define pop(stack)   stack[--stack ## _fill_pointer]
#define push(item, stack)   stack[stack ## _fill_pointer++] = item
#define satisfiable()   CLAUSE_STACK_fill_pointer == NB_CLAUSE
#define NEGATIVE   0
#define POSITIVE   1
#define PASSIVE   0
#define ACTIVE   1
#define MAX_NODE_NUMBER   6000
#define double_tab_clause_size   2*tab_clause_size
#define VAR_NODES1_nb   6
#define OLD_CLAUSE_REDUNDANT   77
#define NEW_CLAUSE_REDUNDANT   7
#define ACTIVE2   2

Typedefs

typedef signed int my_type
typedef unsigned int my_unsigned_type
typedef unsigned long StatisticsCount

Functions

struct nodeallocate_node ()
void free_ressources ()
struct var_nodeallocate_var_node1 ()
void remove_clauses (register int *clauses)
int manage_clauses (register int *clauses)
void simple_manage_clauses (register int *clauses)
void my_simple_manage_clauses (register int *clauses)
int my_manage_clauses (register int *clauses)
void print_values (int nb_var)
int backtracking ()
int smaller_than (int lit1, int lit2)
my_type redundant (int *new_clause, int *old_clause)
my_type get_resolvant (int *clause1, int *clause2, int *resolvant)
void remove_link (int clause)
void set_link (int clause)
void set_link_for_resolv (int resolv)
void remove_link_for_resolv (int resolv)
int already_present (int *resolvant)
int search_redundence (int *lits)
int add_resolvant (int *lits)
int * copy_clauses (struct node *node_in)
int unitclause_process ()
my_type build_sat_instance (char *const input_file)
int verify_solution ()
int get_nb_clauses (int var)
int get_resolvant_nb (int saved_managedclause_fill_pointer)
void reset_context (int saved_var_stack_fill_pointer, int saved_managedclause_fill_pointer)
int branch ()
int examine1 (int tested_var)
int examine (int tested_var)
int get_nb (int saved_managedclause_fill_pointer)
int examine2 (int tested_var)
int satisfy_literal (int lit)
int treat_implied_lits ()
int get_complement (int lit)
int insert_var_if_necessary1 (int var)
int branch1 ()
int further_examin_var_if_positive (int var)
int further_examin_var_if_negative (int var)
int further_examin (int saved_managedclause_fill_pointer)
int further_testable (const int saved_managedclause_fill_pointer)
int examine3 (const int tested_var)
int get_neg_clause_nb (const int var)
int get_pos_clause_nb (const int var)
int choose_and_instantiate_variable_in_clause ()
void reset_all ()
void dpl ()
int main (const int argc, char *const argv[])

Variables

int CLAUSE_NODES_pointer = MAX_NODE_NUMBER
struct nodeCLAUSE_NODES
struct ressourceressources = NULL
struct nodenode_neg_in [tab_variable_size]
struct nodenode_pos_in [tab_variable_size]
struct nodein_resolv [tab_literal_size]
int * neg_in [tab_variable_size]
int * pos_in [tab_variable_size]
my_type var_current_value [tab_variable_size]
my_type var_rest_value [tab_variable_size]
my_type var_state [tab_variable_size]
int saved_clause_stack [tab_variable_size]
int saved_managedclause_stack [tab_variable_size]
my_unsigned_type nb_neg_clause_of_length2 [tab_variable_size]
my_unsigned_type nb_neg_clause_of_length3 [tab_variable_size]
my_unsigned_type nb_pos_clause_of_length2 [tab_variable_size]
my_unsigned_type nb_pos_clause_of_length3 [tab_variable_size]
int reduce_if_negative_nb [tab_variable_size]
int reduce_if_positive_nb [tab_variable_size]
int * sat [tab_clause_size]
my_type clause_state [tab_clause_size]
my_type clause_length [tab_clause_size]
int VARIABLE_STACK_fill_pointer = 0
int CLAUSE_STACK_fill_pointer = 0
int UNITCLAUSE_STACK_fill_pointer = 0
int MANAGEDCLAUSE_STACK_fill_pointer = 0
int VARIABLE_STACK [tab_variable_size]
int CLAUSE_STACK [tab_clause_size]
int UNITCLAUSE_STACK [tab_unitclause_size]
int MANAGEDCLAUSE_STACK [tab_clause_size]
int TESTED_VAR_STACK [tab_variable_size]
int TESTED_VAR_STACK_fill_pointer = 0
int NB_VAR
int NB_CLAUSE
int INIT_NB_CLAUSE
my_type R = 3
StatisticsCount NB_UNIT = 0
StatisticsCount NB_MONO = 0
StatisticsCount NB_BRANCHE = 0
StatisticsCount NB_BACK = 0
int VAR_NODES1_index = 0
struct var_node VAR_NODES1 [10 *VAR_NODES1_nb]
struct var_nodeVAR_FOR_TEST1 = NULL
int test_flag [tab_variable_size]
int MAX_REDUCED
int T_SEUIL
int H_SEUIL
long NB_SECOND_SEARCH = 0
long NB_SECOND_FIXED = 0
int INVOLVED_CLAUSE_STACK [tab_clause_size]
int INVOLVED_CLAUSE_STACK_fill_pointer = 0
int CLAUSE_INVOLVED [tab_clause_size]
int OLD_CLAUSE_SUPPRESED
long NB_SEARCH = 0
long NB_FIXED = 0
int IMPLIED_LITS_fill_pointer = 0
int IMPLIED_LITS [tab_variable_size]
int LIT_IMPLIED [tab_variable_size]

Detailed Description

Updated and corrected version.

  • Safer input handling.
  • Updated output format.
  • Improved C usage, and update to C99.
  • Corrected time measurement.

Definition in file satz215.2.c.


Define Documentation

#define ACTIVE2   2

Definition at line 568 of file satz215.2.c.

Referenced by add_resolvant(), and build_sat_instance().

#define complement (   lit1,
  lit2 
)    ((lit1<lit2) ? lit2-lit1 == NB_VAR : lit1-lit2 == NB_VAR)

Definition at line 195 of file satz215.2.c.

Definition at line 195 of file satz215.2.c.

#define EXITCODE_INPUT_ERROR   101

Definition at line 61 of file satz215.2.c.

Referenced by main().

#define EXITCODE_PARAMETER_FAILURE   100

Definition at line 60 of file satz215.2.c.

Referenced by main().

#define EXITCODE_SAT   10

Definition at line 63 of file satz215.2.c.

Referenced by main().

#define EXITCODE_UNSAT   20

Definition at line 64 of file satz215.2.c.

Referenced by main().

#define EXITCODE_VERIFICATION_FAILED   102

Definition at line 62 of file satz215.2.c.

Referenced by main().

#define MAX_CLAUSE_LENGTH   1000

Definition at line 75 of file satz215.2.c.

Referenced by build_sat_instance().

#define MAX_NODE_NUMBER   6000

Definition at line 110 of file satz215.2.c.

Referenced by allocate_node().

#define MAX_NUMBER_CLAUSES   800000

Definition at line 71 of file satz215.2.c.

Referenced by build_sat_instance().

#define MAX_NUMBER_VARIABLES   200000

Definition at line 67 of file satz215.2.c.

Referenced by build_sat_instance().

#define my_tab_clause_size   ((tab_clause_size/2<2000) ? 2000 : tab_clause_size/2)

Definition at line 89 of file satz215.2.c.

Definition at line 91 of file satz215.2.c.

#define my_tab_variable_size   ((tab_variable_size/2<1000) ? 1000 : tab_variable_size/2)

Definition at line 87 of file satz215.2.c.

#define negative (   literal)    literal>=NB_VAR

Definition at line 96 of file satz215.2.c.

Referenced by get_nb(), and verify_solution().

#define NEGATIVE   0

Definition at line 106 of file satz215.2.c.

#define OLD_CLAUSE_REDUNDANT   77

Definition at line 349 of file satz215.2.c.

Referenced by redundant(), and search_redundence().

#define pop (   stack)    stack[--stack ## _fill_pointer]

Definition at line 102 of file satz215.2.c.

Referenced by backtracking().

#define POSITIVE   1

Definition at line 107 of file satz215.2.c.

#define RESOLVANT_LENGTH   3

Definition at line 98 of file satz215.2.c.

Referenced by add_resolvant(), and get_resolvant().

#define RESOLVANT_SEARCH_THRESHOLD   5000

Definition at line 99 of file satz215.2.c.

Definition at line 104 of file satz215.2.c.

Referenced by dpl(), main(), and UnitPropagation::unit_propagation_simple().

Definition at line 83 of file satz215.2.c.

Referenced by build_sat_instance().

Definition at line 93 of file satz215.2.c.

#define tab_unitclause_size   ((tab_clause_size/4<2000) ? 2000 : tab_clause_size/4)

Definition at line 85 of file satz215.2.c.

Definition at line 82 of file satz215.2.c.

#define VAR_NODES1_nb   6

Definition at line 203 of file satz215.2.c.

Referenced by insert_var_if_necessary1().

#define WEIGTH   5

Definition at line 57 of file satz215.2.c.

Referenced by get_nb_clauses(), and get_resolvant_nb().

#define WORD_LENGTH   100

The maximal length of words to be read (otherwise segmentation fault!)

Definition at line 50 of file satz215.2.c.

Referenced by build_sat_instance(), and main().


Typedef Documentation

typedef signed int my_type

Definition at line 45 of file satz215.2.c.

typedef unsigned int my_unsigned_type

Definition at line 46 of file satz215.2.c.

typedef unsigned long StatisticsCount

Definition at line 192 of file satz215.2.c.


Function Documentation

struct node* allocate_node ( ) [read]
struct var_node* allocate_var_node1 ( ) [read]

Definition at line 208 of file satz215.2.c.

References VAR_NODES1, and VAR_NODES1_index.

Referenced by insert_var_if_necessary1().

int* copy_clauses ( struct node node_in)

Definition at line 644 of file satz215.2.c.

References ACTIVE, node::clause, clause_state, node::next, and NONE.

Referenced by build_sat_instance().

void free_ressources ( )

Definition at line 140 of file satz215.2.c.

References ressource::next, ressource::pnode, and ressources.

Referenced by build_sat_instance().

int further_testable ( const int  saved_managedclause_fill_pointer)

Definition at line 1425 of file satz215.2.c.

References FALSE, MANAGEDCLAUSE_STACK_fill_pointer, MAX_REDUCED, T_SEUIL, and TRUE.

Referenced by examine3().

int get_complement ( int  lit)

Definition at line 1233 of file satz215.2.c.

References NB_VAR, and positive.

Referenced by further_examin_var_if_positive().

my_type get_resolvant ( int *  clause1,
int *  clause2,
int *  resolvant 
)

Definition at line 386 of file satz215.2.c.

References complement, FALSE, NONE, RESOLVANT_LENGTH, smaller_than(), and TRUE.

Referenced by add_resolvant().

int manage_clauses ( register int *  clauses)
int my_manage_clauses ( register int *  clauses)

Definition at line 277 of file satz215.2.c.

References ACTIVE, clause_length, clause_state, FALSE, MANAGEDCLAUSE_STACK, NONE, push, TRUE, and UNITCLAUSE_STACK.

Referenced by branch(), and branch1().

void print_values ( int  nb_var)

Definition at line 293 of file satz215.2.c.

References var_current_value.

Referenced by main().

my_type redundant ( int *  new_clause,
int *  old_clause 
)

Definition at line 357 of file satz215.2.c.

References complement, FALSE, NEW_CLAUSE_REDUNDANT, NONE, OLD_CLAUSE_REDUNDANT, and smaller_than().

Referenced by search_redundence().

void remove_link ( int  clause)

Definition at line 448 of file satz215.2.c.

References node::clause, get_var_from_lit, node::next, NONE, positive, and sat.

Referenced by already_present(), and search_redundence().

void remove_link_for_resolv ( int  resolv)

Definition at line 508 of file satz215.2.c.

References node::clause, node::next, NONE, and sat.

Referenced by already_present(), and build_sat_instance().

void set_link ( int  clause)

Definition at line 476 of file satz215.2.c.

References allocate_node(), node::clause, get_var_from_lit, node::next, NONE, positive, and sat.

Referenced by build_sat_instance().

void set_link_for_resolv ( int  resolv)

Definition at line 496 of file satz215.2.c.

References allocate_node(), node::clause, node::next, NONE, and sat.

Referenced by add_resolvant(), and build_sat_instance().

int smaller_than ( int  lit1,
int  lit2 
)

Definition at line 352 of file satz215.2.c.

References NB_VAR.

Referenced by get_resolvant(), and redundant().

int verify_solution ( )

Definition at line 793 of file satz215.2.c.

References FALSE, get_var_from_lit, NB_CLAUSE, negative, NONE, positive, sat, TRUE, and var_current_value.

Referenced by main().


Variable Documentation

Definition at line 533 of file satz215.2.c.

Referenced by already_present(), and build_sat_instance().

struct node* CLAUSE_NODES

Definition at line 124 of file satz215.2.c.

Referenced by allocate_node().

Definition at line 122 of file satz215.2.c.

Referenced by allocate_node().

Definition at line 180 of file satz215.2.c.

Referenced by backtracking(), remove_clauses(), and reset_all().

int H_SEUIL

Definition at line 216 of file satz215.2.c.

Referenced by main().

Definition at line 152 of file satz215.2.c.

Definition at line 189 of file satz215.2.c.

Referenced by build_sat_instance(), and main().

Definition at line 531 of file satz215.2.c.

Referenced by already_present(), and build_sat_instance().

Definition at line 532 of file satz215.2.c.

Referenced by already_present(), and build_sat_instance().

Definition at line 193 of file satz215.2.c.

Referenced by backtracking(), main(), and reset_all().

int NB_CLAUSE

Definition at line 188 of file satz215.2.c.

Referenced by add_resolvant(), build_sat_instance(), main(), and verify_solution().

long NB_FIXED = 0

Definition at line 813 of file satz215.2.c.

Referenced by branch(), branch1(), main(), and reset_all().

Definition at line 193 of file satz215.2.c.

Referenced by main(), reset_all(), and unitclause_process().

Definition at line 150 of file satz215.2.c.

Definition at line 151 of file satz215.2.c.

Definition at line 567 of file satz215.2.c.

Referenced by add_resolvant(), and search_redundence().

struct ressource* ressources = NULL

Definition at line 125 of file satz215.2.c.

Referenced by allocate_node(), and free_ressources().

int T_SEUIL

Definition at line 215 of file satz215.2.c.

Referenced by further_testable(), and main().

Definition at line 212 of file satz215.2.c.

Referenced by dpl(), and further_examin().

struct var_node* VAR_FOR_TEST1 = NULL

Definition at line 206 of file satz215.2.c.

Referenced by insert_var_if_necessary1().

Definition at line 205 of file satz215.2.c.

Referenced by allocate_var_node1().

Definition at line 204 of file satz215.2.c.

Referenced by allocate_var_node1(), and choose_and_instantiate_variable_in_clause().