5 #ifndef DIGNEA_PROBLEM_H
6 #define DIGNEA_PROBLEM_H
8 #include <dignea/core/Solution.h>
9 #include <dignea/utilities/random/ParallelPRNG.h>
13 #include <nlohmann/json.hpp>
19 enum optimisationDirection { Minimize, Maximize };
33 Problem(
const int &numberOfVars,
const int &numberOfObjectives,
68 virtual S createSolution(ParallelPRNG &engine)
const = 0;
112 virtual void readData(
const std::string &path) = 0;
179 : numberOfVars(ind->numberOfVars),
180 numberOfObjs(ind->numberOfObjs),
181 numberOfCons(ind->numberOfCons) {}
193 : numberOfVars(nVars), numberOfObjs(nObjs), numberOfCons(nCons) {}
203 data[
"name"] = this->getName();
204 data[
"num_objs"] = this->numberOfObjs;
205 data[
"num_vars"] = this->numberOfVars;
206 data[
"num_cons"] = this->numberOfCons;
207 data[
"up_limit"] = this->getUpperLimit(0);
208 data[
"low_limit"] = this->getLowerLimit(0);
nlohmann::json json
Definition: MinKnap.h:85
Class to represent a Problem in the tool. It includes the basic information for a problem a few metho...
Definition: Problem.h:29
int getNumberOfVars() const
Get the number of variables (dimension) of the problem.
Definition: Problem.h:122
virtual void readData(const std::string &path)=0
Method to read problem information from the given path. This method must be implemented in the subcla...
virtual S createSolution() const =0
Creates a new solution for the problem. Usually uses problem information and generates a solution ran...
int numberOfVars
Definition: Problem.h:155
void setNumberOfObjs(int nObjs)
Sets the number of objectives to the problem.
Definition: Problem.h:142
virtual float getLowerLimit(const int i) const =0
Returns the lower bound to the problem at dimension i. This method must be implemented in the subclas...
int getNumberOfObjs() const
Get the number of objectives of the problem.
Definition: Problem.h:135
virtual bool evaluateConstraints(S &sol) const =0
Method to evaluate whether a solution is feasible or not. This method must be implemented in the subc...
virtual json to_json() const
Creates a JSON object with the information of the Problem.
Definition: Problem.h:201
Problem(const int &numberOfVars, const int &numberOfObjectives, const int &nCons)
Construct a new Problem with all the given parameters.
Definition: Problem.h:192
int getNumberOfCons() const
Get the number the constraint of the problem.
Definition: Problem.h:149
int numberOfObjs
Definition: Problem.h:159
void setNumberOfCons(int nCons)
Sets the number of constraint of the problem.
Definition: Problem.h:155
virtual string getName() const =0
Returns the name of the problem. This method must be implemented in the subclasses.
virtual void evaluate(S &sol) const =0
Method to evaluate a solution using the proper problem formulation. This method must be implemented i...
virtual int getOptimizationDirection(const int i) const =0
Returns the optimization direction for each objective in the problem. It returns Minimize or Maximize...
void setNumberOfVars(int nVars)
Sets the number of variables (dimension) of the problem.
Definition: Problem.h:128
virtual float getUpperLimit(const int i) const =0
Returns the upper bound to the problem at dimension i. This method must be implemented in the subclas...
int numberOfCons
Definition: Problem.h:160
Problem()
Creates a new Problem with all parameters to zero.
Definition: Problem.h:169