PIPS
simp.c
Go to the documentation of this file.
1 /*
2 
3  $Id: simp.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 du simplex : ce test s'appelle par :
26  * programme fichier1.data fichier2.data ... fichiern.data
27  * ou bien : programme<fichier.data
28  * Si on compile grace a` "make sim" dans le directory
29  * /home/users/pips/C3/Linear/Development/polyedre.dir/test.dir
30  * alors on peut tester l'execution dans le meme directory
31  * en faisant : tests|more
32  */
33 
34 #ifdef HAVE_CONFIG_H
35  #include "config.h"
36 #endif
37 
38 #include <stdio.h>
39 #include <stdlib.h>
40 
41 #include "boolean.h"
42 #include "linear_assert.h"
43 #include "arithmetique.h"
44 #include "vecteur.h"
45 #include "contrainte.h"
46 #include "sc.h"
47 
48 static void
50 {
52  fprintf(stdout, "*** Arithmetic error occured in simplex\n");
53  TRY
54  if (sc_simplexe_feasibility_ofl_ctrl(sc,FWD_OFL_CTRL))
55  printf("Systeme faisable (soluble) en rationnels\n") ;
56  else
57  printf("Systeme insoluble\n");
58 }
59 
60 static void test_file(FILE * f, char * name)
61 {
62  Psysteme sc=sc_new();
63  printf("systeme initial \n");
64  if(sc_fscan(f,&sc))
65  {
66  printf("syntaxe correcte dans %s\n",name);
67  sc_fprint(stdout, sc, *variable_default_name);
68  printf("Nb_eq %d , Nb_ineq %d, dimension %d\n",
69  sc->nb_eq, sc->nb_ineq, sc->dimension) ;
70  test_system(sc);
71  }
72  else
73  {
74  fprintf(stderr,"erreur syntaxe dans %s\n",name);
75  exit(1);
76  }
77 }
78 
79 int
80 main(int argc, char *argv[])
81 {
82  /* Programme de test de faisabilite'
83  * d'un ensemble d'equations et d'inequations.
84  */
85  FILE * f1;
86  int i; /* compte les systemes, chacun dans un fichier */
87 
89 
90  /* lecture et test de la faisabilite' de systemes sur fichiers */
91 
92  if(argc>=2)
93  {
94  for(i=1;i<argc;i++)
95  {
96  if((f1 = fopen(argv[i],"r")) == NULL) {
97  fprintf(stdout,"Ouverture fichier %s impossible\n", argv[i]);
98  exit(4);
99  }
100  test_file(f1, argv[i]);
101  fclose(f1) ;
102  }
103  }
104  else
105  {
106  test_file(stdin, "standard input");
107  }
108  exit(0) ;
109 }
#define CATCH(what)
@ overflow_error
#define TRY
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
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
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 initialize_sc(char *(*var_to_string)(Variable))
Definition: sc_debug.c:253
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()
static void test_file(FILE *f, char *name)
Definition: simp.c:60
int main(int argc, char *argv[])
Definition: simp.c:80
static void test_system(Psysteme sc)
test du simplex : ce test s'appelle par : programme fichier1.data fichier2.data .....
Definition: simp.c:49
int dimension
Definition: sc-local.h:74
int nb_ineq
Definition: sc-local.h:73
int nb_eq
Definition: sc-local.h:72
#define FWD_OFL_CTRL