PIPS
sc-fais-int.c
Go to the documentation of this file.
1 /*
2 
3  $Id: sc-fais-int.c 1641 2016-03-02 08:20:19Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of Linear/C3 Library.
8 
9  Linear/C3 Library is free software: you can redistribute it and/or modify it
10  under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25  /* package plint */
26 
27 #ifdef HAVE_CONFIG_H
28  #include "config.h"
29 #endif
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 
34 #include "boolean.h"
35 #include "arithmetique.h"
36 #include "vecteur.h"
37 #include "contrainte.h"
38 #include "sc.h"
39 
40 #include "sommet.h"
41 #include "matrix.h"
42 
43 #include "plint.h"
44 
45 #define MALLOC(s,t,f) malloc(s)
46 
47 /* bool sys_int_fais(Psysteme sys1):
48  * Test de faisabilite d'un systeme lineaire syst1 en nombres entiers par
49  * l'algorithme des congruences decroissantes (cf. livre ???, pp. ??? ).
50  * Renvoie true si le systeme est satisfiable (i.e. il definit un polyedre
51  * convexe non vide), false sinon.
52  *
53  * Ce test est exact, mais il est tres couteux en temps CPU.
54  *
55  * Le systeme de contrainte syst1 n'est pas modifie
56  */
57 bool sys_int_fais(sys1)
58 Psysteme sys1;
59 {
60  Psysteme sys2 = NULL;
61  Psommet fonct = fonct_min(sys1->dimension,sys1->base);
62  Psolution sol1 = NULL;
63 
64  bool is_faisable = false;
65 
66  sys2=sc_dup(sys1);
67  /*
68  * Recherche d'une solution par l'algorithme des congruences
69  * decroissantes a partir d'une fonction economique minimale (
70  * recherche du minimum de la premiere variable du systeme)
71  */
72  if ((sys2 != NULL) &&
73  ( (sys2->egalites != NULL) || (sys2->inegalites != NULL)))
74  sys2 = plint(sys2,fonct,&sol1);
75  else
76  is_faisable = true;
77 
78  if ((sys2 != NULL) && ((sys2->egalites != NULL)
79  || (sys2->inegalites != NULL)))
80  is_faisable = true;
81 
82  if (is_faisable)
83  /* cas ou le systeme est faisable */
84  sc_rm(sys2);
85  return (is_faisable);
86 }
Psommet fonct_min(int nbvars, Pbase b)
RGSUSED.
Definition: plfonct-eco.c:78
Psysteme plint(Psysteme first_sys, Psommet fonct, Psolution *sol_fin)
Psysteme plint(Psysteme first_sys, Psommet fonct, Psolution *sol_fin): resolution d'un systeme lineai...
Definition: plint.c:430
bool sys_int_fais(Psysteme sys1)
bool sys_int_fais(Psysteme sys1): Test de faisabilite d'un systeme lineaire syst1 en nombres entiers ...
Definition: sc-fais-int.c:57
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70
structure de donnees Sommet
Definition: sommet-local.h:64