@@ -401,9 +401,24 @@ namespace opt {
401
401
void context::set_model (model_ref& m) {
402
402
m_model = m;
403
403
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) {
405
409
model_ref md = m->copy ();
406
410
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;
407
422
}
408
423
if (m_on_model_eh && m) {
409
424
model_ref md = m->copy ();
@@ -1168,20 +1183,6 @@ namespace opt {
1168
1183
void context::model_updated (model* md) {
1169
1184
model_ref mdl = md;
1170
1185
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
1185
1186
}
1186
1187
1187
1188
rational context::adjust (unsigned id, rational const & v) {
0 commit comments