Example #1
0
int main(void)
{

  VariationalInequality vi;
  variationalInequality_clear(&vi);
  
  vi.size=10;
  //vi.Callback = (CallbackVI *)malloc(sizeof(CallbackVI));
  
  vi.env = &vi;
  
  vi.F = &Ftest;
  vi.ProjectionOnX = &PXtest ;
  
  /* Call the callback */
  double x[10], F[10], PX[10];
  int i, n=10;
  for (i =0; i< n ; i++)
  {
    x[i] = i-5;
  }
  vi.F(&vi,n,x,F);
  vi.ProjectionOnX(&vi,x,PX);
  for (i =0; i< n ; i++)
  {
    printf("x[%i]=%f\t",i,x[i]);    printf("F[%i]=%f\t",i,F[i]);    printf("PX[%i]=%f\n",i,PX[i]);
  }
  

    
}
Example #2
0
int main(void)
{

  VariationalInequality vi;
  variationalInequality_clear(&vi);

  vi.size=1;
  //vi.Callback = (CallbackVI *)malloc(sizeof(CallbackVI));

  vi.env = &vi;

  vi.F = &Ftest;
  vi.ProjectionOnX = &PXtest ;

  /* Call the callback */
  double x[1], F[1], PX[1];
  int i, n=1;
  for (i =0; i< n ; i++)
  {
    x[i] = i-5;
  }
  vi.F(&vi,n,x,F);
  vi.ProjectionOnX(&vi,x,PX);
  for (i =0; i< n ; i++)
  {
    printf("x[%i]=%f\t",i,x[i]);    printf("F[%i]=%f\t",i,F[i]);    printf("PX[%i]=%f\n",i,PX[i]);
  }

  NumericsOptions global_options;
  setDefaultNumericsOptions(&global_options);
  global_options.verboseMode = 1; // turn verbose mode to off by default

  SolverOptions * options = (SolverOptions *) malloc(sizeof(SolverOptions));
  int info = variationalInequality_setDefaultSolverOptions(options, SICONOS_VI_HP);
  options->dparam[0]=1e-10;
  options->iparam[0]=50000000;
  

  info = variationalInequality_driver(&vi,
                                      x,
                                      F,
                                      options,
                                      &global_options);

  for (i =0; i< n ; i++)
  {
    printf("x[%i]=%f\t",i,x[i]);    printf("w[%i]=F[%i]=%f\n",i,i,F[i]);
  }

  deleteSolverOptions(options);
  free(options);

  return info;
}