/*************************************************************************** main.cpp - description ------------------- begin : Die Feb 19 12:20:21 CET 2002 copyright : (C) 2002 by Sven Klauke email : sklauke@wiwi.uni-bielefeld.de Institute of Mathematical Economics (IMW) University of Bielefeld, Germany http://www.wiwi.uni-bielefeld.de/~imw/ I ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include #include #include "rand.h" #include "nuk.h" #include #include int n; int main (int argc, char* argv[]) { double v_i,x_s,v_s; zufall_ini (); int i,j,maxe; double maxw,h; char game_file[80]; char result_file[80]; double precision=0.0; int digits=6; switch(argc) { case 1: cout << "No game specified!\n"; return 1; case 2: sprintf (game_file, "game.%s", argv[1]); precision=1.0/pow(10,6); break; case 3: sprintf (game_file, "game.%s", argv[1]); digits=atoi(argv[2]); if(digits>9) digits=9; precision=1.0/pow(10,digits) ; break; default: cout << "too many arguments!\n"; return 1; } cout << endl << endl << "Calculating the Prenucleolus of " << game_file << endl << endl; ifstream fin (game_file); fin >> n; int koalitionen = (int) pow (2, n); vector v(0); for (i = 0; i < koalitionen; i++) { fin >> v_i; v.push_back(v_i); } vector nucleolus; nucleolus=calc_nuc(n,v,precision); vector excess; for (i = 0; i < koalitionen; i++) { x_s = 0; for (j = 0; j < n; j++) x_s += j_in_i (j, i) * nucleolus[j]; v_s = v[i]; excess.push_back(v_s-x_s); } vector ko(0); for(i=0;i maxw) { maxw = excess[j]; maxe = j; } } h = excess[i]; excess[i] = excess[maxe]; excess[maxe] = h; h = ko[i]; ko[i] = ko[maxe]; ko[maxe] = (int) h; } sprintf(result_file,"result.%s",argv[1]); ofstream fout(result_file); cout.precision(digits-1); cout << endl << endl << "The Prenucleolus: \n\n"; fout << "The Prenucleolus: \n\n"; for (i = 0;i < n; i++) { cout << "x" << i+1 << " = " << nucleolus[i] << "\n"; fout << "x" << i+1 << " = " << nucleolus[i] << "\n"; } fout << "\nExcesses:" << endl << endl; for(i=0;i