bool DSLightChunk::operator == (const StateChunk &other) const { const DSLightChunk *tother = dynamic_cast<const DSLightChunk *>(&other); if(!tother) return false; if(tother == this) return true; if(!getAmbient ().equals(tother->getAmbient (), TypeTraits<Real32>::getDefaultEps()) || !getDiffuse ().equals(tother->getDiffuse (), TypeTraits<Real32>::getDefaultEps()) || !getSpecular ().equals(tother->getSpecular (), TypeTraits<Real32>::getDefaultEps()) || !getPosition ().equals(tother->getPosition (), TypeTraits<Real32>::getDefaultEps()) || !getDirection().equals(tother->getDirection(), TypeTraits<Real32>::getDefaultEps()) || getConstantAttenuation () != tother->getConstantAttenuation () || getLinearAttenuation () != tother->getLinearAttenuation () || getQuadraticAttenuation() != tother->getQuadraticAttenuation() || getCutoff () != tother->getCutoff () || getExponent () != tother->getExponent () ) { return false; } return true; }
void RenderableLightEntityItem::render(RenderArgs* args) { PerformanceTimer perfTimer("RenderableLightEntityItem::render"); assert(getType() == EntityTypes::Light); glm::vec3 position = getPosition(); glm::vec3 dimensions = getDimensions(); glm::quat rotation = getRotation(); float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z); glm::vec3 color = toGlm(getXColor()); float intensity = getIntensity(); float exponent = getExponent(); float cutoff = glm::radians(getCutoff()); if (_isSpotlight) { DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f, color, intensity, rotation, exponent, cutoff); } else { DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f, color, intensity); } #ifdef WANT_DEBUG Q_ASSERT(args->_batch); gpu::Batch& batch = *args->_batch; batch.setModelTransform(getTransformToCenter()); DependencyManager::get<GeometryCache>()->renderWireSphere(batch, 0.5f, 15, 15, glm::vec4(color, 1.0f)); #endif };
//############################################################################# // Perform reduced cost fixing on integer variables. The variables in // question are already nonbasic at bound. We're just nailing down the // current situation. void DcModel::reducedCostFix () { double cutoff = getCutoff(); double direction = solver_->getObjSense(); double gap = cutoff - solver_->getObjValue()*direction; double integerTolerance = getDblParam(DcIntegerTolerance); const double* lower = solver_->getColLower(); const double* upper = solver_->getColUpper(); const double* solution = solver_->getColSolution(); const double* reducedCost = solver_->getReducedCost(); int numberFixed = 0 ; for (int i = 0; i < numberIntegers_; i++) { int iColumn = integerVariable_[i]; double djValue = direction * reducedCost[iColumn]; if (upper[iColumn] - lower[iColumn] > integerTolerance) { if (solution[iColumn] < lower[iColumn] + integerTolerance && djValue > gap) { solver_->setColUpper(iColumn, lower[iColumn]); numberFixed++; } else if (solution[iColumn] > upper[iColumn] - integerTolerance && -djValue > gap) { solver_->setColLower(iColumn, upper[iColumn]); numberFixed++; } } } }
bool DcModel::solveWithoutCuts (OsiCuts & cuts, int numberTries, DcTreeNode * node, int & numberOldActiveCuts, int & numberNewCuts, int & maximumWhich, int *& whichGenerator, const bool cutDuringRampup, int & found ) { found = -10; bool feasible; feasible = resolve(); if(!feasible) { return false; // If lost feasibility, bail out right now } // check integer feasibility of solution found = -1; // If found a solution, Record it before we free the vector int numberIntegerInfeasibilities = 0; bool integerFeasible = feasibleSolution(numberIntegerInfeasibilities); bool better; double currentObjValue = getCurrentObjValue(); double cutoff = getCutoff(); if (integerFeasible) { if (currentObjValue < cutoff) { better = setBestSolution(DC_BRANCH, currentObjValue, currentSolution()); } } reducedCostFix(); double minimumDrop = minimumDrop_; if (numberTries < 0) { numberTries = -numberTries; minimumDrop = -1.0; } incrementNodeCount(); return feasible; }
bool BranchAcceptor::save(ostream &os) { os.precision(8); os << "BranchAcceptor" << endl; os << getSignalType() << " " << getCutoff() << " " << getStrand() <<endl; os << getConsensusOffset() << endl; branchPoint->save(os); acceptor->save(os); return true; }
void LightEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params, EntityTreeElementExtraEncodeData* modelTreeElementExtraEncodeData, EntityPropertyFlags& requestedProperties, EntityPropertyFlags& propertyFlags, EntityPropertyFlags& propertiesDidntFit, int& propertyCount, OctreeElement::AppendState& appendState) const { bool successPropertyFits = true; APPEND_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, getIsSpotlight()); APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor()); APPEND_ENTITY_PROPERTY(PROP_INTENSITY, getIntensity()); APPEND_ENTITY_PROPERTY(PROP_EXPONENT, getExponent()); APPEND_ENTITY_PROPERTY(PROP_CUTOFF, getCutoff()); }
void RenderableLightEntityItem::render(RenderArgs* args) { PerformanceTimer perfTimer("RenderableLightEntityItem::render"); assert(getType() == EntityTypes::Light); glm::vec3 position = getPosition(); glm::vec3 dimensions = getDimensions(); glm::quat rotation = getRotation(); float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z); const float MAX_COLOR = 255.0f; float colorR = getColor()[RED_INDEX] / MAX_COLOR; float colorG = getColor()[GREEN_INDEX] / MAX_COLOR; float colorB = getColor()[BLUE_INDEX] / MAX_COLOR; glm::vec3 color = glm::vec3(colorR, colorG, colorB); float intensity = getIntensity(); float exponent = getExponent(); float cutoff = glm::radians(getCutoff()); if (_isSpotlight) { DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f, color, intensity, rotation, exponent, cutoff); } else { DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f, color, intensity); } #ifdef WANT_DEBUG glm::vec4 color(diffuseR, diffuseG, diffuseB, 1.0f); glPushMatrix(); glTranslatef(position.x, position.y, position.z); glm::vec3 axis = glm::axis(rotation); glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); glPushMatrix(); glm::vec3 positionToCenter = center - position; glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glScalef(dimensions.x, dimensions.y, dimensions.z); DependencyManager::get<DeferredLightingEffect>()->renderWireSphere(0.5f, 15, 15, color); glPopMatrix(); glPopMatrix(); #endif };
bool DcModel::setBestSolution(DC_Message how, double & objectiveValue, const double * solution, bool fixVariables) { double cutoff = getCutoff(); // Double check the solution to catch pretenders. if (objectiveValue >= cutoff) { // Bad news if (objectiveValue > 1.0e30) handler_->message(DC_NOTFEAS1, messages_) << CoinMessageEol; else handler_->message(DC_NOTFEAS2, messages_) << objectiveValue << cutoff << CoinMessageEol; return false; } else { // Better solution bestObjective_ = objectiveValue; int numberColumns = solver_->getNumCols(); if (bestSolution_ == 0) { bestSolution_ = new double[numberColumns]; } memcpy(bestSolution_, solution, numberColumns*sizeof(double)); cutoff = bestObjective_ - dblParam_[DcCutoffIncrement]; setCutoff(cutoff); if (how == DC_ROUNDING) numberHeuristicSolutions_++; numberSolutions_++; // std::cout << "cutoff = " << getCutoff() // << "; objVal = " << bestObjective_ // << "; cutoffInc = " << dblParam_[DcCutoffIncrement] // << std::endl; handler_->message(how, messages_) << bestObjective_ << numberIterations_ << numberNodes_ << CoinMessageEol; return true; } }
void RenderableLightEntityItem::updateRenderItemFromEntity(LightPayload& lightPayload) { auto entity = this; lightPayload.setVisible(entity->getVisible()); auto light = lightPayload.editLight(); light->setPosition(entity->getPosition()); light->setOrientation(entity->getRotation()); bool success; lightPayload.editBound() = entity->getAABox(success); if (!success) { lightPayload.editBound() = render::Item::Bound(); } glm::vec3 dimensions = entity->getDimensions(); float largestDiameter = glm::compMax(dimensions); light->setMaximumRadius(largestDiameter / 2.0f); light->setColor(toGlm(entity->getXColor())); float intensity = entity->getIntensity();//* entity->getFadingRatio(); light->setIntensity(intensity); light->setFalloffRadius(entity->getFalloffRadius()); float exponent = entity->getExponent(); float cutoff = glm::radians(entity->getCutoff()); if (!entity->getIsSpotlight()) { light->setType(model::Light::POINT); } else { light->setType(model::Light::SPOT); light->setSpotAngle(cutoff); light->setSpotExponent(exponent); } }