boipsolution.cpp 2.55 KB
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <boost/format.hpp>

#include "boipsolution.h"



BoipSolution::BoipSolution()
{
    l_ = 1;
}

BoipSolution::BoipSolution (float obj1, float obj2, std::vector< double > v) : obj1_(obj1), obj2_(obj2), v_(v)
{
    l_ = 1;
}

BoipSolution::BoipSolution (const BoipSolution & sol) : obj1_(sol.get_obj1_()), obj2_(sol.get_obj2_()), v_(sol.get_v_()), l_(sol.get_l_())
{
    l_ = 1;
}

BoipSolution::~BoipSolution()
{

}

float BoipSolution::get_obj1_() const
{
    return obj1_;
}

float BoipSolution::get_obj2_() const
{
    return obj2_;
}

std::vector< double > BoipSolution::get_v_() const
{
    return v_;
}

int BoipSolution::get_l_() const
{
    return l_;
}

void BoipSolution::set_obj1_(float obj1)
{
    obj1_ = obj1;
}

void BoipSolution::set_obj2_(float obj2)
{
    obj2_ = obj2;
}

void BoipSolution::set_v_(std::vector < double > v)
{
    v_ = v;
}

void BoipSolution::set_l_(int l)
{
    l_=l;
}

int BoipSolution::dominate( BoipSolution s){ //return 1 if this BoipSolution dominates s
    float s1 = s.get_obj1_();
    float s2 = s.get_obj2_();

    int dom = 0, obj1 = 0, obj2 = 0, strict1 = 0, strict2 = 0;

    if (s1 > obj1_){
        strict1 = 1;
        obj1 = 1;
    }
    else if ( std::abs(s1 - obj1_) < PRECISION ){
        obj1 = 1;
    }
    if (s2 > obj2_){
        strict2 = 1;
        obj2 = 1;
    }
    else if ( std::abs(s2 - obj2_) < PRECISION ){
        obj2 = 1;
    }

    if ( obj1 == 1 && obj2 == 1 && ( strict1 == 1 || strict2 == 1 ) ){
        dom = 1;
    }

    return dom;
}


// BoipChrSolution


BoipChrSolution::BoipChrSolution()
{
    l_ = 1;
}

BoipChrSolution::BoipChrSolution (float obj1, float obj2, std::vector< double > v,
                                  std::vector< std::vector < double > > varVC, std::vector < double > varColorUsed) :
    BoipSolution(obj1, obj2, v), varVC_(varVC), varColorUsed_(varColorUsed)
{
    l_ = 1;
}

BoipChrSolution::BoipChrSolution (const BoipChrSolution & sol) :
    BoipSolution(sol.obj1_, sol.obj2_, sol.v_),
    varVC_(sol.varVC_), varColorUsed_(sol.varColorUsed_)
{
    l_ = sol.l_;
}

BoipChrSolution::~BoipChrSolution()
{

}

std::vector< std::vector < double > > BoipChrSolution::get_varVC_() const
{
    return varVC_;
}

std::vector< double > BoipChrSolution::get_varColorUsed_() const
{
    return varColorUsed_;
}

void BoipChrSolution::set_varVC_(std::vector < std::vector < double > > varVC)
{
    varVC_ = varVC;
}

void BoipChrSolution::set_varColorUsed_(std::vector < double > varColorUsed)
{
    varColorUsed_ = varColorUsed;
}