#include #include #include /* This is a simple program for setting up an input file for c2002a.c */ #define DEFAVENUM 300 #define MAXIND 101 /* * MAXIND is the maximum # of individuals */ #define MAXFACTS 301 /* * MAXFACTS is the maximum # of facts */ #define MAXPROBLEM 25 /* MAXPROBLEMS is the number of tasks the organization or society faces */ #define MAXGROUPS 3 #define MAXGR2 10 /* * MAXGROUPS is the maximum # of groups */ #define MEANDIF 0.0000 /* * stop when x[0][0]-x[0][1] decreases to MEANDIF * its initial value */ #define MAXTIMES 1000 /* maximum value allowed for maxtime */ #define MAXSKBGEN 1000000 /* maximum attempts to make an skb for doarun */ #define LSIZE 1000 int maxtime ; int intstyle ; int numinds, numfacts, numunused, numgroups, flag, time ; int fromind, toind, totffrom, totfto, fromfact, tofact, fromreferred, toreferred ; int avenum, itnum, sumt, sumtt, numwarn, numt, maxt ; int totnum[MAXGROUPS][MAXGROUPS] ; int terminate ; int forget ; int killstyle ; int killperiod ; int killdelay ; int database ; int avatars ; int books ; double forgetrate ; double condint ; double proxvar[MAXGROUPS][MAXGROUPS], proxmean[MAXGROUPS][MAXGROUPS], kbmean[MAXGROUPS][MAXGROUPS] ; double y ; double proxkbis[MAXGROUPS][MAXGROUPS] ; double intfrac ; double kbtmmean ; short skb[MAXIND][MAXFACTS] ; /* now add trandactive memory */ short skb_tm[MAXIND][MAXIND][MAXFACTS] ; int grp[MAXGROUPS][MAXIND] ; int grpk[MAXGROUPS][MAXFACTS] ; int grpk_tm[MAXGROUPS][MAXIND][MAXFACTS] ; int numindg[MAXGROUPS], numfactg[MAXGROUPS] ; int thisgrp[MAXIND] ; double prox[MAXIND][MAXIND], colint[MAXIND], interact[MAXIND][MAXIND] ; /* files */ FILE *INF ; FILE *OUT1, *OUT2, *OUT3 ; /* random stuff from input file */ int savenets ; /* = 1 if save friendship networks, 2 if save advice, 3 if save both on 10 point scale else 0 */ /* stop condition */ int one_to_n ; /* block people when setting proximity */ int pblock ; /* block facts when setting knowledge base */ int fblock ; main(){ int i,j ; char *l, line[LSIZE] ; int df,vf,klf,ktf, af ; int maxg, maxf ; l = line ; OUT3 = fopen("input.txt", "w") ; printf(" Welcome to the Construct Startup Program.\n") ; printf("This program is designed to be used with CONSTRUCT-TM 2002.\n") ; printf("\n\n By answering a series of questions you will be directed in the creation\n") ; printf("of a file, input.txt, that you can use in running construct.\n\n") ; printf("\nWhat is the number of agents (e.g., people + databases), max is %d? ", MAXIND) ; fgets(line, LSIZE, stdin) ; numinds = atoi(line) ; printf("\nWhat is the number of pieces of knowledge (a.k.a. skills or facts), max is %d? ", MAXFACTS) ; fgets(line, LSIZE, stdin) ; numfacts = atoi(line) ; printf("\n\nConstruct enables multiple kinds of agents.\n") ; printf("The basic agent is the 'person' or 'corportion'.\n") ; printf("Such agents can interact 1:1 or 1:many.\n") ; printf("Books are agents that cannot initiate or learn but can communicate to many at once.\n") ; printf("Avatars are agents that have a sample of the person or corporations knowledge at time 0\n") ; printf("can communicate 1:N, but cannot learn\n") ; printf("Database can communicate 1:N, can be updated by one person/corporation at a time\n") ; printf("cannot initiate communication, but can communicate with many at a time.\n") ; printf("There are three types of databases - task bases, referential, combined task and referential.\n") ; printf("At this point you can only have one of books, databases and avatars.\n") ; printf("Do you have one or more books (1 yes 0 no)? ") ; fgets(line, LSIZE,stdin) ; books = atoi(line) ; if (books == 0) { printf("Do you have a database (1 yes 0 no)? ") ; fgets(line, LSIZE,stdin) ; database = atoi(line) ; if (database == 1) { printf("Is the database: 1) task based, 2) referential, 3) combined? ") ; fgets(line, LSIZE,stdin) ; database = atoi(line) ; } if (database == 0) { printf("Do you have avatars (1 yes 0 no)? ") ; fgets(line, LSIZE,stdin) ; avatars = atoi(line) ; } } if ((database > 0)||(avatars == 1)||(books == 1)) numgroups = 2 ; printf("You can have up to 3 groups that statistics are calculated on.\n") ; printf("If you have databses,avatars, or books they are put in group 1.\n") ; printf("If you have databses,avatars, or books you must have at least two groups.\n") ; printf("At this point you must have at least %d groups.\n", numgroups) ; printf("What is the number of groups, max is %d? ",MAXGROUPS) ; fgets(line, LSIZE,stdin) ; numgroups = atoi(line) ; fprintf(OUT3, "%d Number of Groups\n",numgroups) ; printf("Construct allows you to enter data directly from pre-defined files.") ; printf("These are flat unformatted files, such as *.txt files\n") ; printf("This allows the user fine control over knowledge and decisions\n") ; printf("and makes it possible to input detailed real data.\n") ; printf("You will know be asked if any of these files are available.\n") ; printf("Note, if no such files exist, you will then be asked for other information\n") ; printf("that can be used in creating an abstracted version of these files.\n") ; printf("\n\nThe requirements network file is tasks by knowledge in size.\n") ; printf("This is a binary file such that: \n") ; printf("Rik = 1 means for task i knowlsge k bears positively on the decision\n") ; printf("Rik = 0 means for task i knowledge k has no bearing on the decision.\n") ; printf("This has also been referred to as the decision file.\n") ; printf("Presently the number of tasks has to be 25\n") ; printf("There are task (25) rows and knowledge columns.\n") ; printf("Numbers are separate by a single space.\n") ; printf("Each row is ended by a carriage return.\n") ; printf("Is there a network denoting what tasks need what knowledge (1 yes 0 no)? ") ; fgets(line, LSIZE,stdin) ; df = atoi(line) ; printf("\n\nThe votes network file is agents by knowledge in size.\n") ; printf("This is a number files filled with Vik.\n") ; printf("Vik = 1 means agent i feels that k bears positively on the decision.\n") ; printf("Vik = 0 means agent i feels that k has no bearing on the decision.\n") ; printf("Vik = -1 means agent i feels that k bears negatively on the decision.\n") ; printf("There are agent rows and knowledge columns.\n") ; printf("Numbers are separate by a single space.\n") ; printf("Each row is ended by a carriage return.\n") ; printf("Is there a vote file (1 yes 0 no)? ") ; fgets(line, LSIZE,stdin) ; vf = atoi(line) ; printf("\n\nThe knowledge network file is agents by knowledge in size.\n") ; printf("They are binary files such that Kik = 1 means agent i knows k.\n") ; printf("There are agent rows and knowledge columns.\n") ; printf("Numbers are separate by a single space.\n") ; printf("Each row is ended by a carriage return.\n") ; printf("Is there a knowledge network file (1 yes 0 no) ? ") ; fgets(line, LSIZE,stdin) ; klf = atoi(line) ; printf("\n\nTransactive knowledge network files are agents by agents by knowledge in size\n") ; printf("They are binary files such that Kijk = 1 means agent i thinks agent j knows k.\n") ; printf("There are agent matrices such that in each there are agent rows and knowledge columns.\n") ; printf("Each matrix is separated by a blank line.\n") ; printf("Numbers are separate by a single space.\n") ; printf("Each row is ended by a carriage return.\n") ; printf("Is there a transactive memory knowledge network file (1 yes 0 no)? ") ; fgets(line, LSIZE,stdin) ; ktf = atoi(line) ; printf("\n\nAccess files are agents by agents in size\n") ; printf("They are numeric files such that Rik = A means \n") ; printf("agent i has access to agent j A percent of the time.\n") ; printf("0 <= A <= 1\n") ; printf("A=1 means interaction is only controled by knowledge\n") ; printf("A=0 means the two agents cannot interact directly in this simulation.\n") ; printf("There are agent rows and agent columns.\n") ; printf("Numbers are separate by a single space.\n") ; printf("Each row is ended by a carriage return.\n") ; printf("Is there an access file (1 yes 0 no)? ") ; fgets(line, LSIZE,stdin) ; af = atoi(line) ; printf("\nDo you want to save friendship nets (1), advice (2), both (3), neither (0)? ") ; fgets(line, LSIZE, stdin) ; savenets = atoi(line) ; fprintf(OUT3, "%d %d Number of People, Save Nets\n",numinds,savenets) ; if (ktf == 0) { printf("\nWhat percent of transactive memory do people have initially (between 0 and 1)? ") ; fgets(line, LSIZE, stdin) ; kbtmmean = atof(l) ; } else kbtmmean = 0.0 ; fprintf(OUT3, "%d %6.4f Number of Facts and Percent of TM\n",numfacts,kbtmmean) ; printf("\nWhat is the number of runs to average? ") ; fgets(line, LSIZE, stdin) ; avenum = atoi(line) ; fprintf(OUT3, "%d Number of Runs\n",avenum) ; printf("\nWhat is the number of time steps per run, max is %d? ",MAXTIMES) ; fgets(line, LSIZE, stdin) ; maxtime = atoi(line) ; fprintf(OUT3, "%d Number of Time Steps\n",maxtime) ; /*printf("What is the one_to_n mode and technology: \n") ; printf(" 0 means all individuals only communicate to 1 other individual.\n") ; printf(" 1 means individuals in group 1 can communicate to any\n") ; printf(" number of people, and they themselves don't receive or change.\n") ; printf(" 2 means individuals in group 1 cannot communicate or change\n") ; printf(" People in the other groups can only communicate with group 1 or themselves\n") ; printf(" 3 number of people, and they themselves do communicate or change.\n") ; printf(" 4 means individuals in group 1 cannot communicate or change\n") ; printf(" People in the other groups communicate as usual.\n") ; printf(" This mode is useful for comparison with one_to_n = 1.\n") ; printf(" 5 means that all individuals can communicate to any\n") ; printf(" number of people, and they themselves do communicate or change\n") ; printf(" except for individuals in group 1 who cannot communicate or change.\n") ; printf(" 6 means that all individuals in group 1 can receive, learn, send,\n") ; printf(" but not initiate, and can receive from only 1 at a time.\n") ; printf(" a data base for only task info\n") ; printf(" 7 means that all individuals in group 1 can send, not learn, and can initiate\n") ; printf(" an avatar - set initially to match one individual\n") ; printf(" 8 means that all individuals in group 1 can receive, learn, send,\n") ; printf(" but not initiate, and can receive from only 1 at a time.\n") ; printf(" a data base for only referential info\n") ; printf(" 9 means that all individuals in group 1 can receive, learn, send,\n") ; printf(" but not initiate, and can receive from only 1 at a time.\n") ; printf(" a data base for task and referential info\n") ; printf("??? ") ; */ one_to_n = -1 ; if (books == 1) one_to_n = 5 ; if (database == 1) one_to_n = 6 ; if (database == 2) one_to_n = 8 ; if (database == 3) one_to_n = 9 ; if (avatars == 1) one_to_n = 7 ; if (one_to_n == -1) { printf("You have elected to have all agents of the same type.\n") ; printf("Do these agents communicate 0) one_to_one or 1) one_to_many? ") ; fgets(line, LSIZE, stdin) ; one_to_n = atoi(line) ; } /* note this eliminates options 2,3,4 */ /* get the info on the groups */ maxg = maxf = 0 ; for(i = 0; i < numgroups; i++) { if (i != numgroups - 1) { printf("How many individuals are in group %d? ",i) ; fgets(line, LSIZE, stdin) ; numindg[i] = atoi(line) ; printf("How many facts are special to group %d? ",i) ; fgets(line, LSIZE, stdin) ; numfactg[i] = atoi(line) ; maxg += numindg[i] ; maxf += numfactg[i] ; } else { numindg[i] = numinds - maxg ; numfactg[i] = numfacts - maxf ; } if (pblock == 1) { printf("What is the mean for proximity for group %d (0 to 1)? ",i) ; fgets(line, LSIZE, stdin) ; proxmean[i][i] = atof(l) ; printf("What is the variance for proximity for group %d (0 to 1)? ",i) ; fgets(line, LSIZE, stdin) ; proxvar[i][i] = atof(l) ; } else { proxmean[i][i] = 0.0 ; proxvar[i][i] = 0.0 ; } if (klf == 0) { printf("What is the mean for the KB (0 to 1) of group %d? ",i) ; fgets(line, LSIZE, stdin) ; kbmean[i][i] = atof(l) ; printf("What is the proxkbis(0 to 1) of group %d? ",i) ; fgets(line, LSIZE, stdin) ; proxkbis[i][i] = atof(l) ; } else { kbmean[i][i] = 0.0 ; proxkbis[i][i] = 0.0 ; } fprintf(OUT3,"%d %d %6.4f %6.4f %6.4f %6.4f\n",numindg[i],numfactg[i],proxmean[i][i],proxvar[i][i],kbmean[i][i],proxkbis[i][i]); } if (numgroups != 1){ for(i = 0; i < numgroups; i++){ for(j = 0; j < numgroups; j++) { if (i != j) { if (pblock == 1) { printf("What is the mean for proximity from group %d to %d(0 to 1)? ",i,j) ; fgets(line, LSIZE, stdin) ; proxmean[i][j] = atof(l) ; printf("What is the variance for proximity from group %d to 1%d (0 to 1)? ",i,j) ; fgets(line, LSIZE, stdin) ; proxvar[i][j] = atof(l) ; } else { proxmean[i][j] = 0.0 ; proxvar[i][j] = 0.0 ; } if (klf == 0) { printf("What is the mean for the KB from group %d to %d (0 to 1)? ",i,j) ; fgets(line, LSIZE, stdin) ; kbmean[i][j] = atof(l) ; printf("What is the proxkbis from group %d to %d (0 to 1)? ",i,j) ; fgets(line, LSIZE, stdin) ; proxkbis[i][j] = atof(l) ; } else { kbmean[i][j] = 0.0 ; proxkbis[i][j] = 0.0 ; } } } } fprintf(OUT3,"%6.4f %6.4f %6.4f %6.4f ",proxmean[0][1],proxvar[0][1],kbmean[0][1],proxkbis[0][1]) ; fprintf(OUT3,"%6.4f %6.4f %6.4f %6.4f ",proxmean[1][0],proxvar[1][0],kbmean[1][0],proxkbis[1][0]) ; fprintf(OUT3, "\n") ; } if (numgroups == 3) { fprintf(OUT3,"%6.4f %6.4f %6.4f %6.4f ",proxmean[0][2],proxvar[0][2],kbmean[0][2],proxkbis[0][2]) ; fprintf(OUT3,"%6.4f %6.4f %6.4f %6.4f \n",proxmean[2][0],proxvar[2][0],kbmean[2][0],proxkbis[2][0]) ; fprintf(OUT3,"%6.4f %6.4f %6.4f %6.4f ",proxmean[1][2],proxvar[1][2],kbmean[1][2],proxkbis[1][2]) ; fprintf(OUT3,"%6.4f %6.4f %6.4f %6.4f \n",proxmean[2][1],proxvar[2][1],kbmean[2][1],proxkbis[2][1]) ; } /* now get all the random stuff */ /* now print the one_to_n mode */ fprintf(OUT3, "%d one_to_n\n",one_to_n) ; printf("\nProximity is used 0 no 1 yes? ") ; fgets(line, LSIZE,stdin) ; pblock = atoi(line) ; fprintf(OUT3, "%d Proximity\n",pblock) ; /* 0 then prox if > 0 and relative shared knowledge = int * or if prox = 0 int = relative shared knowledge (or style) * 1 then prox is converted to facts by mean + stddev * proxkbis */ printf("\nMake knowledge fully connected 0=no 1=yes 2=yes_all_have_last_fact? ") ; fgets(line, LSIZE,stdin) ; fblock = atoi(line) ; fprintf(OUT3, "%d Fully Connected\n",fblock) ; printf("\nTerminate the simulation when: \n") ; printf("0 - terminate when all individuals know all facts\n") ; printf("1 - terminate when all those in group 1 know all facts\n") ; printf("2 - terminate when all except those in group 1 know all facts\n") ; printf("3 - terminate when all but group 1 ind. 1 know all facts\n") ; printf("4 - terminate at user defined time period\n") ; printf("??? ") ; fgets(line, LSIZE, stdin) ; terminate = atoi(line) ; printf("\nPersonnel exit can occur because agents leave, die, are fired, are killed off, or temporarily isolated.\n") ; printf("Do you want agents to exit (1 yes 0 no)? ") ; fgets(line, LSIZE, stdin) ; killstyle = atoi(line) ; killperiod = 0 ; killdelay = 0 ; if (killstyle == 1) { printf("Exit strategy: Kill off or isolate individuals:\n") ; printf("1 - person with the highest cognitive load exits\n") ; printf("2 - person who has the highest centrality exits\n") ; printf("3 - random person exits\n") ; printf("??? ") ; fgets(line, LSIZE, stdin) ; killstyle = atoi(line) ; } if (killstyle != 0) { printf("What is the number of time periods between kills? ") ; fgets(line, LSIZE, stdin) ; killperiod = atoi(line) ; printf("What is the number of time periods to delay before starting to have agents exit? ") ; fgets(line, LSIZE, stdin) ; killdelay = atoi(line) ; } if (killstyle == 0) fprintf(OUT3, "%d terminate style\n", terminate) ; else { fprintf(OUT3,"%d kill %d %d %d terminate style, kill style, time period between kills, kill delay\n",terminate,killstyle,killperiod) ; } printf("\nWhat is the interaction style: \n") ; printf("0 interaction is homophilly based - relative similarity\n") ; printf("1 interaction is information seeking - relative expertise\n") ; printf(" (based on interact with most different\n") ; printf("2 interaction is both styles at some ratio\n") ; printf("??? ") ; fgets(line, LSIZE, stdin) ; intstyle = atoi(line) ; if (intstyle == 2) { printf("What percentage of the time is relative similarity used (0 to 1)? ") ; fgets(line, LSIZE, stdin) ; intfrac = atof(l) ; } else intfrac = 0 ; fprintf(OUT3, "%d %6.4f interaction style and percent\n",intstyle,intfrac) ; printf("\nDo people forget 0 no 1 yes? ") ; fgets(line, LSIZE,stdin) ; forget = atoi(line) ; if (forget == 1) { printf("What is the likelihood of fogetting something at time x (0 to 1)? ") ; fgets(line, LSIZE, stdin) ; forgetrate = atof(l) ; } else forgetrate = 0.0 ; fprintf(OUT3, "%d %6.4f Forget and percent\n",forget,forgetrate) ; if (df == 1) { printf("\nWhat is the name of the decision file? ?") ; fgets(line, LSIZE,stdin) ; if (line[0] != '\0') fprintf(OUT3, "DEC %s",line) ; } if (vf == 1) { printf("\nWhat is the name of the vote file? ") ; fgets(line, LSIZE,stdin) ; if (line[0] != '\0') fprintf(OUT3, "VOTE %s",line) ; } if (klf == 1) { printf("\nWhat is the name of the initial knowledge base? ? ") ; fgets(line, LSIZE,stdin) ; if (line[0] != '\0') fprintf(OUT3, "KB %s",line) ; } if (ktf == 1) { printf("\nWhat is the name of the initial transactive memory? ? ") ; fgets(line, LSIZE,stdin) ; if (line[0] != '\0') fprintf(OUT3, "KBTM %s",line) ; } if (af == 1) { printf("\nWhat is the name of the access file? ? ") ; fgets(line, LSIZE,stdin) ; if (line[0] != '\0') fprintf(OUT3, "ACCESS %s",line) ; } printf("\n\nTHANK YOU - this information is in input.txt\n") ; printf("Put input.txt in the same directory as you are running CONSTRUCT-TM\n") ; printf("After doing a run - put all inputs and outputs in a separate \n") ; printf(" for safe keeping\n") ; fclose(OUT3) ; exit(0) ; }