PIPS
test_env_chernikova.c
Go to the documentation of this file.
1 /*
2 
3  $Id: test_env_chernikova.c 1669 2019-06-26 17:24:57Z 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  /* Test de l'enveloppe convexe de deux systemes. L'enveloppe convexe
26  * est faite par traduction des systemes lineaires en systemes
27  * generateurs (par chernikova), puis par union des systemes
28  * generateurs, enfin par la traduction du systeme generateur
29  * resultant en systeme lineaire (toujours par chernikovva). Cette
30  * fonction utilise la bibliotheque fournie par l'IRISA. On suppose
31  * que les deux systemes fournis en entree ont la meme base */
32 
33 #ifdef HAVE_CONFIG_H
34  #include "config.h"
35 #endif
36 
37 #include <stdio.h>
38 #include <stdlib.h>
39 
40 #include "boolean.h"
41 #include "arithmetique.h"
42 #include "linear_assert.h"
43 #include "vecteur.h"
44 #include "contrainte.h"
45 #include "ray_dte.h"
46 #include "sommet.h"
47 #include "sc.h"
48 #include "sg.h"
49 #include "polyedre.h"
50 
52 {
53  FILE * f;
54  Psysteme s = sc_new();
55 
56  if((f = fopen(name,"r")) == NULL) {
57  fprintf(stderr,"Ouverture du fichier %s impossible\n",name);
58  exit(2);
59  }
60 
61  if(sc_fscan(f,&s)) {
62  fprintf(stderr,"syntaxe correcte dans %s\n",name);
63  /* sc_fprint(stderr, s, *variable_default_name); */
64  }
65  else {
66  fprintf(stderr,"erreur de syntaxe dans %s\n",name);
67  exit(3);
68  }
69 
70  return s;
71 }
72 
73 int main(int argc, char **argv)
74 {
75  Psysteme sc1, sc2, sc;
76 
77  if(argc!=3) {
78  fprintf(stdout,"Usage: %s sc1 sc2\n",argv[0]);
79  exit(1);
80  }
81 
82  sc1 = read_syst_from_file(argv[1]);
83  sc2 = read_syst_from_file(argv[2]);
84 
85  sc1 = sc_normalize(sc1);
86  sc2 = sc_normalize(sc2);
87 
88  sc_fprint(stdout, sc1, *variable_default_name);
89  sc_fprint(stdout, sc2, *variable_default_name);
90 
91  assert(vect_size(sc1->base) == vect_size(sc2->base));
92 
93  sc2 = sc_translate(sc2, sc1->base, *variable_default_name);
94  sc = sc_convex_hull(sc1,sc2);
95 
96  printf("systeme correspondant \n");
97  sc_fprint(stdout, sc, *variable_default_name);
98 
99  return 0;
100 }
101 
102 /* that is all
103  */
Psysteme sc_convex_hull(Psysteme sc1, Psysteme sc2)
Definition: chernikova.c:74
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
char * variable_default_name(Variable v)
char * variable_default_name(Variable v): returns the name of variable v
Definition: variable.c:81
#define exit(code)
Definition: misc-local.h:54
#define assert(ex)
Definition: newgen_assert.h:41
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
Psysteme sc_translate(Psysteme s, Pbase b, char *(*variable_name)())
Psysteme sc_translate(Psysteme s, Pbase b, char * (*variable_name)()): reecriture du systeme s dans l...
Definition: sc.c:99
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220
bool sc_fscan(FILE *f, Psysteme *ps)
bool sc_fscan(FILE * f, Psysteme * ps): construit un systeme d'inegalites et d'egalites lineaires a p...
Definition: sc_io.c:121
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
int printf()
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
Pbase base
Definition: sc-local.h:75
int main(int argc, char **argv)
Psysteme read_syst_from_file(char *name)
Test de l'enveloppe convexe de deux systemes.