Hi, it's me again 
I have a problem running my code on windows. It works on Linux!
The probelm must be with threads...
I suspect on this part of code:
QVector<Pso*> psoInstances;
for(int iThread=0; iThread<numberOfThreads; iThread++)
{
Pso* pso = initPsoInstance();
psoInstances.push_back(pso);
// Dimension vs Swarm size
int maxfuncalls = 100000;
pso->dimensions = parameter1[iParam1];
QVector<double> lb(pso->dimensions), ub(pso->dimensions);
lb.fill(-50.0);
ub.fill(50.0);
pso->lowerBound = lb;
pso->upperBound = ub;
pso->psoParameters.swarmSize= parameter2[iParam2];
pso->psoParameters.maxIterations = int(double(maxfuncalls)/double(pso->psoParameters.swarmSize));
pso->clear();
pso->start();
}
for(int iThread=0; iThread<numberOfThreads; iThread++)
{
psoInstances[iThread]->wait();
tmpValueSum += psoInstances[iThread]->iteration * psoInstances[iThread]->psoParameters.swarmSize;
delete psoInstances[iThread]->evaluator;
delete psoInstances[iThread];
}
psoInstances.clear();
QVector<Pso*> psoInstances;
for(int iThread=0; iThread<numberOfThreads; iThread++)
{
Pso* pso = initPsoInstance();
psoInstances.push_back(pso);
// Dimension vs Swarm size
int maxfuncalls = 100000;
pso->dimensions = parameter1[iParam1];
QVector<double> lb(pso->dimensions), ub(pso->dimensions);
lb.fill(-50.0);
ub.fill(50.0);
pso->lowerBound = lb;
pso->upperBound = ub;
pso->psoParameters.swarmSize= parameter2[iParam2];
pso->psoParameters.maxIterations = int(double(maxfuncalls)/double(pso->psoParameters.swarmSize));
pso->clear();
pso->start();
}
for(int iThread=0; iThread<numberOfThreads; iThread++)
{
psoInstances[iThread]->wait();
tmpValueSum += psoInstances[iThread]->iteration * psoInstances[iThread]->psoParameters.swarmSize;
delete psoInstances[iThread]->evaluator;
delete psoInstances[iThread];
}
psoInstances.clear();
To copy to clipboard, switch view to plain text mode
I'm running this in Visual Studio 2010.
During the execution the following message is repeatedly outputted:
The thread 'Swarm' (0xc74) has exited with code 0 (0x0).
The thread 'Swarm' (0xc74) has exited with code 0 (0x0).
To copy to clipboard, switch view to plain text mode
When debugging the code it get stuck on wait() function in second loop.
Is there any thread-related difference in Qt code behavior between Linux and Windows?
Just to mention
class Pso: public QThread
To copy to clipboard, switch view to plain text mode

Any suggestion is more then welcome!
Thanx
Added after 22 minutes:
I found problem!
There is no problem with wait function. In Debug the code i too slow to do anything. It works in Release.
Is this normal for debugging multithread calculations?
It's completely uselss to do anything in Debug... I would wait days for result.
Also, in Release there is no message
The thread 'Swarm' (0xc74) has exited with code 0 (0x0).
The thread 'Swarm' (0xc74) has exited with code 0 (0x0).
To copy to clipboard, switch view to plain text mode
Bookmarks