Hi,
I am using the VS 2008 version downloaded from website. Everything is OK when I tried the SMILE tutorial. However, in the SMILElearn, I met problems when Parse a vector into DSL_dataset object.
I did realized that you changed several functions in "dataset.h" compared with SMILElearn tutorial. When I was attending to add variable into the DSL_dataset, it occurs a real-time error in "AddIntVar" function. Here is the piece of code:
#include <iostream>
#include <string>
#include "smilearn.h"
using namespace std;
void CreateDataset(void);
int main()
{
CreateDataset();
}
void CreateDataset()
{
vector<int> aData;
vector<float> bData;
aData.push_back(1); bData.push_back(11.1f);
aData.push_back(2); bData.push_back(22.2f);
aData.push_back(3); bData.push_back(33.3f);
aData.push_back(4); bData.push_back(44.4f);
aData.push_back(5); bData.push_back(55.5f);
DSL_dataset ds;
vector <int>::iterator iter_int;
vector <float>::iterator iter_float;
iter_int = aData.begin();
iter_float = bData.begin();
int rec = 0;
string aName = "aaa";
int aVar = ds.AddIntVar(aName);
while (iter_int != aData.end() ) {
int data = *iter_int;
cout<<data<<endl;
ds.SetInt(aVar,rec,data);
rec ++;
iter_int ++;
}
}
Pls help me out. Thank you very much.
Problem using dataset.h in SMILELearn
-
- Site Admin
- Posts: 1417
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Problem using dataset.h in SMILELearn
You need to call DSL_dataset::AddEmptyRecord in the loop or DSL_datset::SetNumberOfRecords(int) before entering the loop.
Re: Problem using dataset.h in SMILELearn
Thank you for your quick reply!
However, I got the runtime error even if I comment from the line after
So, is it possible I should do something before this line?
Thanks again!
However, I got the runtime error even if I comment from the line after
Code: Select all
int aVar = ds.AddIntVar(aName);
Thanks again!
Re: Problem using dataset.h in SMILELearn
Let me clarify my problem:
if I change my code like this, I still get a runtime error in the last line in CreateDataset function:
if I change my code like this, I still get a runtime error in the last line in CreateDataset function:
Code: Select all
#include <iostream>
#include <string>
#include "smilearn.h"
using namespace std;
void CreateDataset(void);
int main()
{
CreateDataset();
}
void CreateDataset()
{
vector<int> aData;
vector<float> bData;
aData.push_back(1); bData.push_back(11.1f);
aData.push_back(2); bData.push_back(22.2f);
aData.push_back(3); bData.push_back(33.3f);
aData.push_back(4); bData.push_back(44.4f);
aData.push_back(5); bData.push_back(55.5f);
DSL_dataset ds;
vector <int>::iterator iter_int;
vector <float>::iterator iter_float;
iter_int = aData.begin();
iter_float = bData.begin();
int rec = 0;
string aName = "aaa";
int aVar = ds.AddIntVar(aName);
}
-
- Site Admin
- Posts: 1417
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Problem using dataset.h in SMILELearn
ds.AddIntVar should work. Are you using any manually-specified library settings in your project, or just let smile.h and smilearn.h pick the right SMILE build?
Re: Problem using dataset.h in SMILELearn
Yes, I did manually include the lib file in the VS setting. Problem solved after I delete them!
Thanks a lot !!!
Thanks a lot !!!