Exemplo n.º 1
0
int soclcp_test_function(FILE * f, SolverOptions * options)
{

  int k, info = -1 ;
  SecondOrderConeLinearComplementarityProblem* problem = (SecondOrderConeLinearComplementarityProblem *)malloc(sizeof(SecondOrderConeLinearComplementarityProblem));

  assert(f);
  assert(problem);
  
  info = secondOrderConeLinearComplementarityProblem_newFromFile(problem, f);

  FILE * foutput  =  fopen("checkinput.dat", "w");

  info = secondOrderConeLinearComplementarityProblem_printInFile(problem, foutput);

  /* secondOrderConeLinearComplementarityProblem_display(problem); */

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


  int n = problem->n;

  double *r = (double*)malloc(n * sizeof(double));
  double *v = (double*)malloc(n * sizeof(double));
  for(k = 0 ; k <n; k++)
  {
    v[k] = 0.0;
    r[k] = 0.0;
  }
  info = soclcp_driver(problem,
                       r , v,
                       options, &global_options);

  printf("\n");
  for(k = 0 ; k < n; k++)
  {
    printf("v[%i] = %12.8e \t \t r[%i] = %12.8e\n", k, v[k], k , r[k]);
  }
  printf("\n");

  if(!info)
  {
    printf("test succeeded\n");
  }
  else
  {
    printf("test unsuccessful\n");
  }
  free(r);
  free(v);

  freeSecondOrderConeLinearComplementarityProblem(problem);
  fclose(foutput);

  return info;

}
int secondOrderConeLinearComplementarityProblem_printInFilename(SecondOrderConeLinearComplementarityProblem* problem, char* filename)
{
  int info = 0;
  FILE * file = fopen(filename, "w");

  if(!file)
  {
    return errno;
  }

  info = secondOrderConeLinearComplementarityProblem_printInFile(problem, file);

  fclose(file);
  return info;
}