nojhan / paradiseo

An evolutionary computation framework to (automatically) build fast parallel stochastic optimization solvers
https://nojhan.github.io/paradiseo/
Other
92 stars 33 forks source link

‘make_from_tuple’ is not a member of ‘std’ #66

Open filipesaraiva opened 2 years ago

filipesaraiva commented 2 years ago

Hello, I built and installed paradiseo-3.0.0-beta and now I am having a problem trying to build my own code. Examples below.

CMakeList.txt:

cmake_minimum_required(VERSION 3.5)

project(knapsack-paradiseo LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(knapsack-paradiseo main.cpp)

main.cpp:

#include <stdexcept>  // runtime_error
#include <iostream>    // cout
#include <strstream>  // ostrstream, istrstream

#include <paradiseo/eo/eo>
#include <paradiseo/eo/eoSGA.h>
#include <paradiseo/eo/ga/eoBit.h>
#include <paradiseo/eo/eoPop.h>
#include <paradiseo/eo/eoEvalFuncPtr.h>
#include <paradiseo/eo/utils/eoRndGenerators.h>

using namespace std;

typedef eoBit<double> Indi;

double binary_value(const Indi & _indi)
{
 double sum = 0;
 for (unsigned i = 0; i < _indi.size(); i++)
     sum += _indi[i];
 return sum;
}

int main()
{
    const unsigned int SEED = 42;          // seed for random number generator
    const unsigned int T_SIZE = 3;        // size for tournament selection
    const unsigned int VEC_SIZE = 8;    // Number of bits in genotypes
    const unsigned int POP_SIZE = 20;  // Size of population
    const unsigned int MAX_GEN = 100;  // Maximum number of generation before STOP
    const float CROSS_RATE = 0.8;          // Crossover rate
    const double P_MUT_PER_BIT = 0.01; // probability of bit-flip mutation
    const float MUT_RATE = 1.0;              // mutation rate

    rng.reseed(SEED);

    // Evaluation: from a plain C++ fn to an EvalFunc Object
    eoEvalFuncPtr<Indi> eval(binary_value);

    eoPop<Indi> pop;
    for (unsigned int igeno=0; igeno<POP_SIZE; igeno++)
     {
         Indi v;                    // void individual, to be filled
         for (unsigned ivar=0; ivar<VEC_SIZE; ivar++)
             {
                 bool r = rng.flip(); // new value, random in {0,1}
                 v.push_back(r);          // append that random value to v
             }
         eval(v);                                // evaluate it
         pop.push_back(v);              // and put it in the population
     }
     // sort pop before printing it!
     pop.sort();
     // Print (sorted) intial population (raw printout)
     cout << "Initial Population" << endl;
     cout << pop;

    return 0;
}

The cmake .. command output is:

$ cmake ..
-- The CXX compiler identification is GNU 11.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/filipe/Desenvolvimento/knapsack-paradiseo/build

and the make output is:

$ make -j
[ 50%] Building CXX object CMakeFiles/knapsack-paradiseo.dir/main.cpp.o
In file included from /usr/include/c++/11.2.0/backward/strstream:50,
                 from /home/filipe/Desenvolvimento/knapsack-paradiseo/main.cpp:3:
/usr/include/c++/11.2.0/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
   32 | #warning \
      |  ^~~~~~~
In file included from /usr/local/include/paradiseo/eo/eo:164,
                 from /home/filipe/Desenvolvimento/knapsack-paradiseo/main.cpp:5:
/usr/local/include/paradiseo/eo/eoForge.h: In member function ‘Op* eoForgeOperator<Itf, Op, Args>::op_constructor(T&)’:
/usr/local/include/paradiseo/eo/eoForge.h:150:32: error: ‘make_from_tuple’ is not a member of ‘std’
  150 |             return new Op(std::make_from_tuple<Op>(args));
      |                                ^~~~~~~~~~~~~~~
/usr/local/include/paradiseo/eo/eoForge.h:150:32: note: ‘std::make_from_tuple’ is only available from C++17 onwards
/usr/local/include/paradiseo/eo/eoForge.h:150:50: error: expected primary-expression before ‘>’ token
  150 |             return new Op(std::make_from_tuple<Op>(args));
      |                                                  ^
/usr/local/include/paradiseo/eo/eoForge.h: In member function ‘void eoForgeVector<Itf, Enable>::add(Args ...)’:
/usr/local/include/paradiseo/eo/eoForge.h:267:56: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?
  267 |             auto pfo = new eoForgeOperator<Itf,Op,std::decay_t<Args>...>(
      |                                                        ^~~~~~~
      |                                                        decay
/usr/local/include/paradiseo/eo/eoForge.h:267:56: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?
  267 |             auto pfo = new eoForgeOperator<Itf,Op,std::decay_t<Args>...>(
      |                                                        ^~~~~~~
      |                                                        decay
/usr/local/include/paradiseo/eo/eoForge.h:267:68: error: template argument 3 is invalid
  267 |             auto pfo = new eoForgeOperator<Itf,Op,std::decay_t<Args>...>(
      |                                                                    ^
/usr/local/include/paradiseo/eo/eoForge.h: In member function ‘void eoForgeVector<Itf, Enable>::setup(size_t, Args ...)’:
/usr/local/include/paradiseo/eo/eoForge.h:295:56: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?
  295 |             auto pfo = new eoForgeOperator<Itf,Op,std::decay_t<Args>...>(
      |                                                        ^~~~~~~
      |                                                        decay
/usr/local/include/paradiseo/eo/eoForge.h:295:56: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?
  295 |             auto pfo = new eoForgeOperator<Itf,Op,std::decay_t<Args>...>(
      |                                                        ^~~~~~~
      |                                                        decay
/usr/local/include/paradiseo/eo/eoForge.h:295:68: error: template argument 3 is invalid
  295 |             auto pfo = new eoForgeOperator<Itf,Op,std::decay_t<Args>...>(
      |                                                                    ^
make[2]: *** [CMakeFiles/knapsack-paradiseo.dir/build.make:76: CMakeFiles/knapsack-paradiseo.dir/main.cpp.o] Erro 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/knapsack-paradiseo.dir/all] Erro 2
make: *** [Makefile:91: all] Erro 2

It is like the paradiseo compilation is not supporting the make_from_tuple function, despite the building and installation of the framework was correct.

Well, any idea about what is happening here?

All the best;