mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 03:32:28 +00:00 
			
		
		
		
	fix some bugs, it seems to run now
This commit is contained in:
		
							parent
							
								
									2480b5a359
								
							
						
					
					
						commit
						da85ed8cdd
					
				
					 1 changed files with 15 additions and 17 deletions
				
			
		|  | @ -4,7 +4,7 @@ from z3 import * | ||||||
| from multiprocessing import Process | from multiprocessing import Process | ||||||
| import math, random | import math, random | ||||||
| 
 | 
 | ||||||
| MAX_CONFLICTS = 1000 | MAX_CONFLICTS = 100 | ||||||
| MAX_EXAMPLES = 5 | MAX_EXAMPLES = 5 | ||||||
| bench_dir = "../z3-poly-testing/inputs/QF_NIA_small" | bench_dir = "../z3-poly-testing/inputs/QF_NIA_small" | ||||||
| 
 | 
 | ||||||
|  | @ -50,15 +50,16 @@ def solver_from_file(filepath): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def apply_param_state(s, param_state): | def apply_param_state(s, param_state): | ||||||
|  |     print(f"Applying param state: {param_state}") | ||||||
|     for name, value in param_state: |     for name, value in param_state: | ||||||
|         s.set(name, value) |         s.set(name, value) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def stats_tuple(st): | def stats_tuple(st): | ||||||
|     return ( |     return ( | ||||||
|         int(st["conflicts"]), |         int(st.get_key_value("conflicts")), | ||||||
|         int(st["decisions"]), |         int(st.get_key_value("decisions")), | ||||||
|         int(st["rlimit count"]), |         int(st.get_key_value("rlimit count")), | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -78,6 +79,7 @@ def collect_conflict_clauses_placeholder(S, limit=4): | ||||||
| # Replay proof prefix on an existing PPS_solver (no solver recreation) | # Replay proof prefix on an existing PPS_solver (no solver recreation) | ||||||
| # Solver continues from its current state. | # Solver continues from its current state. | ||||||
| def replay_prefix_on_pps(PPS_solver, clauses, param_state, budget): | def replay_prefix_on_pps(PPS_solver, clauses, param_state, budget): | ||||||
|  |     print(f"[Replaying] on PPS with params={param_state} and budget={budget}") | ||||||
|     apply_param_state(PPS_solver, param_state) |     apply_param_state(PPS_solver, param_state) | ||||||
|     PPS_solver.set("max_conflicts", budget) |     PPS_solver.set("max_conflicts", budget) | ||||||
| 
 | 
 | ||||||
|  | @ -152,12 +154,10 @@ def protocol_iteration(filepath, manager, S, PPS_solvers, PPS_states, K, eps=200 | ||||||
|     # Collect subset of conflict clauses from the bounded run of S. Call these clauses C1...Cl |     # Collect subset of conflict clauses from the bounded run of S. Call these clauses C1...Cl | ||||||
|     print(f"[S] collecting conflict clauses for replay") |     print(f"[S] collecting conflict clauses for replay") | ||||||
|     C_list = collect_conflict_clauses_placeholder(S) |     C_list = collect_conflict_clauses_placeholder(S) | ||||||
|     print(f"[S] collected {len(C_list)} conflict clauses for replay") |  | ||||||
| 
 | 
 | ||||||
|     # For each PPS_i, replay the proof prefix of S |     # For each PPS_i, replay the proof prefix of S | ||||||
|     print(f"[Replaying] Replaying proof prefix on PPS solvers with budget={K + eps}") |     print(f"[Replaying] Replaying proof prefix on PPS solvers with budget={K + eps}") | ||||||
|     best_state, best_score = replay_proof_prefixes(C_list, PPS_states, PPS_solvers, K, eps) |     best_state, best_score = replay_proof_prefixes(C_list, PPS_states, PPS_solvers, K, eps) | ||||||
|     print(f"[Done replaying] best={best_state} score(conf, dec, rlim)={best_score}") |  | ||||||
| 
 | 
 | ||||||
|     if best_state != P: |     if best_state != P: | ||||||
|         print(f"[Dispatch] updating best param state") |         print(f"[Dispatch] updating best param state") | ||||||
|  | @ -166,10 +166,10 @@ def protocol_iteration(filepath, manager, S, PPS_solvers, PPS_states, K, eps=200 | ||||||
| 
 | 
 | ||||||
|     # Update PPS_0 to use P (if it changed), and update all PPS_i > 0 with new perturbations of P |     # Update PPS_0 to use P (if it changed), and update all PPS_i > 0 with new perturbations of P | ||||||
|     PPS_states[0] = P  |     PPS_states[0] = P  | ||||||
|     new_perturbations = perturbate(P) |  | ||||||
|     for i in range(1, len(PPS_states)): |     for i in range(1, len(PPS_states)): | ||||||
|         PPS_states[i] = new_perturbations[i - 1] |         PPS_states[i] = perturbate(P) | ||||||
|     print(f"[Dispatch] PPS_0 := {PPS_states[0]}, new perturbations: {new_perturbations}") |          | ||||||
|  |     return PPS_states | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # -------------------------- | # -------------------------- | ||||||
|  | @ -183,12 +183,10 @@ def prefix_probe_thread(filepath, manager): | ||||||
| 
 | 
 | ||||||
|     PPS_solvers = [] |     PPS_solvers = [] | ||||||
|     PPS_states = [] |     PPS_states = [] | ||||||
|     PPS_states.append(list(BASE_PARAM_CANDIDATES)) |  | ||||||
|     perturbations = perturbate(BASE_PARAM_CANDIDATES) |  | ||||||
| 
 | 
 | ||||||
|     # set up 5 parameter probe solvers PPS_0 ... PPS_4 as new contexts on the proof prefix solver S |     # set up the 4 variant parameter probe solvers PPS_1 ... PPS_4 as new contexts on the proof prefix solver S | ||||||
|     for i in range(5): |     for i in range(4): | ||||||
|         st = perturbations if i < len(perturbations) else BASE_PARAM_CANDIDATES |         st = BASE_PARAM_CANDIDATES if i == 0 else perturbate(BASE_PARAM_CANDIDATES) # PPS_0 uses base params | ||||||
|         ctx = Context() |         ctx = Context() | ||||||
|         PPS_solver = S.translate(ctx)  # clone S (proof prefix) into new context |         PPS_solver = S.translate(ctx)  # clone S (proof prefix) into new context | ||||||
|         apply_param_state(PPS_solver, st) |         apply_param_state(PPS_solver, st) | ||||||
|  | @ -200,7 +198,7 @@ def prefix_probe_thread(filepath, manager): | ||||||
|     iteration = 0 |     iteration = 0 | ||||||
|     while not manager.search_complete: |     while not manager.search_complete: | ||||||
|         print(f"\n[PrefixThread] Iteration {iteration}") |         print(f"\n[PrefixThread] Iteration {iteration}") | ||||||
|         protocol_iteration(filepath, manager, S, PPS_solvers, PPS_states, K=MAX_CONFLICTS, eps=200) |         PPS_states = protocol_iteration(filepath, manager, S, PPS_solvers, PPS_states, K=MAX_CONFLICTS, eps=200) | ||||||
|         iteration += 1 |         iteration += 1 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue