forum.alglib.net

ALGLIB forum
It is currently Fri Apr 19, 2024 8:27 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: minbleicsetscale throws ap_error
PostPosted: Thu Jan 26, 2012 5:11 pm 
Offline

Joined: Sat Jan 21, 2012 7:00 pm
Posts: 3
I am trying to use the BLEIC optimiser. However, everytime my code gets to minbleicsetscale it terminates after throwing an instance of 'alglib::ap_error'.

Code:
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <stdlib.h>
#define TWO_PI 6.28318530732959
#define PI 3.14159255

//include libraries
#include <string> //for joining the strings
#include <sstream> //for naming the output files.
#include <iostream>
#include <omp.h>
#include <ctime> //for random numbers
#include <cstdlib> //for srand() and rand()

#include <iostream>

#include "/hwdisks/home/al544/ALGLIB/cpp/src/stdafx.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/ap.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/ap.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/linalg.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/linalg.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/alglibinternal.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/alglibmisc.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/alglibinternal.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/alglibmisc.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/solvers.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/solvers.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/interpolation.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/interpolation.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/specialfunctions.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/specialfunctions.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/statistics.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/statistics.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/optimization.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/optimization.h"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/integration.cpp"
#include "/hwdisks/home/al544/ALGLIB/cpp/src/integration.h"

using namespace std;

int main (int argc, char* argv[]) {
   
   int lenJ = 400;
   double diffstep = 1e-6;
   
   alglib::minbleicstate bleicstate;
   alglib::minbleicreport bleicrep;
   
   alglib::real_1d_array lambdaJguess;
   lambdaJguess.setlength(lenJ);   
   alglib::real_1d_array lscale;
   lscale.setlength(lenJ);
   for (int i = 0; i < lenJ; i++) {
      lambdaJguess[i] = 0.0;
      lscale[i] = 10.*double(i);
   }
   
   alglib::minbleiccreatef(lenJ, lambdaJguess, diffstep, bleicstate);
   printf("after creating minbleiccreatef\n");
   alglib::minbleicsetscale(bleicstate, lscale);
   printf("after setting scale\n");
   
   return 0;
}


This is simply a cut-down code, to show the problem. Any suggestions would be welcomed.

Thanks.


Top
 Profile  
 
 Post subject: Re: minbleicsetscale throws ap_error
PostPosted: Fri Jan 27, 2012 5:32 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
Hello!

You've passed incorrect scale - first component is zero. If you enclose your code in the try/catch, you will be able to get short description of the error in the msg field of the ap_error instance:

Code:
try
{
   .... your code ....
}
catch(alglib::ap_error e)
{
    printf("error msg: %s\n", e.msg.c_str());
}


Code above will print msg: MinBLEICSetScale: S contains zero elements


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 61 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group