我如何仅列出来自我的不满核心的特定约束结果?我有很多条件和打印整个核心不打印所有。我读到可以使用assert_and_track和unsat_core命令完成它。我找到了一些例子,但它们不起作用。有这方面的经验吗?
#include <sstream>
#include <iostream>
#include <fstream>
#include "Date.h"
#include "Address.h"
#include "student.h"
using namespace std;
int main(){
string line;
ifstream inputFile("studentdata.txt");
bool keepGoing = true;
Student *student = new Student[50];
int i = 0;
while(!inputFile.eof()){
getline(inputFile, line);
student[i].setInfo(line);
i++;
}
int choice;
cout << "A Heap of Students";
while(keepGoing){ //This while loop creates the menu and asks for user input
cout << "What would you like to do?" << endl;
cout << "1. Print full report." << endl;
cout << "2. Print simple report." << endl;
cout << "3. Sort records." << endl;
cout << "4. Quit" << endl;
cin >> choice;
//prints full student report
if(choice == 1){
for(int i = 0; i < 50; i++){ //Full print loop
cout << student[i] << endl;
}
cout << endl;
keepGoing = true;
}
//Just first and last name
else if(choice == 2){
cout << "First Last" << endl;
for(int i = 0; i < 50; i++){ //Simple print loop
cout << student[i].getFirstName() << " " << student[i].getLastName() << endl;
}
cout << endl; //formatting
keepGoing = true;
}
//sort function
else if(choice == 3){
for(int j = 1; j < 50; j++){
stringstream key = student[j].getLastName;
int i = j - 1;
while(i > 0 && student[i].getLastName > key){
student[i+1] = student[i];
i = i - 1;
}
Student[i + 1] = key;
}
for j = 1 to A.length
key = A[j]
i = j - 1
while i > 0 and A[i] > key
A[i + 1] = A[i]
i = i - 1
A[i + 1] = key
keepGoing = true;
}
//quit
else if(choice == 4){
cout << "Goodbye!" << endl;
keepGoing = false;
}
}
return 0;
}
那么如何只打印p1或p2(只是真/假结果)?例如p2 = false,或者它可以按照打印(c)模式显示的方式显示 - 但仅适用于p1。
答案 0 :(得分:0)
实现这一目标的最简单方法是简单地将标签贴图保存到约束中,我们可以做这个例子
M = {}
M['p1'] = (A > B)
M['p2'] = (B > C)
M['p3'] = (C > A)
以便稍后我们可以根据这些约束打印核心,例如如下
core = s.unsat_core()
for e in core:
print(M[str(e)])
当然,如果您只想打印一些条目而不是全部条目,这也会有效。