std::map.at("...")
is throwing an out_of_range exception, but when I iterate over the map with an iterator, and when I call map.find("...")
, it can find the key. Also, at a previous point in the program, map.at("...")
is working on the same key as expected. After doing a find/search through the code base, the only methods I am invoking on the map are map["..."] = ...
to insert values, and then a whole lot of map.at("...")
to retrieve, so I don't have any idea why this isn't working.
I thought I already explained the relevant parts. |
|
|
.. ... ... dot_dot_dot AAA aaa dot_dot_dot .. ... ... xyz AAA aaa Program ended with exit code: 0 |
|
|
std::map<std::string, std::vector<double>>
C:\Users\mathh\GitHub\Molecular-Spintronics-Research-Project\MSD_Research_Project_01-25-2020\MSD Research Project (v2.2.0)>bin\metropolis parameters-metropolis.txt "out\metropolis, CONTINUOUS_SPIN_MODEL, 01-29-2020, 4.xml" CONTINUOUS_SPIN_MODEL 1 0% [0 days, 0: 0: 1] -- AL => 0.50 -- AR => 0.50 -- Am => 0.00 -- B_x => 0.00 -- B_y => -1.50 -1.45 -1.40 -1.35 -1.30 -1.25 -1.20 -1.15 -1.10 -1.05 -1.00 -0.95 -0.90 -0.85 -0.80 -0.75 -0.70 -0.65 -0.60 -0.55 -0.50 -0.45 -0.40 -0.35 -0.30 -0.25 -0.20 -0.15 -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 -- B_z => 0.00 -- JL => 1.00 -- JLR => 0.00 -- JR => 1.00 -- Jm => 0.00 -- JmL => 0.20 -- JmR => -0.20 -- bL => 0.00 -- bLR => 0.00 -- bR => 0.00 -- backR => 6.00 -- bm => 0.00 -- bmL => 0.00 -- bmR => 0.00 -- bottomL => 6.00 -- depth => 10.00 -- freq => 1.00 -- frontR => 3.00 -- height => 10.00 -- kT => 0.34 -- molPosL => 5.00 -- molPosR => 5.00 -- simCount => 0.00 -- t_eq => 10000.00 -- topL => 3.00 -- width => 11.00 -- 1 Parameter file is missing some data! invalid map<K, T> key ---------------------------------------- Wed 01/29/2020 02:13 AM Press any key to continue . . . |
|
|
width = 11 height = 10 depth = 10 molPosL = 5 molPosR = 5 topL = 3 bottomL = 6 frontR = 3 backR = 6 t_eq = 10000 simCount = 0 freq = 1 kT = 0.34 B_x = 0 B_y : -1.5 1.5 0.05 B_z = 0 JL = 1 JR = 1 Jm = 0 JmL = 0.2 JmR = -0.2 JLR = 0 AL = 0.5 AR = 0.5 Am = 0 bL = 0 bR = 0 bm = 0 bmL = 0 bmR = 0 bLR = 0 |
g++ iterate.cpp heat.cpp extract.cpp magnetize.cpp spin-test.cpp metropolis.cpp simple_msd_sim.cpp |
In file included from iterate.cpp:10: MSD.h:135:43: error: extra qualification 'udc::MSD::' on member 'rand' [-fpermissive] uniform_real_distribution<double> MSD::rand; //uniform probability density function on the interval [0, 1) ^~~ <MASSES OF SIMILAR ERRORS> ^~~ metropolis.cpp: In function 'int main(int, char**)': metropolis.cpp:250:64: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] recordVar( doc, *global, "param", "width", p.at("width")[0] ); ^ metropolis.cpp:254:68: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] metropolis.cpp:255:62: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] recordVar( doc, *global, "param", "topL", p.at("topL")[0] ); ^ ^ <MASSES OF SIMILAR ERRORS> ^~~ In file included from metropolis.cpp:19: rapidxml_print.hpp: In instantiation of 'OutIt rapidxml::internal::print_node(OutIt, const rapidxml::xml_node<Ch>*, int, int) [with OutIt = std::ostream_iterator<char, char, std::char_traits<char> >; Ch = char]': rapidxml_print.hpp:390:36: required from 'OutIt rapidxml::print(OutIt, const rapidxml::xml_node<Ch>&, int) [with OutIt = std::ostream_iterator<char, char, std::char_traits<char> >; Ch = char]' rapidxml_print.hpp:403:14: required from 'std::basic_ostream<Ch>& rapidxml::print(std::basic_ostream<Ch>&, const rapidxml::xml_node<Ch>&, int) [with Ch = char]' rapidxml_print.hpp:414:21: required from 'std::basic_ostream<Ch>& rapidxml::operator<<(std::basic_ostream<Ch>&, const rapidxml::xml_node<Ch>&) [with Ch = char]' metropolis.cpp:283:11: required from here rapidxml_print.hpp:115:37: error: 'print_children' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] out = print_children(out, node, flags, indent); ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ rapidxml_print.hpp:169:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_children(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent) ^~~~~~~~~~~~~~ rapidxml_print.hpp:120:41: error: 'print_element_node' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] out = print_element_node(out, node, flags, indent); ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ rapidxml_print.hpp:242:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_element_node(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent) ^~~~~~~~~~~~~~~~~~ rapidxml_print.hpp:125:38: error: 'print_data_node' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] out = print_data_node(out, node, flags, indent); ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ rapidxml_print.hpp:208:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_data_node(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent) ^~~~~~~~~~~~~~~ <MASSES OF SIMILAR ERRORS> ^~~ ^~~~~~~~~~~~~ In file included from simple_msd_sim.cpp:16: MSD.h:135:43: error: extra qualification 'udc::MSD::' on member 'rand' [-fpermissive] uniform_real_distribution<double> MSD::rand; //uniform probability density function on the interval [0, 1) ^~~ |
Unit testing for this program would be a nightmare to develop. |
Mathhead200 wrote: |
---|
I know it's being caused by that line |
|
|
|
|
|
|
0% [0 days, 0: 0: 0] -- AL => 0.50 -- AR => 0.50 -- Am => 0.00 -- B_x => 0.00 -- B_y => -1.50 -- B_z => 0.00 -- JL => 1.00 -- JLR => 0.00 -- JR => 1.00 -- Jm => 0.00 -- JmL => 0.20 -- JmR => -0.20 -- bL => 0.00 -- bLR => 0.00 -- bR => 0.00 -- backR => 6.00 -- bm => 0.00 -- bmL => 0.00 -- bmR => 0.00 -- bottomL => 6.00 -- depth => 10.00 -- freq => 1.00 -- frontR => 3.00 -- height => 10.00 -- kT => 0.34 -- molPosL => 5.00 -- molPosR => 5.00 -- simCount => 0.00 -- t_eq => 10000.00 -- topL => 3.00 -- width => 11.00 Success! About to run algorithm ... OK1 N=10000 Got past random Got past getResults i=0 i=1 i=2 i=3 i=4 i=5 |
|
|
|
|
vec_dbl_1 1 0.5 0.333333 0.25 0.2 vec_dbl_2 0.192708 0.183168 0.174528 0.166667 0.159483 0.152893 0.146825 xy prob 0.192708 0.183168 0.174528 0.166667 0.159483 0.152893 0.146825 Program ended with exit code: 0 |
void MSD::setSpin(unsigned int a, const Vector &spin)
WTF has any of that got to do with the original question? |
void MSD::setSpin(unsigned int a, const Vector &spin)
$ cd Molecular-Spintronics-Research-Project/MSD_Research_Project_01-25-2020/MSD Research Project (v2.2.0) $ g++ -ggdb src/metropolis.cpp -fpermissive -pthread -o metropolis.bin |
$ ./metropolist.bin parameters-metropolis.txt output CONTINUOUS_SPIN_MODEL 1 |
Parameter file is missing some data! map::at |
(gdb) backtrace #8 0x000055555555f183 in udc::MSD::setSpin (this=0x7ffffffebf80, a=116, spin=...) at src/MSD.h:844 #9 0x000055555556022e in udc::MSD::metropolis (this=0x7ffffffebf80, N=10000) at src/MSD.h:999 #10 0x0000555555560629 in udc::MSD::metropolis (this=0x7ffffffebf80, N=10000, freq=0) at src/MSD.h:1015 #11 0x0000555555563806 in algorithm (info=...) at src/metropolis.cpp:81 #12 0x00005555555692a1 in main (argc=5, argv=0x7fffffffdde8) at src/metropolis.cpp:485 |
|
|