#pragma once #include #include struct Solution { std::vector bitstring; double objectiveFunctionValue; Solution(); Solution(std::vector bitstring, double objectiveFunctionValue); std::string bitstringToStdString(); }; namespace objective { double onemaxLinear(const std::vector& bitstring); double onemaxWithTrap(const std::vector& bitstring); double onemaxTrigger(const std::vector& bitstring); class OneMax{ public: std::vector results; OneMax(int n, int k); void generateKStep(int k); double function(const std::vector&); }; // struct Item { double value; double weight; }; class KnapsackProblem { public: KnapsackProblem(double weightLimit,double limitPenalty); // List of items that can be selected std::vector itemVec; // Limit of the maximum weight that will apply the penalty double weightLimit; // The penalty for exceeding the limit double limitPenalty; double function(const std::vector&); }; }