When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
1 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
#define MATCHINGPROBLEM_H_INCLUDED
#pragma once
#include <vector>
#include <random>
#include <algorithm>
#include <iostream>
#include "GeneticAlgorithmSolver.h"
class GeneticAlgorithmSolver {
public:
GeneticAlgorithmSolver(const MatchingProblem& problem, int populationSize, int selectionSize);
void initialize(const std::vector<double>& lowerBounds, const std::vector<double>& upperBounds);
void iterate();
double getMaxParameterRange() const;
std::vector<double> getCurrentBest() const;
private:
const MatchingProblem& problem;
int populationSize;
int selectionSize;
std::vector<std::vector<double>> population;
std::vector<double> costs;
std::vector<double> lowerBounds;
std::vector<double> upperBounds;
std::default_random_engine rng;
void generateRandomParameters(std::vector<double>& parameters);
void evaluatePopulation();
void selectParents(std::vector<std::vector<double>>& parents);
void crossover(const std::vector<std::vector<double>>& parents, std::vector<std::vector<double>>& offspring);
void mutate(std::vector<std::vector<double>>& population);
};
#endif // MATCHINGPROBLEM_H_INCLUDED
!code
```cpp
int main() {}
```
int main() {}
How are you compiling your code?
mingw
And how are you compiling, i.e. with what command?
why is the header that seems to be matching problem.h define genetic algorithm solver
oh um is this g++ ?
normally you'd expect it to define matching problem
looks a bit like code block
so that'd be my bet
mandatory mention that beginner introductory videos don't have a good average quality
especially if it's only 1 hour
Also why are you declaring 2 functions inside your main?
should i be making it into only one function?
i've watched multiple
No, not necessarily, but you just can't declare functions inside other functions
oh? is that why it might be an error
There seem to be multiple errors like e.g. you not defining the class MatchingProblem anywhere but presumably defining GeneticAlgorithmSolver in 2 different header files (we only see the MatchingProblem.h file, but in there you defined GeneticAlgorithmSolver but never MatchingProblem.
Also in your header why are you using 2 include guards?
Either use the ifndef, define, endif chain or just use the pragma once, but there's no need for both in the same file
i see.. let me implement these and come back, thank you for having a look 
@native kestrel Has your question been resolved? If so, type !solved :)
ERROR MSG:
what do you expect this to do/achieve GeneticAlgorithmSolver solver(problem, numParameters, 5000, 100);
and how did you ensure it would work/succeed to do what you wanted
to set up the parameters of solver, with Nc (candidate parameter sets) = 5000 and Ns (solutions taken to be parents to form next generation) = 100
this would find their costs, and sort list in order of increasing cost i think
you didn't answer the second part
got to leave but GeneticAlgorithmSolver is a type
you want to create an instance of it
to do that you need a constructor that matches the argument you're passing in
you're passing in 4 arguments
there are no constructor that take 4 arguments
oh is this to do with the cpp file for it...?
might I suggest you take up a tutorial on how to write classes in c++
okay
hi i'm so sorry, but i'm getting this error now? i'm not sure if its my code or my project's settings? ðŸ˜
or something with the void parts of my code
where did you define those member functions
most likely you've put them in their own .cpp files, so the question is how you've told codeblocks that those files were part of your project, and should be compiled and linked together with whatever .cpp file contains your main function
I think it also has to be said by this point that I really don't recommend using codeblock as your c++ ide, but I also was too lazy to argue the point or try to figure out if you had any constraints that forced you to use it
unfortunately i'm required to use codeblocks ðŸ˜

haven't looked in details but you have multiple .cpp files, so the pending issue is how yo'uve told codeblocks about all of them
based just on that it seems likely you have told it about them, because it doesn't seem like you have a codeblock project
so I'd assume that in some way shape or form codeblocks is only trying to compile one cpp file
and I don't use codeblock so I can't help you with setting that up
cause you seem to be using codeblocks builtin build system
ok but being in the same folder means little to codeblock
like codeblock almost certainly shouldn't try to compile CW3.layout
oh
so that's generally just not how it works
the build system has to be told in some way about what files are part of the project and what files it has to deal with
google "codeblock multiple files compilation" or "codeblock setting up project" or whatever
@native kestrel Has your question been resolved? If so, type !solved :)
I don't follow why you would/should
about any project setup allows you to add existing files
and if codeblock doesn't with its projects then it's really something that politically correct speech cannot name
This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.
!howto ask
Anyone can ask a question in our programming channels. Following the guide Writing The Perfect Question is recommended.
State your problem clearly and provide all necessary details:
Provide the relevant code in the message, and format it nicely with a code block*. If it's too much for one message, you can upload it:
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity