IloInt choose(IloCP cp, IloIntVarArray vars, IloInt i) {
   IloIntVar var = vars[i];
   IloNum best = IloInfinity;
   IloInt bestValue = cp.getMin(var);
   IloNum centroid = CalcCentroid(cp, var);
   for (IloCP::IntVarIterator it(cp, var); it.ok(); ++it) {
     IloNum eval = IloAbs(centroid - *it);
     if (eval < best) {
       best      = eval;
       bestValue = *it;
     }
   }
   return bestValue;
 }
 IloInt choose(IloCP cp, IloIntVarArray vars) {
   IloNum best = IloInfinity;
   IloInt bestIndex = -1;
   IloInt n = vars.getSize();
   for (IloInt i = 0; i < n; i++) {
     if (!cp.isFixed(vars[i])) {
       IloNum c = CalcCentroid(cp, vars[i]);
       if (c < best) {
         best = c;
         bestIndex = i;
       }
     }
   }
   return bestIndex;
 }
Exemple #3
0
void
FitTLSModel(Chain::SegmentSet& segment_set, IFitTLSModel& tls_fit, TLSModel& tls_model) {
  // calculate the centroid of the atoms which are to
  // be fit and use it as the origin of the TLS tensors
  double x, y, z;
  CalcCentroid(segment_set.begin(), segment_set.end(), &x, &y, &z);
  tls_model.set_origin(x, y, z);

  // set the datapoints for the fit
  tls_fit.reset_fit(&tls_model, CalcNumAtoms(segment_set.begin(), segment_set.end()));
 
  Chain::SegmentSet::AtomIterator atom;
  for (atom = segment_set.begin(); atom != segment_set.end(); ++atom) {
    tls_fit.set_atom_data_point(*atom);
  }

  tls_fit.fit_params();
}
 IloNum eval(IloCP cp, IloIntVar var, IloInt value) {
   return IloAbs(CalcCentroid(cp, var) - value);
 }
 IloNum eval(IloCP cp, IloIntVar var) { return CalcCentroid(cp, var); }
Exemple #6
0
void ATriangle::Init()
{
	type = OBJ_TRIANGLE;
	CalcNormal();
	CalcCentroid();
}