richelbilderbeek / pbdmms

Some models
GNU General Public License v3.0
2 stars 0 forks source link

sado: Create correct tree from species pedigree #241

Closed Lumphie closed 7 years ago

Lumphie commented 7 years ago

right now my function correctly graphs all the species, but still has to group different species together if the end up (some generations later) in 1 species. testing_graph

Lumphie commented 7 years ago

Desired result:

 3    4     <--- generation 2
 |    |
 1    2     <---- generation 1
   \ /
    |
    0         <--- generation 0
Lumphie commented 7 years ago

Yay I broke the boost graph

runtime error: member access within misaligned address [some memory location] for type 'const struct pair', which requires 8 byte alignment

Lumphie commented 7 years ago

`/usr/include/c++/5/ext/new_allocator.h:120:4: runtime error: constructor call on misaligned address 0xb780f000b7817 for type 'struct pair', which requires 8 byte alignment 0xb780f000b7817: note: pointer points here

`
Lumphie commented 7 years ago

I think I found the error.

Lumphie commented 7 years ago

I was trying to change something outside the borders of a vector, as I like to do often because I forget to assert the ranges I'm looking for. Now trying to find how the value got outside the borders of the vector.

Lumphie commented 7 years ago

I'm making a vector of size n. Where n is the generation number of the last species in the vector I get from the input. Maybe the last species is not necessarily the one with the highest generation number.

Will make a for loop that looks for the highest generation number in all the species.

Lumphie commented 7 years ago

That did not work.

Lumphie commented 7 years ago

Aaaaaah

Why didn't I find that sooner.

My vector has the correct size (3) but I forgot that I number my generations as generation 1, generation 2, generation 3.

So if I look in the vector[3] it will not work because I should look for vector[2].

That's a mistake I haven't made in a long time.

Lumphie commented 7 years ago

thank you assert() and std::cout for finding this error.

Lumphie commented 7 years ago

The code looks horrible and is terribly slow, but it should work now.

Lumphie commented 7 years ago

sado_test: malloc.c:3695: _int_malloc: Assertion (unsigned long) (size) >= (unsigned long) (nb) failed.

God damnit

Lumphie commented 7 years ago

same mistake as above. Num_gen is the number of generations (which is 3) and another vector I'm looking in is size 3.

Lumphie commented 7 years ago

too many empty species and looking outside of vectors.

Can you have a look @richelbilderbeek ?

Lumphie commented 7 years ago

I think I fixed it.

Problem was that in a directed graph you have to make sure you check the right way.

edge between vd1 and vd2 does not mean edge between vd2 and vd1.

I'm not sure if this is in your tutorial @richelbilderbeek

Lumphie commented 7 years ago

Yes it passed!

Since I edited it in the online github editor I can't check if it procudes the right graphs, but I'll look at that tomorrow.

Or if you actually looked at the clock you knew I meant today.

Lumphie commented 7 years ago

testing_graph

So close. It doesn't do the last generation. That should be doable.

Lumphie commented 7 years ago

Correction: It does not do the last generation and does the 0th generation wrong.

richelbilderbeek commented 7 years ago

I'm not sure if this is in your tutorial @richelbilderbeek

AFAIKS, it is absent in the tutorial. Thanks for posting this at https://github.com/richelbilderbeek/BoostGraphTutorial/issues/44 and I will implement it one day.

Lumphie commented 7 years ago

Somehow there are 2 species to start with in a temporary vector. That vector should be empty.

Lumphie commented 7 years ago

testing_graph

Getting there.

Lumphie commented 7 years ago

This is happening:

[0]  [1]
 |\  /|
 | \/ |
 | /\ |
[a]  [b]

a <- 0 true so: Fixed[a] += a a <= 1 true so: Fixed[b] += a b <- 0 true so: Fixed[a] += b b <= 1 true so: Fixed[b] += b

Instead of just creating 1 single species (Fixed[a])

Lumphie commented 7 years ago

I just don't know. Do you know how to do fix this. The code is a mess. sado_species_graph.cpp

@richelbilderbeek

richelbilderbeek commented 7 years ago

Just follow the advice of OCLint: cut it to pieces, into multiple smaller (thus better testable) functions.

I hope you have not been doing this: do not optimize for high runtime speed before measuring: slow code that runs is preferred over fast code that does not run.

Lumphie commented 7 years ago

It does run, but I don't know how to merge species correctly. I might go back a few steps next monday.

richelbilderbeek commented 7 years ago

I guess it has been done, use sado::to_newick