Пример #1
0
void init_rpn(void) {
  parser_doubles_init(&constants, 0);
  parser_ufuns_init(&ufuns, 0);
  parser_doubles_init(&variables, 0);
  parser_symbols_init(&my_symb, NUM_BUILTIN_SYMBOLS);
  memcpy(parser_symbols_insert(&my_symb, 0, NUM_BUILTIN_SYMBOLS),
         BUILTIN_SYMBOLS, NUM_BUILTIN_SYMBOLS * sizeof(*BUILTIN_SYMBOLS));

  add_con("PI", M_PI);

  add_con("I'", 0.0);
  SumIndex = constants.len - 1;

  add_con("", 0.0);
  shift_index = constants.len - 1;

  /*   This is going to be for interacting with the
       animator */
  add_con("mouse_x", 0.0);
  add_con("mouse_y", 0.0);
  add_con("mouse_vx", 0.0);
  add_con("mouse_vy", 0.0);

  /* end animator stuff */
  /*  add_con("c___1",0.0);
      add_con("c___2",0.0);
      add_con("c___3",0.0); */

  init_table();
}
Пример #2
0
init_rpn()
{
	int             i;
	ERROUT = 1;
	NCON = 0;
	NFUN = 0;
	NVAR = 0;
	NKernel=0;
    
	MaxPoints=4000;
	NSYM = STDSYM;
	two_args();
	one_arg();
	add_con("PI", M_PI);
        add_con("I'",0.0);
	SumIndex=NCON-1;
	init_table();
	srand48(RandSeed);
}
Пример #3
0
void init_rpn()
{

    ERROUT = 1;
    NCON = 0;
    NFUN = 0;
    NVAR = 0;
    NKernel=0;

    MaxPoints=4000;
    NSYM = STDSYM;
    two_args();
    one_arg();
    add_con("PI", M_PI);

        add_con("I'",0.0);
    /*   This is going to be for interacting with the
         animator */
    SumIndex=NCON-1;
        add_con("mouse_x",0.0);
        add_con("mouse_y",0.0);
        add_con("mouse_vx",0.0);
        add_con("mouse_vy",0.0);

    /* end animator stuff */
    /*  add_con("c___1",0.0);
        add_con("c___2",0.0);
        add_con("c___3",0.0); */

    init_table();
    if (newseed==1) RandSeed=time(0);
    nsrand48(RandSeed);
}
Пример #4
0
int
main (int argc, char **argv)
{
   IloEnv   env;
   try {
      IloModel model(env);
      IloNumVarArray var(env);
      IloRangeArray con(env);
      IloRange add_con(env, 0.0, IloInfinity);

      populatebyrow (model, var, con);

      IloCplex cplex(model);

      // When a non-convex objective function is present, CPLEX will
      // raise an exception unless the parameter
      // IloCplex::Param::OptimalityTarget is set to accept first-order optimal
      // solutions
      cplex.setParam(IloCplex::Param::OptimalityTarget,
                     IloCplex::SolutionFirstOrder);

      // CPLEX may converge to either local optimum 
      solveanddisplay(env, cplex, var, con);

      // Add a constraint that cuts off the solution at (-1, 1)
      add_con.setExpr(var[0]);
      model.add(add_con);
      solveanddisplay(env, cplex, var, con);

      // Change the bounds of the newly added constraint to cut off
      // the solution at (1, 1)
      add_con.setBounds(-IloInfinity, 0.0);
      solveanddisplay(env, cplex, var, con);

      cplex.exportModel("indefqpex1.lp");
      
   }
   catch (IloException& e) {
      cerr << "Concert exception caught: " << e << endl;
   }
   catch (...) {
      cerr << "Unknown exception caught" << endl;
   }

   env.end();

   return 0;
}  // END main
Пример #5
0
/* this adds a derived quantity  */
int add_derived(char *name, char *rhs) {
  int n = strlen(rhs) + 2;
  int i0;
  if (nderived >= MAXDERIVED) {
    plintf(" Too many derived constants! \n");
    return (1);
  }
  i0 = nderived;
  derived[i0].rhs = (char *)malloc(n);
  /* save the right hand side */
  strcpy(derived[i0].rhs, rhs);
  /* this is the constant to which it addresses */
  derived[i0].index = constants.len;
  /* add the name to the recognized symbols */
  plintf(" derived constant[%d] is %s = %s\n", constants.len, name, rhs);
  nderived++;
  return (add_con(name, 0.0));
}