#include "DualSolution.h"

DualSolution::DualSolution() : pi() {
}

DualSolution::DualSolution(const vector<double>& pi, const vector<double>& gamma, const vector<double>& sigma, const double& beta)
    : pi(pi), gamma(gamma), beta(beta), sigma(sigma) {
}

DualSolution::DualSolution(const DualSolution& dual_solution) : pi(dual_solution.pi), gamma(dual_solution.gamma), sigma(dual_solution.sigma), beta(dual_solution.beta) {
}

DualSolution::~DualSolution()
{
}


double DualSolution::get_pi_i(const int i) const {
    assert(i >=0 && i < this->pi.size());
    return this->pi.at(i);
}

double DualSolution::get_gamma_i(const int i) const {
    assert(i >= 0 && i < this->gamma.size());
    return this->gamma.at(i);
}

double DualSolution::get_sigma_i(const int i) const {
    assert(i >= 0 && i < this->sigma.size());
    return this->sigma.at(i);
}

const vector<double>& DualSolution::get_sigma() const {
    return this->sigma;
}

double DualSolution::get_beta() const {
    return this->beta;
}

string DualSolution::toString() const {
    string str = "DUAL BOUND\t" + to_string(this->beta) + "\n";
    for (int i = 0; i < this->pi.size(); i++) {
        str += "PACK\t" + to_string(i) + "\t" + to_string(this->pi.at(i)) + "\n";
    }
    for (int i = 0; i < this->gamma.size(); i++) {
        str += "BRANCH\t" + to_string(i) + "\t" + to_string(this->gamma.at(i)) + "\n";
    }
    for (int i = 0; i < this->sigma.size(); i++) {
        str += "SSI\t" + to_string(i) + "\t" + to_string(this->sigma.at(i)) + "\n";
    }
    return str;
}

DualSolution& DualSolution::operator=(const DualSolution& new_dual_solution) {
    this->pi = new_dual_solution.pi;
    this->gamma = new_dual_solution.gamma;
    this->beta = new_dual_solution.beta;
    this->sigma = new_dual_solution.sigma;
    return *this;
}
