PIPS
pip.c File Reference
#include <setjmp.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "genC.h"
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "sc.h"
#include "polyedre.h"
#include "matrix.h"
#include "ri.h"
#include "constants.h"
#include "ri-util.h"
#include "misc.h"
#include "bootstrap.h"
#include "complexity_ri.h"
#include "database.h"
#include "graph.h"
#include "dg.h"
#include "paf_ri.h"
#include "parser_private.h"
#include "property.h"
#include "reduction.h"
#include "text.h"
#include "paf-util.h"
#include "pip.h"
+ Include dependency graph for pip.c:

Go to the source code of this file.

Macros

#define PIP_BIN   "pip4"
 Name : pip.c Package : pip Author : F. More...
 
#define PIP_OPTION   "-s"
 
#define PIP_IN_FILE   "pip_in"
 
#define PIP_OUT_FILE   "pip_out"
 
#define INLENGTH   1024
 Variables for the direct call to PIP version. More...
 

Functions

quast pip_solve_min_with_big (Psysteme ps_dep, Psysteme ps_context, Pvecteur pv_unknowns, char *big)
 ========================================================================== More...
 
Pvecteur vect_add_first (Pvecteur pv1, Pvecteur pv2)
 ====================================================================== More...
 
quast pip_solve (Psysteme ps_dep, Psysteme ps_context, Pvecteur pv_unknowns, int int_or_rat, int min_or_max)
 ========================================================================== More...
 
quast pip_integer_min (Psysteme ps_dep, Psysteme ps_context, Pvecteur pv_unknowns)
 ================================================================== More...
 
quast pip_integer_max (Psysteme ps_dep, Psysteme ps_context, Pvecteur pv_unknowns)
 ================================================================== More...
 
quast pip_rational_min (Psysteme ps_dep, Psysteme ps_context, Pvecteur pv_unknowns)
 ================================================================== More...
 
quast pip_rational_max (Psysteme ps_dep, Psysteme ps_context, Pvecteur pv_unknowns)
 ================================================================== More...
 
static int compare_variables_in_base (Pvecteur *pv1, Pvecteur *pv2)
 function for qsort. More...
 
void sort_psysteme (Psysteme ps, Pvecteur pv)
 ================================================================== More...
 

Variables

long int cross_product
 
long int limit
 
int allocation
 External variables for direct call to PIP. More...
 
int comptage
 
char inbuff [INLENGTH]
 
int inptr = 256
 
int proviso = 0
 
int verbose = 0
 
FILE * dump = NULL
 Should not be used : put here for Pip copatibility. More...
 
char dump_name [] = "XXXXXX"
 
quast quast_act
 Global variables
More...
 
Pbase base_var_ref
 Tag for MIN or MAX resolution. More...
 
Pbase base_ref
 Base of the unknowns. More...
 
Pbase old_base
 Base of the parameters. More...
 
Pbase old_base_var
 Base of the unknowns. More...
 
int ind_min_max
 
static Pbase base_for_sort = (Pbase)NULL
 ================================================================== More...
 

Macro Definition Documentation

◆ INLENGTH

#define INLENGTH   1024

Variables for the direct call to PIP version.

Definition at line 90 of file pip.c.

◆ PIP_BIN

#define PIP_BIN   "pip4"

Name : pip.c Package : pip Author : F.

Dumontet, A. Platonoff and A. Leservot Date : 30 july 1993 Historic :

  • 16 nov 93, few changes (e.g. "test1" to "pip_in", etc.), AP
  • 08 dec 93, creation of a new package named pip.
  • 10 dec 93, new version of pip_solve : direct call to pip. AL
  • 31 jul 95, cleaning, pip_solve_min, pip_solve_max, old_pip_solve, old2_pip_solve, AP

Documents: Comments : file containing the functions that resolve a Parametric Integer Programming problem with the PIP solver. Ansi includes
Newgen includes
C3 includes
Pips includes
Macros and functions Used by the old_pip_solve version

Definition at line 84 of file pip.c.

◆ PIP_IN_FILE

#define PIP_IN_FILE   "pip_in"

Definition at line 86 of file pip.c.

◆ PIP_OPTION

#define PIP_OPTION   "-s"

Definition at line 85 of file pip.c.

◆ PIP_OUT_FILE

#define PIP_OUT_FILE   "pip_out"

Definition at line 87 of file pip.c.

Function Documentation

◆ compare_variables_in_base()

static int compare_variables_in_base ( Pvecteur pv1,
Pvecteur pv2 
)
static

function for qsort.

rank_of_variable returns 0 for TCST, hence the strange return

TCST must be last, but given as 0

Definition at line 700 of file pip.c.

