@@ -401,9 +401,24 @@ namespace opt {
401401 void context::set_model (model_ref& m) {
402402 m_model = m;
403403 opt_params optp (m_params);
404- if (optp.dump_models () && m) {
404+ symbol prefix = optp.solution_prefix ();
405+ bool model2console = optp.dump_models ();
406+ bool model2file = prefix != symbol::null && prefix != symbol (" " );
407+
408+ if ((model2console || model2file) && m) {
405409 model_ref md = m->copy ();
406410 fix_model (md);
411+ if (model2file) {
412+ std::ostringstream buffer;
413+ buffer << prefix << (m_model_counter++) << " .smt2" ;
414+ std::ofstream out (buffer.str ());
415+ if (out) {
416+ out << *md;
417+ out.close ();
418+ }
419+ }
420+ if (model2console)
421+ std::cout << *md;
407422 }
408423 if (m_on_model_eh && m) {
409424 model_ref md = m->copy ();
@@ -1168,20 +1183,6 @@ namespace opt {
11681183 void context::model_updated (model* md) {
11691184 model_ref mdl = md;
11701185 set_model (mdl);
1171- #if 0
1172- opt_params optp(m_params);
1173- symbol prefix = optp.solution_prefix();
1174- if (prefix == symbol::null || prefix == symbol("")) return;
1175- model_ref mdl = md->copy();
1176- fix_model(mdl);
1177- std::ostringstream buffer;
1178- buffer << prefix << (m_model_counter++) << ".smt2";
1179- std::ofstream out(buffer.str());
1180- if (out) {
1181- out << *mdl;
1182- out.close();
1183- }
1184- #endif
11851186 }
11861187
11871188 rational context::adjust (unsigned id, rational const & v) {
0 commit comments