}
// find vertex costs
- for (int vertex=0;vertex<m_nVert;vertex++)
+ for (unsigned int vertex=0;vertex<m_nVert;vertex++)
{
try
{
// find max cost, next max cost, and min cost
m_iMax = m_iNextMax = m_iMin = 0;
- for (int vertex=0;vertex<m_nVert;vertex++)
+ for (unsigned int vertex=0;vertex<m_nVert;vertex++)
{
if ( m_cost[vertex] > m_cost[m_iMax] )
{
}
// compute element sum of simplex vertices
- for (int dim=0;dim<m_nDim;dim++)
+ for (unsigned int dim=0;dim<m_nDim;dim++)
{
m_elemSum[dim] = 0;
- for (int vertex=0;vertex<m_nVert;vertex++)
+ for (unsigned int vertex=0;vertex<m_nVert;vertex++)
m_elemSum[dim] += m_simplex[vertex][dim];
}
if (showSimplex)
{
std::cout << "simplex: " << std::endl;;
- for (int j=0;j<m_nVert;j++)
+ for (unsigned int j=0;j<m_nVert;j++)
std::cout << "\t" << std::scientific
<< std::setw(10) << m_cost[j];
std::cout << std::endl;
- for (int j=0;j<m_nVert;j++) std::cout << "\t\t" << j;
+ for (unsigned int j=0;j<m_nVert;j++) std::cout << "\t\t" << j;
std::cout << std::endl;
- for (int i=0;i<m_nDim;i++)
+ for (unsigned int i=0;i<m_nDim;i++)
{
- for (int j=0;j<m_nVert;j++)
+ for (unsigned int j=0;j<m_nVert;j++)
std::cout << "\t" << std::setw(10) << m_simplex[j][i];
std::cout << std::endl;
}
double a= (1.0-factor)/m_nDim;
double b = a - factor;
std::vector<double> tryVertex(m_nDim);
- for (int dim=0;dim<m_nDim;dim++)
+ for (unsigned int dim=0;dim<m_nDim;dim++)
{
tryVertex[dim] = m_elemSum[dim]*a - m_simplex[m_iMax][dim]*b;
boundVertex(tryVertex,m_lowerBound,m_upperBound);
if (costTry < m_cost[m_iMax])
{
// update the element sum of the simplex
- for (int dim=0;dim<m_nDim;dim++) m_elemSum[dim] +=
+ for (unsigned int dim=0;dim<m_nDim;dim++) m_elemSum[dim] +=
tryVertex[dim] - m_simplex[m_iMax][dim];
// replace the max vertex with the trial vertex
- for (int dim=0;dim<m_nDim;dim++) m_simplex[m_iMax][dim] = tryVertex[dim];
+ for (unsigned int dim=0;dim<m_nDim;dim++) m_simplex[m_iMax][dim] = tryVertex[dim];
// update the cost
m_cost[m_iMax] = costTry;
if (showSimplex) std::cout << "stretched\t" << m_iMax << "\tby : " << factor << std::endl;
void FGNelderMead::contract()
{
- for (int dim=0;dim<m_nDim;dim++)
+ for (unsigned int dim=0;dim<m_nDim;dim++)
{
- for (int vertex=0;vertex<m_nVert;vertex++)
+ for (unsigned int vertex=0;vertex<m_nVert;vertex++)
{
m_simplex[vertex][dim] =
getRandomFactor()*0.5*(m_simplex[vertex][dim] +
void FGNelderMead::constructSimplex(const std::vector<double> & guess,
const std::vector<double> & stepSize)
{
- for (int vertex=0;vertex<m_nVert;vertex++)
+ for (unsigned int vertex=0;vertex<m_nVert;vertex++)
{
m_simplex[vertex] = guess;
}
- for (int dim=0;dim<m_nDim;dim++)
+ for (unsigned int dim=0;dim<m_nDim;dim++)
{
int vertex = dim + 1;
m_simplex[vertex][dim] += stepSize[dim]*getRandomFactor();
if (showSimplex)
{
std::cout << "simplex: " << std::endl;;
- for (int j=0;j<m_nVert;j++) std::cout << "\t\t" << j;
+ for (unsigned int j=0;j<m_nVert;j++) std::cout << "\t\t" << j;
std::cout << std::endl;
- for (int i=0;i<m_nDim;i++)
+ for (unsigned int i=0;i<m_nDim;i++)
{
- for (int j=0;j<m_nVert;j++)
+ for (unsigned int j=0;j<m_nVert;j++)
std::cout << "\t" << std::setw(10) << m_simplex[j][i];
std::cout << std::endl;
}
const std::vector<double> & lowerBound,
const std::vector<double> & upperBound)
{
- for (int dim=0;dim<m_nDim;dim++)
+ for (unsigned int dim=0;dim<m_nDim;dim++)
{
if (vertex[dim] > upperBound[dim]) vertex[dim] = upperBound[dim];
else if (vertex[dim] < lowerBound[dim]) vertex[dim] = lowerBound[dim];
size_t nY = y.getSize();
double f1 = 0, f2 = 0, fn1 = 0, fn2 = 0;
J.resize(nY);
- for (int iY=0;iY<nY;iY++)
+ for (unsigned int iY=0;iY<nY;iY++)
{
J[iY].resize(nX);
- for (int iX=0;iX<nX;iX++)
+ for (unsigned int iX=0;iX<nX;iX++)
{
x.set(x0);
x.set(iX,x.get(iX)+h);
std::ostream &operator<<( std::ostream &out, const FGStateSpace::ComponentVector &v )
{
- for (int i=0; i< v.getSize(); i++)
+ for (unsigned int i=0; i< v.getSize(); i++)
{
out << *(v.getComp(i)) << "\n";
}
std::streamsize width = out.width();
size_t nI = vec2d.size();
out << std::left << std::setw(1) << "[" << std::right;
- for (int i=0;i<nI;i++)
+ for (unsigned int i=0;i<nI;i++)
{
//std::cout << "i: " << i << std::endl;
size_t nJ = vec2d[i].size();
- for (int j=0;j<nJ;j++)
+ for (unsigned int j=0;j<nJ;j++)
{
//std::cout << "j: " << j << std::endl;
if (i==0 && j==0) out << std::setw(width-1) << vec2d[i][j];
std::streamsize width = out.width();
size_t nI = vec.size();
out << std::left << std::setw(1) << "[" << std::right;
- for (int i=0;i<nI;i++)
+ for (unsigned int i=0;i<nI;i++)
{
if (i==0) out << std::setw(width-1) << vec[i];
else out << std::setw(width) << vec[i];
std::vector<double> get() const
{
std::vector<double> val;
- for (int i=0;i<getSize();i++) val.push_back(m_components[i]->get());
+ for (unsigned int i=0;i<getSize();i++) val.push_back(m_components[i]->get());
return val;
}
void get(double * array) const
{
- for (int i=0;i<getSize();i++) array[i] = m_components[i]->get();
+ for (unsigned int i=0;i<getSize();i++) array[i] = m_components[i]->get();
}
double getDeriv(int i)
{
std::vector<double> getDeriv() const
{
std::vector<double> val;
- for (int i=0;i<getSize();i++) val.push_back(m_components[i]->getDeriv());
+ for (unsigned int i=0;i<getSize();i++) val.push_back(m_components[i]->getDeriv());
return val;
}
void getDeriv(double * array) const
{
- for (int i=0;i<getSize();i++) array[i] = m_components[i]->getDeriv();
+ for (unsigned int i=0;i<getSize();i++) array[i] = m_components[i]->getDeriv();
}
void set(std::vector<double> vals)
{
- for (int i=0;i<getSize();i++) m_components[i]->set(vals[i]);
+ for (unsigned int i=0;i<getSize();i++) m_components[i]->set(vals[i]);
m_stateSpace->run();
}
void set(double * array)
{
- for (int i=0;i<getSize();i++) m_components[i]->set(array[i]);
+ for (unsigned int i=0;i<getSize();i++) m_components[i]->set(array[i]);
m_stateSpace->run();
}
std::string getName(int i) const
std::vector<std::string> getName() const
{
std::vector<std::string> name;
- for (int i=0;i<getSize();i++) name.push_back(m_components[i]->getName());
+ for (unsigned int i=0;i<getSize();i++) name.push_back(m_components[i]->getName());
return name;
}
std::string getUnit(int i) const
std::vector<std::string> getUnit() const
{
std::vector<std::string> unit;
- for (int i=0;i<getSize();i++) unit.push_back(m_components[i]->getUnit());
+ for (unsigned int i=0;i<getSize();i++) unit.push_back(m_components[i]->getUnit());
return unit;
}
void clear() {
double stateSum() {
double sum = 0;
- for (int i=0;i<x.getSize();i++) sum += x.get(i);
+ for (unsigned int i=0;i<x.getSize();i++) sum += x.get(i);
return sum;
}
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGAccelerations.cpp,v 1.22 2015/03/28 14:49:02 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGAccelerations.cpp,v 1.24 2015/04/02 18:30:06 ehofman Exp $");
IDENT(IdHdr,ID_ACCELERATIONS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// 1. Compute the right hand side member 'rhs'
// 2. Divide every line of 'a' and 'rhs' by a[i,i]. This is in order to save
// a division computation at each iteration of Gauss-Seidel.
- for (int i=0; i < n; i++) {
+ for (unsigned int i=0; i < n; i++) {
double d = 1.0 / a[i*n+i];
rhs[i] = -(DotProduct(multipliers[i]->ForceJacobian, vdot)
+DotProduct(multipliers[i]->MomentJacobian, wdot))*d;
- for (int j=0; j < n; j++)
+ for (unsigned int j=0; j < n; j++)
a[i*n+j] *= d;
}
for (int iter=0; iter < 50; iter++) {
double norm = 0.;
- for (int i=0; i < n; i++) {
+ for (unsigned int i=0; i < n; i++) {
double lambda0 = multipliers[i]->value;
double dlambda = rhs[i];
- for (int j=0; j < n; j++)
+ for (unsigned int j=0; j < n; j++)
dlambda -= a[i*n+j]*multipliers[j]->value;
multipliers[i]->value = Constrain(multipliers[i]->Min, lambda0+dlambda, multipliers[i]->Max);
// Calculate the total friction forces and moments
- for (int i=0; i< n; i++) {
+ for (unsigned int i=0; i< n; i++) {
double lambda = multipliers[i]->value;
vFrictionForces += lambda * multipliers[i]->ForceJacobian;
vFrictionMoments += lambda * multipliers[i]->MomentJacobian;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGInput.cpp,v 1.32 2015/04/02 02:20:50 dpculp Exp $");
+IDENT(IdSrc,"$Id: FGInput.cpp,v 1.33 2015/04/08 19:35:00 bcoconni Exp $");
IDENT(IdHdr,ID_INPUT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
} else if (type == "QTJSBSIM") {
Input = new FGUDPInputSocket(FDMExec);
} else if (type != string("NONE")) {
- cerr << "Unknown type of input specified in config file" << endl;
+ cerr << element->ReadFrom()
+ << "Unknown type of input specified in config file" << endl;
}
if (!Input) return false;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGKinemat.cpp,v 1.14 2014/01/13 10:46:09 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGKinemat.cpp,v 1.15 2015/04/02 17:39:28 bcoconni Exp $");
IDENT(IdHdr,ID_FLAPS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
while ( dt0 > 0.0 && !EqualToRoundoff(Input, Output) ) {
// Find the area where Output is in
- int ind;
+ unsigned int ind;
for (ind = 1; (Input < Output) ? Detents[ind] < Output : Detents[ind] <= Output ; ++ind)
if (NumDetents <= ind)
break;
if (from == 0) { // Constructor
cout << " INPUT: " << InputNodes[0]->GetName() << endl;
cout << " DETENTS: " << NumDetents << endl;
- for (int i=0;i<NumDetents;i++) {
+ for (unsigned int i=0;i<NumDetents;i++) {
cout << " " << Detents[i] << " " << TransitionTimes[i] << endl;
}
if (IsOutput) {