import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.awt.geom.*; import java.math.*; /**This routine prints out some of the calculations made by the program when it runs the proof. Nothing in this file is used in the proof, but it serves as a sanity check for the calculations.**/ public class BoxStatistics { BoxConfiguration X; double E; int[][] ON=new int[5][5]; int CONFINE; int DYADIC; ListenSquare[] INFO=new ListenSquare[10]; public BoxStatistics() {} public BoxStatistics(BoxConfiguration x,double e,int[][] on,int confine,int dyadic) { X=new BoxConfiguration(x); E=e; CONFINE=confine; for(int i=0;i<5;++i) { for(int j=0;j<5;++j) ON[i][j]=on[i][j]; } DYADIC=dyadic; } public void render(Graphics2D g) { g.translate(200,-160); drawElimStats(g); drawEnergy(g); g.translate(-200,160); } /**This routine computes the energy of our configuration and compares it with the energy of the triangular bi-pyramid.**/ public void drawEnergy(Graphics2D g) { g.translate(160,-50); g.setColor(Color.yellow); g.drawString("BASIC INFORMATION",5,380); Complex[] Z=BoxConfiguration.toComplex(X); g.setColor(Color.white); double t=Energy.minEnergy(E); Double T=new Double(t); g.setColor(Color.white); g.drawString(T.toString(),80,400); t=Energy.energy(E,Z); T=new Double(t); g.setColor(Color.white); g.drawString(T.toString(),80,420); t=XtraEnergy.energy(E,Z,ON); T=new Double(t); g.setColor(Color.white); g.drawString(T.toString(),80,440); g.drawString( "bi-pyramid",5,400); g.drawString("current",5,420); g.drawString("current,bond",5,440); g.drawString("volume",5,460); g.drawString("confined",5,480); t=BoxConfiguration.volume(X); T=new Double(t); g.setColor(Color.white); g.drawString(T.toString(),80,460); Complex[] TBP=new Complex[4]; TBP[0]=new Complex(1,0); TBP[1]=new Complex(-.5,-Math.sqrt(3.0)/2.0); TBP[2]=new Complex(0,0); TBP[3]=new Complex(-.5,Math.sqrt(3.0)/2.0); double test=BoxConfiguration.near(CONFINE,TBP,X); if(test==1) g.drawString("yes",120,480); if(test==0) g.drawString("no",120,480); g.translate(-160,50); } /**This routine parallels our divide and conquer algorithm. Given a configuration of boxes, the routine calculates all the things calculated by our proof and prints the outcome.**/ public void drawElimStats(Graphics2D g) { g.setColor(Color.black); g.fillRect(155,285,220,510); g.setColor(Color.white); g.drawString("CONFIGURATION STATS",200,305); g.setColor(new Color(200,0,200)); g.drawRect(155,285,220,510); drawTetrahedral(g); drawRedundancy(g); drawEnergyEstimator(g); drawFinal(g); } /**Tetrahedral Eliminator**/ public void drawTetrahedral(Graphics2D g) { g.translate(160,80); g.setColor(Color.white); int test1=TetrahedralEliminator.eliminate(Energy.tetrahedralComplement(E),E,X); if(test1==0) g.drawString("no",120,400); if(test1==1) g.drawString("yes",120,400); g.drawString("eliminate:",5,400); g.setColor(Color.yellow); g.drawString("TETRAHEDRAL ELIMINATOR:",5,380); g.translate(-160,-80); } /**Redundancy Eliminator**/ public void drawRedundancy(Graphics2D g) { g.translate(160,130); g.setColor(Color.white); int test1=RedundancyEliminator.eliminate(E,X); if(test1==0) g.drawString("no",120,400); if(test1==1) g.drawString("yes",120,400); g.drawString("eliminate:",5,400); g.drawString("2nd bond too hi:",5,420); g.drawString("points permuted:",5,440); g.drawString("points inverted:",5,460); double test=RedundancyEliminator.bondTooHi(E,X); if(test==1) g.drawString("yes",120,420); if(test==0) g.drawString("no",120,420); test=RedundancyEliminator.isPermuted(X); if(test==1) g.drawString("yes",120,440); if(test==0) g.drawString("no",120,440); test=RedundancyEliminator.isInverted(X); if(test==1) g.drawString("yes",120,460); if(test==0) g.drawString("no",120,460); g.setColor(Color.yellow); g.drawString("REDUNDANCY ELIMINATOR:",5,380); g.translate(-160,-130); } /**Energy Estimator**/ public void drawEnergyEstimator(Graphics2D g) { g.translate(160,240); g.setColor(Color.yellow); g.drawString("ENERGY ESTIMATOR",5,380); g.setColor(Color.white); g.drawString( "eliminate:",5,400); g.drawString( "vertex energy:",5,420); g.drawString( "error estimate:",5,440); g.drawString( "lower bound:",5,460); g.drawString( "TBP energy:",5,480); double t=EnergyEstimator.vertexEnergy(E,X); Double T=new Double(t); g.drawString(T.toString(),80,420); double[] t1=EnergyEstimator.errorTerm(E,X); T=new Double(t1[0]); g.drawString(T.toString(),80,440); t1=EnergyEstimator.energyLowerBound(E,X); T=new Double(t1[0]); g.drawString(T.toString(),80,460); t=Energy.minEnergy(E); T=new Double(t); g.drawString(T.toString(),80,480); int[] t2=EnergyEstimator.eliminate(Energy.minEnergy(E),E,X); if(t2[0]==1) g.drawString("yes",120,400); Integer TT=new Integer(t2[1]); if(t2[0]==0) g.drawString("no "+TT.toString(),120,400); g.translate(-160,-240); } /**This displays the verdict of our main routine. If the routine in the proof decides to eliminate the box, "yes" is printed out. If the proof decides to subdivide, "no" is printed, and the recommended subdivision is listed in the form of a colored box.*/ public void drawFinal(Graphics2D g) { g.translate(160,370); Color[] C=Configuration.colors(); g.setColor(Color.white); int[] test1=mainTest(); Integer TT=new Integer(test1[1]); if(test1[0]==0) g.drawString("no "+TT.toString(),120,400); if(test1[0]==1) g.drawString("yes",120,400); g.drawString("eliminate:",5,400); if(test1[0]==0) { g.setColor(C[test1[1]]); g.fillRect(150,385,20,20); } g.setColor(Color.yellow); g.drawString("FINAL:",5,380); g.translate(-160,-370); } /**This mirrors the main routine in our proof**/ public int[] mainTest() { int k=CONFINE; Complex[] TBP=new Complex[4]; TBP[0]=new Complex(1,0); TBP[1]=new Complex(-.5,-Math.sqrt(3.0)/2.0); TBP[2]=new Complex(0,0); TBP[3]=new Complex(-.5,Math.sqrt(3.0)/2.0); int[] pass={1,0}; if(BoxConfiguration.near(k,TBP,X)==1) return(pass); if(RedundancyEliminator.eliminate(E,X)==1) return(pass); if(TetrahedralEliminator.eliminate(Energy.tetrahedralComplement(E),E,X)==1) return(pass); int[] t=EnergyEstimator.eliminate(Energy.minEnergy(E),E,X); if(t[0]==1) return(pass); return(t); } }