FMU/Source/Contract_Negotiation.cpp
/**
 * @brief Assign power to the contracts
 * @details going slow? have you cleared the contracts?
 */
@brief Assign power to the contracts
@details going slow.
@brief Assign power to the contracts @details going slow .
void Contract_Negotiation::processContracts() {
  ContractPtr c = nodePriority.findRightEdge();
  std::vector<ContractPtr>::iterator cs = contractsSupplied.begin();
  while (c && cs != contractsSupplied.end()) {
      double fractionalPower = c->requested - c->received;
      while (fractionalPower > 0 && cs != contractsSupplied.end()) {
          if (sameContract((*cs), c)) {
            cs++;
            continue;
          }
          double supplied = (*cs)->suppliedLeft;
          double suppliedCost = (*cs)->suppliedCost;
          if (supplied - fractionalPower > 0) {
            supplied = fractionalPower;
            (*cs)->suppliedLeft -= supplied;
          } else {
            (*cs)->suppliedLeft = 0;
            cs++;
          }
          c->receivedCost += suppliedCost * supplied;
          c->received += supplied;
          fractionalPower = c->requested - c->received;
      }
      c = nodePriority.findRightEdge();
  }
}
void Contract_Negotiation :: processContracts ( ) { ContractPtr c = nodePriority . findRightEdge ( ) ; std :: vector < ContractPtr > :: iterator cs = contractsSupplied . begin ( ) ; while ( c && cs != contractsSupplied . end ( ) ) { double fractionalPower = c -> requested - c -> received ; while ( fractionalPower > 0 && cs != contractsSupplied . end ( ) ) { if ( sameContract ( ( * cs ) , c ) ) { cs ++ ; continue ; } double supplied = ( * cs ) -> suppliedLeft ; double suppliedCost = ( * cs ) -> suppliedCost ; if ( supplied - fractionalPower > 0 ) { supplied = fractionalPower ; ( * cs ) -> suppliedLeft -= supplied ; } else { ( * cs ) -> suppliedLeft = 0 ; cs ++ ; } c -> receivedCost += suppliedCost * supplied ; c -> received += supplied ; fractionalPower = c -> requested - c -> received ; } c = nodePriority . findRightEdge ( ) ; } }
@brief Assign power to the contracts
 @details going slow?
@brief Assign power to the contracts @details going slow?