Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.text.DecimalFormat;
- import java.util.Random;
- import javax.sound.midi.SysexMessage;
- public class Main
- {
- static int growth;
- static double variables;
- static int j=0,k=0;
- static int i=0;
- static int bar;
- static String fname = "testbed";
- static FileWriter writer;
- static Random gen;
- static DecimalFormat df = new DecimalFormat("#");
- public static void main(String[] args) throws IOException
- {
- for(i = 1; i<26; i++)
- {
- gen = new Random();
- writer = new FileWriter(fname + i);
- /*open the file for writing, each time its open it should be overridden*/
- growth = (int)Math.pow(2, i);
- writer.write("p cnf 3 " + growth + "\n");
- /*looping to create the new clauses i.e. whitespace and a 0 keeping in mind that the growth is exponential*/
- for(j=0;j<growth;j++)
- {
- /* this loop is for the placement of the variables*/
- for(k=0; k<3;k++)
- {
- variables = gen.nextInt(growth);
- bar = gen.nextInt(2);
- if(k==0)
- {
- if(bar == 1)
- {
- writer.write("" + df.format(variables) + " ");
- }
- else
- {
- writer.write("-" +df.format(variables) + " ");
- }
- }
- else
- {
- if(bar==1)
- {
- writer.write(" " + df.format(variables)+ " ");
- }
- else
- writer.write(" -" + df.format(variables)+ " ");
- }
- }
- writer.write(" 0 c \n");
- }
- writer.close();
- }
- System.out.println(i + "testbeds created");
- }//main
- }//class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement