
On Mon, 1 Feb 2010, Geoff Hilton wrote:
Hi, I'm currently using MSVC9 and the code listed below doesn't compile, instead producing the following errors and warnings:
Warning 1 warning C4100: 'x' : unreferenced formal parameter c:\program files\boost\boost_1_41_0\boost\concept\detail\msvc.hpp 20 test Warning 2 warning C4100: 'id' : unreferenced formal parameter c:\program files\boost\boost_1_41_0\boost\graph\dag_shortest_paths.hpp 86 test Error 3 error C2440: '<function-style-cast>' : cannot convert from 'int' to 'D' c:\program files\microsoft visual studio 9.0\vc\include\limits 109 test
Do you have an instantiation stack for this? I can't see how it relates to BGL otherwise.
I know MSVC has issues with named parameters among other things, but I haven't been able to get it to compile with the non-named-parameters overload either, in this instance. What am I misusing and how am I misusing it? Also, I get the impression that the default combiner/comparer may be unsafe for floating-point comparisons and addition (with respect to over/underflow and comparing floating point values, I seem to recall it being a good idea never to compare with direct equalities, eg. x == infinity because of rounding issues).
I know there have been issues with things like load(store(a + b)) != a + b before (due to rounding issues). I believe comparison to infinity is safe, though, since that is a special value; checking online seems to suggest that there is only one bit pattern for each infinity. std::plus<double> should work since the CPU should handle infinity as a special case. Even if the comparisons in closed_plus always return false, the code should still work for float and double.
Might it be a good idea to further specialize appropriate areas of the algorithm code to account for this, or am I over-generalizing(specializing?)? How about a specialized closed_plus<> in relax.hpp which makes the comparisons more safely for floats and doubles (since both parameters "a" and "b" of closed_plus must be of type T anyway)?
What comparisons need to be safer? Just comparison to infinity?
#include <boost/graph/adjacency_list.hpp> #include <boost/graph/dag_shortest_paths.hpp> #include <boost/multi_array.hpp>
namespace geoff { typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS ,boost::no_property, float> Graph; typedef boost::multi_array<boost::graph_traits<Graph>::vertex_descriptor, 2U> PredecessorsMatrix;
typedef PredecessorsMatrix::array_view<1>::type PredecessorMap; } //namespace geoff
int main(int /*argc*/, char* /*argv*/[]) { const std::size_t num_agents = 3; geoff::Graph graph; geoff::PredecessorsMatrix per_agent_matrix(boost::extents[num_agents][boost::num_vertices(graph)]); geoff::PredecessorsMatrix::index_gen indices; std::size_t agent_index = 0U; geoff::PredecessorMap agent_x_predecessors = per_agent_matrix[indices[agent_index][boost::multi_array_types::index_range()]]; boost::dag_shortest_paths(graph, 0, boost::predecessor_map(agent_x_predecessors)); }
Is this the erroring code? What errors do you get from it? -- Jeremiah Willcock