martin1887 / oxigen Goto Github PK
View Code? Open in Web Editor NEWFast, parallel, extensible and adaptable genetic algorithms framework written in Rust
License: Mozilla Public License 2.0
Fast, parallel, extensible and adaptable genetic algorithms framework written in Rust
License: Mozilla Public License 2.0
I noticed that travis tends to build 3.0 just fine, so I wonder if I'm missing something here, perhaps the wrong rust version.
When building 3.0 I get the following compilation error:
error[E0046]: not all trait items implemented, missing: `GenotypeHash`, `hash`
--> onemax-oxigen/src/main.rs:19:1
|
19 | impl Genotype<bool> for OneMax {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `GenotypeHash`, `hash` in implementation
|
= help: implement the missing item: `type GenotypeHash = Type;`
= help: implement the missing item: `fn hash(&self) -> <Self as oxigen::Genotype<T>>::GenotypeHash { unimplemented!() }`
error[E0046]: not all trait items implemented, missing: `GenotypeHash`, `hash`
--> knapsack-oxigen/src/main.rs:52:1
|
52 | impl<'a> Genotype<bool> for Knapsack<'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `GenotypeHash`, `hash` in implementation
|
= help: implement the missing item: `type GenotypeHash = Type;`
= help: implement the missing item: `fn hash(&self) -> <Self as oxigen::Genotype<T>>::GenotypeHash { unimplemented!() }`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0046`.
error: could not compile `onemax-oxigen`.
warning: build failed, waiting for other jobs to finish...
error: aborting due to previous error
For more information about this error, try `rustc --explain E0046`.
error: could not compile `knapsack-oxigen`.
warning: build failed, waiting for other jobs to finish...
error: build failed
I was under the impression that there was a default hash implementation for these items, so I'm unsure what could be causing the problem. Any idea?
Thanks
Hello,
See below:
error[E0046]: not all trait items implemented, missing: GenotypeHash
, hash
--> onemax-oxigen/src/main.rs:19:1
|
19 | impl Genotype for OneMax {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing GenotypeHash
, hash
in implementation
|
= help: implement the missing item: type GenotypeHash = Type;
= help: implement the missing item: fn hash(&self) -> <Self as oxigen::Genotype<T>>::GenotypeHash { todo!() }
error[E0046]: not all trait items implemented, missing: GenotypeHash
, hash
--> knapsack-oxigen/src/main.rs:52:1
|
52 | impl<'a> Genotype for Knapsack<'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing GenotypeHash
, hash
in implementation
|
= help: implement the missing item: type GenotypeHash = Type;
= help: implement the missing item: fn hash(&self) -> <Self as oxigen::Genotype<T>>::GenotypeHash { todo!() }
For more information about this error, try rustc --explain E0046
.
error: could not compile onemax-oxigen
due to previous error
warning: build failed, waiting for other jobs to finish...
warning: panic message is not a string literal
--> fd-oxigen/src/main.rs:220:25
|
220 | _ => panic!(format!("Incorrect index passed to n_values: {}", index)),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(non_fmt_panics)]
on by default
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html
= note: the panic!() macro supports formatting, so there's no need for the format!() macro here
help: remove the format!(..)
macro call
|
220 - _ => panic!(format!("Incorrect index passed to n_values: {}", index)),
220 + _ => panic!("Incorrect index passed to n_values: {}", index),
|
warning: fd-oxigen
(bin "fd-oxigen") generated 1 warning
error: build failed
Thanks,
Jianshu
rustc 1.52.0-nightly (83b30a639 2021-02-20)
Build with error message:
error[E0046]: not all trait items implemented, missing: `GenotypeHash`, `hash`
--> onemax-oxigen/src/main.rs:19:1
|
19 | impl Genotype<bool> for OneMax {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `GenotypeHash`, `hash` in implementation
|
= help: implement the missing item: `type GenotypeHash = Type;`
= help: implement the missing item: `fn hash(&self) -> <Self as oxigen::Genotype<T>>::GenotypeHash { todo!() }`
error[E0046]: not all trait items implemented, missing: `GenotypeHash`, `hash`
--> knapsack-oxigen/src/main.rs:52:1
|
52 | impl<'a> Genotype<bool> for Knapsack<'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `GenotypeHash`, `hash` in implementation
|
= help: implement the missing item: `type GenotypeHash = Type;`
= help: implement the missing item: `fn hash(&self) -> <Self as oxigen::Genotype<T>>::GenotypeHash { todo!() }`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0046`.
error: could not compile `onemax-oxigen`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: aborting due to previous error
For more information about this error, try `rustc --explain E0046`.
error: build failed
Is your feature request related to a problem? Please describe.
I am attempting to optimize for a graph-related problem and would like to create a genotype whose fitness
function is calculated based on some reference graph, which ideally would be part of some read-only environment.
It seems that, internally in oxigen/lib.rs
, fitness is calculated for individuals generated with generate
(see here), which can only take in a ProblemSize
instance passed via genotype_size()
.
So, either it appears that any fitness
method I define cannot refer to the graph I wish to optimize against because that is decided at runtime or I must smuggle the graph in as part of the ProblemSize
passed into the genotype_size()
method. Is this the correct interpretation?
In effect, ProblemSize
is acting as the environment type and field. For example, it appears this is the case in the knap-sack example where the items
are constructed (see here) and passed in as part of the problem size.
Describe the solution you'd like
Rename
ProblemSize
genotype_size(mut self, new_size: Ind::ProblemSize)
, andGeneticExecution.genotype_size
to
Environment
set_environment(mut self, env: Ind::Environment)
, andGeneticExecution.environment
, respectivelyDescribe alternatives you've considered
No alternatives considered.
Additional context
No additional context.
The Genotype iter and into_iter methods should return a Type that implements the Iterator and IntoIterator traits and not the specific implementation of these traits for slices.
This would improve usability of the framework
Seems like a comment for the N Queen example instead.
oxigen/knapsack-oxigen/src/main.rs
Lines 79 to 81 in c39aee2
Would it be possible to provide more examples?
I'd like to see how a more simple problem is tackled with oxigen, so to see how the mechanism works. Could this example (https://deap.readthedocs.io/en/master/examples/ga_onemax.html) be translated to oxigen?
I really would like to help, but my Rust-knowledge is not good enough...
Thanks in advance!
I like the way a new GeneticExecution object is built.
According to the Rust Guidelines, although, there should be another object, called ...Builder
, that provides such an API.
The builder methods could take &mut Builder and return the reference, thus being more flexible, while only the final method, that build the actual object, would take the ownership.
On the final type, methods that have the name of a field should be getters for that field instead.
Why at a certain point the optimizer starts to generate individuals with a minor number of elements?
Is it intended behavior?
How can this effect be counteracted?
Thanks!
Is your feature request related to a problem? Please describe.
My use case involves very large numbers whose precision I'd like to maintain. Casting my BigInt
type to an f64
causes a loss of information.
Describe the solution you'd like
Polymorphic fitness types, e.g. changing
fn fitness(&self) -> f64
to something like
fn fitness(&self) -> S where
S: std::ops::Add {
...
}
Describe alternatives you've considered
Casting my big int type to f64
(which is my current fix)
I'd be willing to help with this myself if it's of interest
The word 'cuadratic' doesn't exist in english. You probably meant 'quadratic'.
Describe the bug
Oxigen fails to create the next generation of individuals.
To Reproduce
I'm not sure how to reproduce it with a simple use case, but I can reproduce it systematically with a small variation to the orbit_design_ga project. Specifically, if my genome is only one gene long, this problem shows up. Two or more genes, and it doesn't happen.
I understand/expect that the information I provide is not enough to fix. Hence, can you explain to me in which cases the following line from crossover.rs
would fail:
let cross_point = SmallRng::from_entropy().sample(Uniform::from(1..ind_size));
I'm guessing that ind_size
is zero, but I don't know what would cause it to be zero.
Thanks for your help
Stack trace
Running `target/debug/orbit_design_ga`
Fitness: 2000
Fitness: 2001
Fitness: 2001
Fitness: 2001
Fitness: 2000
Fitness: 2001
Fitness: 2000
Fitness: 2001
Fitness: 0
Fitness: 0
Fitness: 0
Fitness: 2000
Fitness: 2001
Fitness: 2000
Fitness: 2001
Fitness: 2001
thread 'main' panicked at 'Uniform::new called with `low >= high`', /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.7.3/src/distributions/uniform.rs:477:1
stack backtrace:
0: std::panicking::begin_panic
at /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:519:12
1: <rand::distributions::uniform::UniformInt<usize> as rand::distributions::uniform::UniformSampler>::new
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.7.3/src/distributions/uniform.rs:379:17
2: rand::distributions::uniform::Uniform<X>::new
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.7.3/src/distributions/uniform.rs:172:17
3: <rand::distributions::uniform::Uniform<X> as core::convert::From<core::ops::range::Range<X>>>::from
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.7.3/src/distributions/uniform.rs:272:9
4: <oxigen::crossover::CrossoverFunctions as oxigen::crossover::Crossover<T,G>>::cross
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/oxigen-2.2.0/src/crossover.rs:31:67
5: oxigen::GeneticExecution<T,Ind>::cross::{{closure}}
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/oxigen-2.2.0/src/lib.rs:639:40
6: core::ops::function::impls::<impl core::ops::function::Fn<A> for &F>::call
at /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:237:13
7: <rayon::iter::map_with::MapWithFolder<C,U,F> as rayon::iter::plumbing::Folder<T>>::consume_iter::with::{{closure}}
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/map_with.rs:317:22
8: core::iter::adapters::map::map_fold::{{closure}}
at /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:80:28
9: core::iter::traits::iterator::Iterator::fold
at /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2023:21
10: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
at /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:120:9
11: core::iter::traits::iterator::Iterator::for_each
at /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:678:9
12: <rayon::iter::noop::NoopConsumer as rayon::iter::plumbing::Folder<T>>::consume_iter
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/noop.rs:34:9
13: <rayon::iter::map_with::MapWithFolder<C,U,F> as rayon::iter::plumbing::Folder<T>>::consume_iter
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/map_with.rs:322:25
14: rayon::iter::plumbing::Producer::fold_with
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/plumbing/mod.rs:110:9
15: rayon::iter::plumbing::bridge_producer_consumer::helper
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/plumbing/mod.rs:438:13
16: rayon::iter::plumbing::bridge_producer_consumer
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/plumbing/mod.rs:397:12
17: <rayon::iter::plumbing::bridge::Callback<C> as rayon::iter::plumbing::ProducerCallback<I>>::callback
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/plumbing/mod.rs:373:13
18: <rayon::range::Iter<usize> as rayon::iter::IndexedParallelIterator>::with_producer
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/range.rs:112:17
19: rayon::iter::plumbing::bridge
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/plumbing/mod.rs:357:12
20: <rayon::range::Iter<usize> as rayon::iter::ParallelIterator>::drive_unindexed
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/range.rs:88:17
21: <rayon::iter::map_with::MapWith<I,T,F> as rayon::iter::ParallelIterator>::drive_unindexed
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/map_with.rs:53:9
22: rayon::iter::from_par_iter::<impl rayon::iter::FromParallelIterator<()> for ()>::from_par_iter
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/from_par_iter.rs:226:9
23: rayon::iter::ParallelIterator::collect
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/mod.rs:1973:9
24: rayon::iter::ParallelIterator::for_each_with
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.0/src/iter/mod.rs:400:9
25: oxigen::GeneticExecution<T,Ind>::cross
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/oxigen-2.2.0/src/lib.rs:626:9
26: oxigen::GeneticExecution<T,Ind>::run_loop
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/oxigen-2.2.0/src/lib.rs:345:36
27: oxigen::GeneticExecution<T,Ind>::run
at /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/oxigen-2.2.0/src/lib.rs:311:49
28: orbit_design_ga::main
at ./src/main.rs:32:9
29: core::ops::function::FnOnce::call_once
at /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.