|
|
| import sys
|
| import os
|
| from pathlib import Path
|
|
|
|
|
| sys.path.insert(0, str(Path(__file__).parent))
|
|
|
| from material_field_engine import MaterialFieldEngine, VerifiedSubstrate, Vector2D, fp_to_float, fp_from_float
|
| from llm_adapter import DeterministicHashEmbedderND
|
|
|
| def test_16d_stability():
|
| print("Testing 16D Stability and Stress Reporting...")
|
|
|
|
|
| embedder = DeterministicHashEmbedderND(dims=16)
|
|
|
|
|
| substrate_text = "The sky is blue"
|
| sub_vec_coords = embedder.embed(substrate_text)
|
| substrate_vector = Vector2D(
|
| x=sub_vec_coords[0],
|
| y=sub_vec_coords[1],
|
| properties=None,
|
| coords=sub_vec_coords
|
| )
|
|
|
| substrate = VerifiedSubstrate(
|
| verified_states=[substrate_vector],
|
| elastic_modulus_mode='multiplicative',
|
| elastic_modulus_sigma=0.5
|
| )
|
|
|
|
|
| engine = MaterialFieldEngine(substrate, lambda_min=0.3, lambda_max=0.9, inference_steps=8)
|
|
|
|
|
|
|
| near_coords = [c + 0.01 for c in sub_vec_coords]
|
|
|
| engine.initialize_candidates([near_coords])
|
|
|
|
|
| print("\nInitial Candidate Properties:")
|
| for v in engine.candidate_vectors:
|
| print(f"E: {v.properties.elastic_modulus:.4f}, Strain: {v.properties.strain:.4f}")
|
|
|
| start_stress = engine.candidate_vectors[0].properties.stress
|
| print(f"Initial Stress: {start_stress}")
|
|
|
|
|
| results = engine.run_inference()
|
|
|
| final_output = results.get('final_output')
|
| print(f"\nFinal Output: {'Survived' if final_output else 'Excluded'}")
|
|
|
|
|
| max_stress = results.get('max_stress')
|
| final_stress = results.get('final_stress')
|
|
|
| print(f"Max Stress: {max_stress}")
|
| print(f"Final Reported Stress: {final_stress}")
|
|
|
| if final_output is None:
|
|
|
| if final_stress != max_stress:
|
| print("FAILURE: final_stress does not match max_stress for excluded candidate.")
|
| else:
|
| print("SUCCESS: Stress reporting logic works for exclusions.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| print("\nTest passed if no crashes and stress is reported.")
|
|
|
| if __name__ == "__main__":
|
| test_16d_stability()
|
|
|