<commit_before>// This is free and unencumbered software released into the public domain.
// For more information, please refer to <http://unlicense.org/>

#include "models/transmissionline/catenary_solver.h"

#include <cmath>

#include "models/transmissionline/cable_unit_load_calculator.h"

CatenarySolver::CatenarySolver() {
  cable_ = nullptr;
  constraint_ = nullptr;
  spacing_attachments_ = nullptr;

  is_updated_catenary_ = false;
}

CatenarySolver::~CatenarySolver() {
}

Catenary3d CatenarySolver::Catenary() const {
  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return Catenary3d();
    }
  }

  return catenary_;
}

bool CatenarySolver::Validate(
    const bool& is_included_warnings,
    std::list<ErrorMessage>* messages) const {
  // initializes
  bool is_valid = true;
  ErrorMessage message;
  message.title = "CATENARY SOLVER";

  // validates cable
  if (cable_ == nullptr) {
    is_valid = false;
    if (messages != nullptr) {
      message.description = "Invalid cable";
      messages->push_back(message);
    }
  } else {
    if (cable_->Validate(is_included_warnings, messages) == false) {
      is_valid = false;
    }
  }

  // validates constraint
  if (constraint_ == nullptr) {
    is_valid = false;
    if (messages != nullptr) {
      message.description = "Invalid constraint";
      messages->push_back(message);
    }
  } else {
    if (cable_->Validate(is_included_warnings, messages) == false) {
      is_valid = false;
    }
  }

  // validates spacing-attachments
  if (spacing_attachments_->x() <= 0) {
    is_valid = false;<commit_msg>CatenarySolver validation fix.<commit_after>// This is free and unencumbered software released into the public domain.
// For more information, please refer to <http://unlicense.org/>

#include "models/transmissionline/catenary_solver.h"

#include <cmath>

#include "models/transmissionline/cable_unit_load_calculator.h"

CatenarySolver::CatenarySolver() {
  cable_ = nullptr;
  constraint_ = nullptr;
  spacing_attachments_ = nullptr;

  is_updated_catenary_ = false;
}

CatenarySolver::~CatenarySolver() {
}

Catenary3d CatenarySolver::Catenary() const {
  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return Catenary3d();
    }
  }

  return catenary_;
}

bool CatenarySolver::Validate(
    const bool& is_included_warnings,
    std::list<ErrorMessage>* messages) const {
  // initializes
  bool is_valid = true;
  ErrorMessage message;
  message.title = "CATENARY SOLVER";

  // validates cable
  if (cable_ == nullptr) {
    is_valid = false;
    if (messages != nullptr) {
      message.description = "Invalid cable";
      messages->push_back(message);
    }
  } else {
    if (cable_->Validate(is_included_warnings, messages) == false) {
      is_valid = false;
    }
  }

  // validates constraint
  if (constraint_ == nullptr) {
    is_valid = false;
    if (messages != nullptr) {
      message.description = "Invalid constraint";
      messages->push_back(message);
    }
  } else {
    if (constraint_->Validate(is_included_warnings, messages) == false) {
      is_valid = false;
    }
  }

  // validates spacing-attachments
  if (spacing_attachments_->x() <= 0) {
    is_valid = false;
{'fraction_non_alphanumeric': 0.1211104331909701, 'fraction_numerical': 0.0018303843807199512, 'mean_word_length': 3.4673024523160763, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2352278', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1062, 'n_words': 237}