@@ -54,13 +54,12 @@ bool do_verification(stopwatch& compilation_time, stopwatch& reduction_time, sto
5454 Query& q, Query::mode_t m, Network& network, bool no_ip_swap, std::pair<size_t ,size_t >& reduction, size_t tos,
5555 bool need_trace, size_t engine, Moped& moped, SolverAdapter& solver, utils::outcome_t & result,
5656 std::vector<pdaaal::TypedPDA<Query::label_t >::tracestate_t >& trace, std::stringstream& proof,
57- const W_FN& weight_fn) {
57+ std::vector< unsigned int >& trace_weight, const W_FN& weight_fn) {
5858 compilation_time.start ();
5959 q.set_approximation (m);
6060 NetworkPDAFactory factory (q, network, no_ip_swap, weight_fn);
6161 auto pda = factory.compile ();
6262 compilation_time.stop ();
63-
6463 reduction_time.start ();
6564 reduction = Reducer::reduce (pda, tos, pda.initial (), pda.terminal ());
6665 reduction_time.stop ();
@@ -88,7 +87,11 @@ bool do_verification(stopwatch& compilation_time, stopwatch& reduction_time, sto
8887 engine_outcome = solver_result.first ;
8988 verification_time.stop ();
9089 if (need_trace && engine_outcome) {
91- trace = solver.get_trace (pda, std::move (solver_result.second ));
90+ if constexpr (pdaaal::is_weighted<typename W_FN::result_type>) {
91+ std::tie (trace, trace_weight) = solver.get_trace <pdaaal::Trace_Type::Shortest>(pda, std::move (solver_result.second ));
92+ } else {
93+ trace = solver.get_trace <pdaaal::Trace_Type::Any>(pda, std::move (solver_result.second ));
94+ }
9295 if (factory.write_json_trace (proof, trace))
9396 result = utils::YES;
9497 }
@@ -374,18 +377,19 @@ int main(int argc, const char** argv)
374377 stopwatch reduction_time (false );
375378 stopwatch verification_time (false );
376379 std::vector<pdaaal::TypedPDA<Query::label_t >::tracestate_t > trace;
380+ std::vector<unsigned int > trace_weight;
377381 std::stringstream proof;
378382 bool need_trace = was_dual || get_trace;
379383 for (auto m : modes) {
380384 bool engine_outcome;
381385 if (weight_fn) {
382386 engine_outcome = do_verification (compilation_time, reduction_time,
383387 verification_time,q, m, network, no_ip_swap, reduction, tos, need_trace, engine,
384- moped, solver,result, trace, proof, weight_fn.value ());
388+ moped, solver,result, trace, proof, trace_weight, weight_fn.value ());
385389 } else {
386390 engine_outcome = do_verification<std::function<void (void )>>(compilation_time, reduction_time,
387391 verification_time,q, m,network, no_ip_swap, reduction, tos, need_trace, engine,
388- moped, solver,result, trace, proof, [](){});
392+ moped, solver,result, trace, proof, trace_weight, [](){});
389393 }
390394 if (q.number_of_failures () == 0 )
391395 result = engine_outcome ? utils::YES : utils::NO;
@@ -416,11 +420,19 @@ int main(int argc, const char** argv)
416420 break ;
417421 }
418422 std::cout << " ,\n " ;
419- std::cout << " \t\t\" engine\" :" << engineTypes[engine] << " , " << std::endl;
420- std::cout << " \t\t\" mode\" :" << modeTypes[mode] << " , " << std::endl;
423+ std::cout << " \t\t\" engine\" : \" " << engineTypes[engine] << " \ " , " << std::endl;
424+ std::cout << " \t\t\" mode\" : \" " << modeTypes[mode] << " \ " , " << std::endl;
421425 std::cout << " \t\t\" reduction\" :[" << reduction.first << " , " << reduction.second << " ]" ;
422426 if (get_trace && result == utils::YES)
423427 {
428+ if (weight_fn) {
429+ std::cout << " ,\n\t\t\" trace-weight\" : [" ;
430+ for (size_t i = 0 ; i < trace_weight.size (); i++){
431+ if (i != 0 ) std::cout << " , " ;
432+ std::cout << trace_weight[i];
433+ }
434+ std::cout << " ]" ;
435+ }
424436 std::cout << " ,\n\t\t\" trace\" :[\n " ;
425437 std::cout << proof.str ();
426438 std::cout << " \n\t\t ]" ;
0 commit comments