702 {
703  int
704  rank_1 = rank_of_variable(base_for_sort, var_of(*pv1)),
705  rank_2 = rank_of_variable(base_for_sort, var_of(*pv2));
706 
707  message_assert("variable not in global vector", rank_1>=0 && rank_2>=0);
708 
709  /* TCST must be last, but given as 0
710  */
711  return((rank_1==0 || rank_2==0) ? rank_1-rank_2 : rank_2-rank_1);
712 }
int rank_of_variable(Pbase base, Variable var)
this function returns the rank of the variable var in the base 0 encodes TCST, but I do not know why,...
Definition: base.c:497
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
static Pbase base_for_sort
==================================================================
Definition: pip.c:695
#define var_of(varval)

References base_for_sort, message_assert, rank_of_variable(), and var_of.

Referenced by sort_psysteme().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pip_integer_max()

quast pip_integer_max ( Psysteme  ps_dep,
Psysteme  ps_context,
Pvecteur  pv_unknowns 
)

==================================================================

Definition at line 637 of file pip.c.

640 {
641  return( pip_solve( ps_dep, ps_context, pv_unknowns,
643 }
#define PIP_SOLVE_MAX
#define PIP_SOLVE_INTEGER
Definition: pip-local.h:27
quast pip_solve(Psysteme ps_dep, Psysteme ps_context, Pvecteur pv_unknowns, int int_or_rat, int min_or_max)
==========================================================================
Definition: pip.c:503

References pip_solve(), PIP_SOLVE_INTEGER, and PIP_SOLVE_MAX.

Referenced by adg_dataflowgraph(), and adg_dataflowgraph_with_extremities().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pip_integer_min()

quast pip_integer_min ( Psysteme  ps_dep,
Psysteme  ps_context,
Pvecteur  pv_unknowns 
)

==================================================================

Definition at line 628 of file pip.c.

631 {
632  return( pip_solve( ps_dep, ps_context, pv_unknowns,
634 }
#define PIP_SOLVE_MIN

References pip_solve(), PIP_SOLVE_INTEGER, and PIP_SOLVE_MIN.

Referenced by valuer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pip_rational_max()

quast pip_rational_max ( Psysteme  ps_dep,
Psysteme  ps_context,
Pvecteur  pv_unknowns 
)

==================================================================

Definition at line 655 of file pip.c.

658 {
659  return( pip_solve( ps_dep, ps_context, pv_unknowns,
661 }
#define PIP_SOLVE_RATIONAL
Definition: pip-local.h:28

References pip_solve(), PIP_SOLVE_MAX, and PIP_SOLVE_RATIONAL.

+ Here is the call graph for this function:

◆ pip_rational_min()

quast pip_rational_min ( Psysteme  ps_dep,
Psysteme  ps_context,
Pvecteur  pv_unknowns 
)

==================================================================

Definition at line 646 of file pip.c.

649 {
650  return( pip_solve( ps_dep, ps_context, pv_unknowns,
652 }

References pip_solve(), PIP_SOLVE_MIN, and PIP_SOLVE_RATIONAL.

+ Here is the call graph for this function:

◆ pip_solve()

quast pip_solve ( Psysteme  ps_dep,
Psysteme  ps_context,
Pvecteur  pv_unknowns,
int  int_or_rat,
int  min_or_max 
)

==========================================================================

quast pip_solve(Psysteme ps_dep, ps_context, Pvecteur pv_unknowns, int int_or_rat, int min_or_max): Pip resolution. AL 6/12/93

Parameters: ps_dep: system of constraints on the unknowns (and parameters) ps_context: system of constraints on the parameters pv_unknowns: ordered vector of unknowns in "ps_dep" int_or_rat: integer (1) or rational (0) resolution. min_or_max: tag for min or max resolution

Result: a quast giving the value of the unknowns

Call to PIP is direct : no input or output file are produced.

FD variables

Pip variables

Initialization

trace file

Normalize base of system ps_dep

We set the env for the kind of resolution desired (Min or Max)

Computation of the basis (unknowns and parameters) base of ps_dep is the reference for all unknowns and parameters.

Total base of ps_dep

Set PIP variables. Comes from ecrit_probleme2

Prepare to call PIP

Verification de la non vacuite du contexte

We read solution and put it in global quast_act

Definition at line 503 of file pip.c.

507 {
508  /* FD variables */
509  int infinite_num, nb_unknowns;
510 
511  /* Pip variables */
512  int q, bigparm, ni, nvar, nq, non_vide, nparm, nc, p, xq;
513  char* g;
514  Tableau *ineq, *context, *ctxt;
515 
516 
517  /* Initialization */
518  debug_on("PIP_DEBUG_LEVEL");
519  debug(5, "pip_solve", "begin\n");
520  if (ps_dep == NULL) {
521  user_warning("new_pip_solve", "\nInput Psysteme is empty !\n");
522  return quast_undefined;
523  }
524  nb_unknowns = vect_size( pv_unknowns );
525 
526  /* trace file */
527  if (get_debug_level()>4) {
528  debug(5, "pip_solve", "Input Psysteme:\n");
529  fprint_psysteme( stderr, ps_dep );
530  debug(5, "pip_solve", "Input Context:\n");
531  fprint_psysteme( stderr, ps_context );
532  fprintf(stderr, "Number of variables : %d\n", nb_unknowns);
533  }
534 
535 
536  /* Normalize base of system ps_dep */
537  pv_unknowns = base_normalize( pv_unknowns );
538  vect_erase_var( &ps_dep->base, TCST );
539  ps_dep->base = vect_add_first(pv_unknowns, ps_dep->base);
540  ps_dep->dimension = vect_size( ps_dep->base );
541 
542 
543  /* We set the env for the kind of resolution desired (Min or Max) */
544  if(min_or_max == PIP_SOLVE_MIN) {
545  ind_min_max = 0;
546  infinite_num = -1;
547  }
548  else {
549  ps_dep = converti_psysmin_psysmax(ps_dep, nb_unknowns);
550  ind_min_max = 1;
551  infinite_num = vect_size((ps_dep)->base);
552  }
553 
554  /* Computation of the basis (unknowns and parameters)
555  * base of ps_dep is the reference for all unknowns and parameters.
556  */
557  if (ps_context != NULL) {
558  vect_erase_var( &ps_context->base, TCST);
559  ps_context->dimension = vect_size( ps_context->base );
560  base_var_ref = base_union( ps_dep->base, ps_context->base );
561  }
562  else base_var_ref = ps_dep->base;
563  base_var_ref = vect_add_first(pv_unknowns, base_var_ref);
564  base_ref = vect_substract(base_var_ref, pv_unknowns);
565 
566  old_base_var = base_dup(base_var_ref); /* Total base of ps_dep */
568 
569  if(! SC_EMPTY_P(ps_context) ) {
570  ps_context->base = base_dup(base_ref);
571  ps_context->dimension = vect_size( base_ref );
572  }
573 
574  /* Set PIP variables. Comes from ecrit_probleme2 */
575  nvar = nb_unknowns;
576  nparm = ps_dep->dimension - nb_unknowns;
577  ni = (ps_dep->nb_eq * 2) + ps_dep->nb_ineq;;
578  nc = ((ps_context == NULL)? 0 :
579  (ps_context->nb_eq * 2) + ps_context->nb_ineq );
580  bigparm = infinite_num;
581  nq = int_or_rat;
582  debug(5, "pip_solve", "%d %d %d %d %d %d\n",
583  nvar, nparm, ni, nc, bigparm, nq );
584 
585  /* Prepare to call PIP */
586  limit = 0L;
587  sol_init();
588  tab_init();
589  cross_product = 0;
590  g = tab_hwm();
591  ineq = sc_to_tableau(ps_dep, nb_unknowns);
592  if (ps_context != NULL) {
593  context = sc_to_tableau(ps_context, 0);
594  }
595  else context = NULL;
596  xq = p = sol_hwm();
597 
598  /* Verification de la non vacuite du contexte */
599  if (nc) {
600  ctxt = expanser(context, nparm, nc, nparm+1, nparm, 0, 0);
601  traiter( ctxt, NULL, nq, UN, nparm, 0, nc, 0, -1 );
602  non_vide = is_not_Nil(p);
603  sol_reset(p);
604  }
605  else non_vide = True;
606  if ( non_vide ) {
607  traiter( ineq, context, nq, UN, nvar, nparm, ni, nc, bigparm );
608  q = sol_hwm();
609  init_new_base();
610  /* We read solution and put it in global quast_act */
611  if( int_or_rat == PIP_SOLVE_INTEGER )
612  while((xq = integer_sol_edit(xq)) != q);
613  else while((xq = rational_sol_edit(xq)) != q);
614  sol_reset(p);
615  }
616  else quast_act = quast_undefined;
617  tab_reset(g);
618 
619  if (get_debug_level()>5) {
620  imprime_quast( stderr, quast_act );
621  }
622  debug_off();
623  return(quast_act);
624 }
Pbase base_normalize(Pbase b)
Definition: base.c:594
Pbase base_union(Pbase b1, Pbase b2)
Pbase base_union(Pbase b1, Pbase b2): compute a new basis containing all elements of b1 and all eleme...
Definition: base.c:428
bdt base
Current expression.
Definition: bdt_read_paf.c:100
Tableau * expanser()
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
#define user_warning(fn,...)
Definition: misc-local.h:262
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
void imprime_quast(FILE *, quast)
===========================================================================
Definition: print.c:514
void fprint_psysteme(FILE *, Psysteme)
===========================================================================
Definition: print.c:302
#define quast_undefined
Definition: paf_ri.h:603
Pvecteur vect_add_first(Pvecteur pv1, Pvecteur pv2)
======================================================================
Definition: pip.c:470
Pbase old_base
Base of the parameters.
Definition: pip.c:102
Pbase base_ref
Base of the unknowns.
Definition: pip.c:102
int ind_min_max
Definition: pip.c:103
long int limit
Definition: pip.c:91
Pbase old_base_var
Base of the unknowns.
Definition: pip.c:102
quast quast_act
Global variables
Definition: pip.c:101
Pbase base_var_ref
Tag for MIN or MAX resolution.
Definition: pip.c:102
long int cross_product
Definition: pip.c:91
int sol_hwm()
Definition: sol.c:75
void sol_reset()
int is_not_Nil()
void sol_init()
Definition: sol.c:70
void tab_init()
Definition: tab.c:77
char * tab_hwm()
Definition: tab.c:92
void tab_reset()
#define UN
Definition: pip__type.h:26
#define True
Definition: pip__type.h:32
int integer_sol_edit(int i)
Useful for the sorting of the variables in the system's Pvecteur.
int rational_sol_edit(int i)
==========================================================================
Tableau * sc_to_tableau(Psysteme in_ps, int nb_var)
==========================================================================
Psysteme converti_psysmin_psysmax(Psysteme p_systmin, int nb_var)
Name: converti_psysmin_psysmax
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
void init_new_base()
Name: init_new_base.
Definition: solpip.c:601
Definition: pip__tab.h:30
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74
int nb_ineq
Definition: sc-local.h:73
int nb_eq
Definition: sc-local.h:72
Definition: pip__tab.h:48
Definition: delay.c:253
void traiter()
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
Pbase base_dup(Pbase b)
Pbase base_dup(Pbase b) Note: this function changes the value of the pointer.
Definition: alloc.c:268
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
Definition: binaires.c:75
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
Definition: unaires.c:106

References base, base_dup(), base_normalize(), base_ref, base_union(), base_var_ref, converti_psysmin_psysmax(), cross_product, debug(), debug_off, debug_on, expanser(), fprint_psysteme(), fprintf(), get_debug_level(), imprime_quast(), ind_min_max, init_new_base(), integer_sol_edit(), is_not_Nil(), limit, old_base, old_base_var, PIP_SOLVE_INTEGER, PIP_SOLVE_MIN, quast_act, quast_undefined, rational_sol_edit(), sc_to_tableau(), sol_hwm(), sol_init(), sol_reset(), tab_hwm(), tab_init(), tab_reset(), TCST, traiter(), True, UN, user_warning, vect_add_first(), vect_erase_var(), vect_size(), and vect_substract().

Referenced by pip_integer_max(), pip_integer_min(), pip_rational_max(), and pip_rational_min().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pip_solve_min_with_big()

quast pip_solve_min_with_big ( Psysteme  ps_dep,
Psysteme  ps_context,
Pvecteur  pv_unknowns,
char *  big 
)

==========================================================================

quast old_pip_solve(Psysteme ps_dep, ps_context, int nb_unknowns, int min_or_max): Pip resolution.

Parameters: ps_dep: system of constraints on the unknowns (and parameters) ps_context: system of constraints on the parameters nb_unknowns: number of unknowns in "ps_dep" min_or_max: tag for min or max resolution

Result: a quast giving the value of the unknowns

Note: The basis of "ps_dep" must contain all the unknowns and the parameters, with first the unknowns in order to allow us to catch them using "nb_unknowns". Obsolete, AP July 31st 95 :

quast old_pip_solve(ps_dep, ps_context, nb_unknowns, min_or_max) Psysteme ps_dep, ps_context; int nb_unknowns; int min_or_max; { Pvecteur pvect; int aux, n, i, res, infinite_num; char *com = "essai";

if(min_or_max == PIP_SOLVE_MIN) { ind_min_max = 0; infinite_num = -1; } else { ps_dep = converti_psysmin_psysmax(ps_dep, nb_unknowns); ind_min_max = 1; infinite_num = vect_size((ps_dep)->base); }

base_var_ref = base_dup((ps_dep)->base); old_base_var = base_dup(base_var_ref); for(i = 1, pvect = base_var_ref; i<nb_unknowns; i++) { pvect = pvect->succ; } base_ref = pvect->succ; pvect->succ = NULL; old_base = base_dup(base_ref);

if(! SC_EMPTY_P(ps_context)) ps_context->base = base_dup(base_ref);

res = ecrit_probleme2(com, ps_dep, ps_context, nb_unknowns, infinite_num, vect_size(base_ref));

n = 1; while(n & 0xff) { int m; m = fork(); while(m == -1) { char answer;

fprintf(stderr, "Fork failed for PIP\n\t Do you want to retry (y/n) ?\n"); scanf("%c\n", &answer); if(answer == 'y') m = fork(); else exit(1); fprintf(stderr, "\n"); } if(m == 0) { execlp(PIP_BIN, PIP_BIN, PIP_OPTION, PIP_IN_FILE, PIP_OUT_FILE, (char *) 0); }

wait(&n); }

if((quayyin = fopen(PIP_OUT_FILE,"r")) == NULL) { fprintf(stderr, "Cannot open file %s\n", PIP_OUT_FILE); exit(1); } aux = quayyparse();

return(quast_act); } ========================================================================== quast old2_pip_solve(Psysteme ps_dep, ps_context, int nb_unknowns, int min_or_max): Pip resolution. AL 6/12/93

Parameters: ps_dep: system of constraints on the unknowns (and parameters) ps_context: system of constraints on the parameters nb_unknowns: number of unknowns in "ps_dep" int_or_rat: integer or rational resolution. min_or_max: tag for min or max resolution

Result: a quast giving the value of the unknowns

Note: The basis of "ps_dep" must contain all the unknowns and the parameters, with first the unknowns in order to allow us to catch them using "nb_unknowns".

Call to PIP is direct : no input or output file are produced. Obsolete, AP July 31st 95 :

quast old2_pip_solve(ps_dep, ps_context, nb_unknowns, min_or_max) Psysteme ps_dep, ps_context; int nb_unknowns, min_or_max; { Pvecteur pvect; int i, infinite_num;

int q, bigparm, ni, nvar, nq, non_vide, nparm, nc, p, xq; char* g; Tableau *ineq, *context, *ctxt;

    debug_on("PIP_DEBUG_LEVEL");
    debug(5, "pip_solve", "begin\n");
    if (get_debug_level()>4) {
            debug(5, "pip_solve", "Input Psysteme:\n");
            fprint_psysteme( stderr, ps_dep );
            debug(5, "pip_solve", "Input Context:\n");
            fprint_psysteme( stderr, ps_context );
            fprintf(stderr, "Number of variables : %d\n", nb_unknowns);
    }

    vect_erase_var(&(ps_dep->base), (Variable) TCST);
    ps_dep->dimension = vect_size((ps_dep)->base);

    if(min_or_max == PIP_SOLVE_MIN) {
            ind_min_max = 0;
            infinite_num = -1;
    }
    else {
            ps_dep = converti_psysmin_psysmax(ps_dep, nb_unknowns);

            vect_erase_var(&(ps_dep->base), (Variable) TCST);
            ps_dep->dimension = vect_size((ps_dep)->base);

            ind_min_max = 1;
            infinite_num = vect_size((ps_dep)->base);
    }

    base_var_ref = base_dup((ps_dep)->base);
    old_base_var = base_dup(base_var_ref); 

    for(i = 1, pvect = base_var_ref; i<nb_unknowns; i++)
            { pvect = pvect->succ; }
    base_ref = pvect->succ;                 
    pvect->succ = NULL;                     
    old_base = base_dup(base_ref);

    if(! SC_EMPTY_P(ps_context) ) {
            ps_context->base = base_dup(base_ref);
            ps_context->dimension = vect_size( base_ref );
    }

    nvar    = nb_unknowns;
    nparm   = ps_dep->dimension - nb_unknowns;
    ni      = (ps_dep->nb_eq * 2) + ps_dep->nb_ineq;;
    nc      = ((ps_context == NULL)? 0 :
                     (ps_context->nb_eq * 2) + ps_context->nb_ineq );
    bigparm = infinite_num;
    nq      = 1;
    debug(5, "pip_solve", "%d  %d  %d  %d  %d  %d\n",
                            nvar, nparm, ni, nc, bigparm, nq );

    limit   = 0L;
    sol_init();
    tab_init();
    cross_product = 0;
    g       = tab_hwm();
    ineq    = sc_to_tableau(ps_dep, nb_unknowns);
    if (ps_context != NULL) {
            context = sc_to_tableau(ps_context, 0);
    }
    else context = NULL;
    xq = p = sol_hwm();

    if (nc) {
            ctxt = expanser(context, nparm, nc, nparm+1, nparm, 0, 0);
            traiter( ctxt, NULL, True, UN, nparm, 0, nc, 0, -1 );
            non_vide = is_not_Nil(p);
            sol_reset(p);
    }
    else non_vide = True;
    if ( non_vide ) {
            traiter( ineq, context, nq, UN, nvar, nparm, ni, nc, bigparm );
            q = sol_hwm();
            init_new_base();
            while((xq = new_sol_edit(xq)) != q);
            sol_reset(p);
    }
    else quast_act = quast_undefined;
    tab_reset(g);

    if (get_debug_level()>5) {
            imprime_quast( stderr, quast_act );
    }
    debug_off();
    return(quast_act);

} ====================================================================== quast pip_solve_min_with_big(Psysteme ps_dep, ps_context, int nb_unknowns, char *big): Pip resolution.

Parameters: ps_dep: system of constraints on the unknowns (and parameters) ps_context: system of constraints on the parameters nb_unknowns: number of unknowns in "ps_dep" big: big parameter 's name.

Result: a quast giving the value of the unknowns

Note: The basis of "ps_dep" must contain all the unknowns and the parameters, with first the unknowns in order to allow us to catch them using "nb_unknowns".

Call to PIP is direct : no input or output file are produced.

Note: this function is the same as pip_solve_min() but it has a big parameter given by the use.

FD variables

Pip variables

AC variables for the big parameter

trace file

We set the env for the kind of resolution desired (i.e. Min)

and we get the order of the bi parameter called "big" in the

base of ps_dep

Normalize base of system ps_dep

Computation of the basis (unknowns and parameters) base of ps_dep is the reference for all unknowns and parameters.

Total base of ps_dep

Set PIP variables. Comes from ecrit_probleme2

Prepare to call PIP

Verification de la non vacuite du contexte

We read solution and put it in global quast_act

Definition at line 331 of file pip.c.

336 {
337  /* FD variables */
338  int infinite_num;
339 
340  /* Pip variables */
341  int q, bigparm, ni, nvar, nq, non_vide, nparm, nc, p, xq;
342  char* g;
343  Tableau *ineq, *context, *ctxt;
344 
345  /* AC variables for the big parameter */
346  bool not_found = true;
347  list lbase;
348  entity ent;
349  int nb_unknowns, len_big;
350 
351  debug_on("PIP_DEBUG_LEVEL");
352  debug(5, "pip_solve_min_with_big", "begin\n");
353  /* trace file */
354  nb_unknowns = vect_size( pv_unknowns );
355  if (get_debug_level()>4)
356  {
357  debug(5, "pip_solve_min_with_big", "Input Psysteme:\n");
358  fprint_psysteme( stderr, ps_dep );
359  debug(5, "pip_solve_min_with_big", "Input Context:\n");
360  fprint_psysteme( stderr, ps_context );
361  fprintf(stderr, "Number of variables : %d\n", nb_unknowns);
362  }
363 
364  /* We set the env for the kind of resolution desired (i.e. Min) */
365  /* and we get the order of the bi parameter called "big" in the */
366  /* base of ps_dep */
367 
368  /* Normalize base of system ps_dep */
369  pv_unknowns = base_normalize( pv_unknowns );
370  vect_erase_var( &ps_dep->base, TCST );
371  ps_dep->base = vect_add_first(pv_unknowns, ps_dep->base);
372  ps_dep->dimension = vect_size( ps_dep->base );
373 
374  ind_min_max = 0;
375  infinite_num = 1;
376  len_big = strlen(big);
377  lbase = base_to_list(ps_dep->base);
378  while ((not_found) && (lbase != NIL))
379  {
380  ent = ENTITY(CAR(lbase));
381  if (!strncmp(entity_local_name(ent), big, len_big))
382  not_found = false;
383  else
384  {
385  infinite_num++;
386  lbase = CDR(lbase);
387  }
388  }
389  if (not_found) infinite_num = -1;
390 
391  /* Computation of the basis (unknowns and parameters)
392  * base of ps_dep is the reference for all unknowns and parameters.
393  */
394  if (ps_context != NULL) {
395  vect_erase_var( &ps_context->base, TCST);
396  ps_context->dimension = vect_size( ps_context->base );
397  base_var_ref = base_union( ps_dep->base, ps_context->base );
398  }
399  else base_var_ref = ps_dep->base;
400  base_var_ref = vect_add_first(pv_unknowns, base_var_ref);
401  base_ref = vect_substract(base_var_ref, pv_unknowns);
402 
403  old_base_var = base_dup(base_var_ref); /* Total base of ps_dep */
405 
406  if (!SC_EMPTY_P(ps_context))
407  {
408  ps_context->base = base_dup(base_ref);
409  ps_context->dimension = vect_size( base_ref );
410  }
411 
412  /* Set PIP variables. Comes from ecrit_probleme2 */
413  nvar = nb_unknowns;
414  nparm = ps_dep->dimension - nb_unknowns;
415  ni = (ps_dep->nb_eq * 2) + ps_dep->nb_ineq;;
416  nc = ((ps_context == NULL)? 0 :
417  (ps_context->nb_eq * 2) + ps_context->nb_ineq );
418  bigparm = infinite_num;
419  nq = 1;
420  debug(5, "pip_solve_min_with_big", "%d %d %d %d %d %d\n",\
421  nvar, nparm, ni, nc, bigparm, nq );
422 
423  /* Prepare to call PIP */
424  limit = 0L;
425  sol_init();
426  tab_init();
427  cross_product = 0;
428  g = tab_hwm();
429  ineq = sc_to_tableau(ps_dep, nb_unknowns);
430  if (ps_context != NULL)
431  context = sc_to_tableau(ps_context, 0);
432  else context = NULL;
433  xq = p = sol_hwm();
434 
435  /* Verification de la non vacuite du contexte */
436  if (nc)
437  {
438  ctxt = expanser(context, nparm, nc, nparm+1, nparm, 0, 0);
439  traiter( ctxt, NULL, PIP_SOLVE_RATIONAL, UN, nparm, 0, nc, 0, -1 );
440  non_vide = is_not_Nil(p);
441  sol_reset(p);
442  }
443  else non_vide = True;
444 
445  if (non_vide)
446  {
447  traiter(ineq, context, PIP_SOLVE_RATIONAL, UN, nvar, nparm, ni, nc, bigparm);
448  q = sol_hwm();
449  init_new_base();
450  /* We read solution and put it in global quast_act */
451  while((xq = rational_sol_edit(xq)) != q);
452  sol_reset(p);
453  }
454  else quast_act = quast_undefined;
455  tab_reset(g);
456 
457  if (get_debug_level()>5) imprime_quast(stderr, quast_act);
458 
459  debug_off();
460 
461  return(quast_act);
462 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
list base_to_list(Pbase base)
Most includes are centralized here.
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References base_dup(), base_normalize(), base_ref, base_to_list(), base_union(), base_var_ref, CAR, CDR, cross_product, debug(), debug_off, debug_on, ENTITY, entity_local_name(), expanser(), fprint_psysteme(), fprintf(), get_debug_level(), imprime_quast(), ind_min_max, init_new_base(), is_not_Nil(), limit, NIL, old_base, old_base_var, PIP_SOLVE_RATIONAL, quast_act, quast_undefined, rational_sol_edit(), sc_to_tableau(), sol_hwm(), sol_init(), sol_reset(), tab_hwm(), tab_init(), tab_reset(), TCST, traiter(), True, UN, vect_add_first(), vect_erase_var(), vect_size(), and vect_substract().

Referenced by analyze_quast(), and search_scc_bdt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sort_psysteme()

void sort_psysteme ( Psysteme  ps,
Pvecteur  pv 
)

==================================================================

void sort_psysteme(Psysteme ps, Pvecteur pv): sorts the system "ps" according to the vector "pv". In order to avoid any side effects, this vector is duplicated into a base "new_base". When the sorting is done, this new base becomes the basis of this system.

"pv" MUST contain all the variables that appear in "ps". "pv" DOES NOT HAVE TO contain TCST.

modified by FC, 29/12/94. I removed the vect_tri call and the associated memory leaks. sc_vect_sort called instead. maybe the sc base is lost? It depends whether it is pv or not, and what is done with pv by the caller. I would suggest a base_rm.

Definition at line 729 of file pip.c.

732 {
733  if(SC_EMPTY_P(ps)) return;
734 
735  base_for_sort = base_dup(pv);
737 
739  ps->base = base_for_sort;
740  base_for_sort = (Pbase)NULL;
741 }
static int compare_variables_in_base(Pvecteur *pv1, Pvecteur *pv2)
function for qsort.
Definition: pip.c:700
void sc_vect_sort(Psysteme s, int(*compare)(Pvecteur *, Pvecteur *))
the name is self explanatory, I guess.
Definition: sc_unaires.c:116
struct Svecteur * Pbase
#define base_dimension(b)

References base_dimension, base_dup(), base_for_sort, compare_variables_in_base(), and sc_vect_sort().

Referenced by adg_build_Psysteme(), and adg_dataflowgraph().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_add_first()

Pvecteur vect_add_first ( Pvecteur  pv1,
Pvecteur  pv2 
)

======================================================================

Pvecteur vect_add_first( pv1, pv2 ) AL 16 02 94

Suppress all variables of pv1 in pv2 and add pv1 before pv2. Keep pv1 order, not pv2's order!

Definition at line 470 of file pip.c.

472 {
473  Pvecteur pv, pv11, pv22;
474 
475  if (pv1 == NULL) return pv2;
476  pv11 = vect_reversal( vect_dup( pv1 ) );
477  pv22 = vect_dup( pv2 );
478 
479  for( pv = pv11 ; pv != NULL; pv = pv->succ) {
480  vect_erase_var( &pv22, pv->var );
481  if (pv->succ != NULL) continue;
482  pv->succ = pv22;
483  break;
484  }
485  return pv11;
486 }
Pvecteur vect_reversal(Pvecteur vect_in)
Pvecteur vect_reversal(Pvecteur vect_in); produces the reversal vector of the vect_in.
Definition: private.c:237
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51

References Svecteur::succ, Svecteur::var, vect_dup(), vect_erase_var(), and vect_reversal().

Referenced by pip_solve(), and pip_solve_min_with_big().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ allocation

int allocation

External variables for direct call to PIP.

Definition at line 92 of file pip.c.

Referenced by dag_vertex_pred_imagelets(), freia_terapix_call(), tab_alloc(), tab_init(), and tab_reset().

◆ base_for_sort

Pbase base_for_sort = (Pbase)NULL
static

==================================================================

void pip_solve_min(Psysteme ps_dep, ps_context, int nb_unknowns): Pip resolution for the minimum. Obsolete, AP July 31st 95 :

quast pip_solve_min(ps_dep, ps_context, nb_unknowns) Psysteme ps_dep, ps_context; int nb_unknowns; { return(old2_pip_solve(ps_dep, ps_context, nb_unknowns, PIP_SOLVE_MIN)); } ================================================================== void pip_solve_max(Psysteme ps_dep, ps_context, int nb_unknowns): Pip resolution for the maximum. Obsolete, AP July 31st 95 :

quast pip_solve_max(ps_dep, ps_context, nb_unknowns) Psysteme ps_dep, ps_context; int nb_unknowns; { return(old2_pip_solve(ps_dep, ps_context, nb_unknowns, PIP_SOLVE_MAX)); } ================================================================== Useful for the sorting of the variables in the system's Pvecteur.

Definition at line 695 of file pip.c.

Referenced by compare_variables_in_base(), and sort_psysteme().

◆ base_ref

Pbase base_ref

Base of the unknowns.

Definition at line 102 of file pip.c.

Referenced by init_new_base(), init_vecteur(), pip_solve(), and pip_solve_min_with_big().

◆ base_var_ref

Pbase base_var_ref

Tag for MIN or MAX resolution.

Definition at line 102 of file pip.c.

Referenced by init_liste_vecteur(), pip_solve(), and pip_solve_min_with_big().

◆ comptage

int comptage

Definition at line 92 of file pip.c.

◆ cross_product

long int cross_product

◆ dump

FILE* dump = NULL

Should not be used : put here for Pip copatibility.

Definition at line 97 of file pip.c.

Referenced by dgetc(), dscanf(), pivoter(), sol_edit(), and sol_nil().

◆ dump_name

char dump_name[] = "XXXXXX"

Definition at line 98 of file pip.c.

◆ inbuff

char inbuff[INLENGTH]

Definition at line 93 of file pip.c.

Referenced by dgetc(), and dscanf().

◆ ind_min_max

◆ inptr

int inptr = 256

Definition at line 94 of file pip.c.

Referenced by dgetc(), and dscanf().

◆ limit

long int limit

Definition at line 91 of file pip.c.

Referenced by pip_solve(), and pip_solve_min_with_big().

◆ old_base

Pbase old_base

Base of the parameters.

Definition at line 102 of file pip.c.

Referenced by creer_Psysteme(), pip_solve(), and pip_solve_min_with_big().

◆ old_base_var

Pbase old_base_var

Base of the unknowns.

Definition at line 102 of file pip.c.

Referenced by pip_solve(), and pip_solve_min_with_big().

◆ proviso

int proviso = 0

Definition at line 95 of file pip.c.

◆ quast_act

quast quast_act

Global variables

Definition at line 101 of file pip.c.

Referenced by creer_true_quast(), ecrit_resultat(), fait_quast(), pip_solve(), and pip_solve_min_with_big().

◆ verbose

int verbose = 0

Definition at line 96 of file pip.c.

Referenced by sol_edit(), and sol_nil().