Annotation of OpenXM_contrib/PHC/Ada/Root_Counts/Product/drivers_for_multi_homogenization.adb, Revision 1.1.1.1
1.1 maekawa 1: with integer_io; use integer_io;
2: with Timing_Package; use Timing_Package;
3: with Communications_with_User; use Communications_with_User;
4: with Numbers_io; use Numbers_io;
5: with Standard_Natural_Vectors;
6: with Standard_Complex_Poly_Systems_io; use Standard_Complex_Poly_Systems_io;
7: with Standard_Complex_Solutions_io; use Standard_Complex_Solutions_io;
8: with Sets_of_Unknowns; use Sets_of_Unknowns;
9: with Partitions_of_Sets_of_Unknowns; use Partitions_of_Sets_of_Unknowns;
10: with Partitions_of_Sets_of_Unknowns_io; use Partitions_of_Sets_of_Unknowns_io;
11: with Degree_Structure; use Degree_Structure;
12: with Multi_Homogeneous_Start_Systems; use Multi_Homogeneous_Start_Systems;
13:
14: package body Drivers_for_Multi_Homogenization is
15:
16: procedure Multi_Homogenization_Info is
17:
18: i : array(1..17) of string(1..65);
19:
20: begin
21: i( 1):=" A multi-homogeneous Bezout number is based on a tuple of";
22: i( 2):="partitions of the set of unknowns. For every polynomial in the";
23: i( 3):="system, a different partition can model its structure. ";
24: i( 4):=" The corresponding start system is a linear-product system: the";
25: i( 5):="i-th equation is the product of linear equations with random";
26: i( 6):="coefficients in the unknowns of the set of the partition. The";
27: i( 7):="number of factors in the product for the i-th equation of the";
28: i( 8):="start system equals the product of the degrees of the i-th";
29: i( 9):="polynomial in the original system w.r.t. every set in the";
30: i(10):="partition. ";
31: i(11):=" Given a tuple of partitions, the multi-homogeneous Bezout";
32: i(12):="number equals the number of solutions of the corresponding";
33: i(13):="linear-product start system. Before the construction of the";
34: i(14):="start system, a multi-homogeneous Bezout number is first computed";
35: i(15):="in a formal way as a generalized permanent of a degree matrix. A";
36: i(16):="heuristic procedure is available for generating a tuple of";
37: i(17):="partitions. ";
38: for k in i'range loop
39: put_line(i(k));
40: end loop;
41: end Multi_Homogenization_Info;
42:
43: procedure Driver_for_Multi_Homogenization
44: ( file : in file_type; p : in Poly_Sys; b : in out natural;
45: q : out Poly_Sys; qsols : out Solution_List ) is
46:
47: procedure Write_Results ( file : in file_type; gb : in natural ) is
48:
49: m : natural;
50:
51: begin
52: new_line(file);
53: put(file," multi-homogeneous Bezout number is ");
54: put(file,gb,1); new_line(file);
55: put_line(file," with partitions :");
56: for i in p'range loop
57: m := Degree_Structure.Get(i);
58: declare
59: z : partition(1..m);
60: dg : Standard_Natural_Vectors.Vector(1..m);
61: begin
62: Degree_Structure.Get(i,z,dg);
63: put(file," partition for equation "); put(file,i,2);
64: put(file," : "); put(file,z); new_line(file);
65: Clear(z);
66: end;
67: end loop;
68: end Write_Results;
69:
70: procedure Save_Results ( qq : in Poly_Sys; qqsols : in Solution_List ) is
71:
72: qqfile : file_type;
73:
74: begin
75: if not Is_Null(qqsols)
76: then new_line;
77: put_line("Reading file name to write start system.");
78: Read_Name_and_Create_File(qqfile);
79: put_line(qqfile,qq);
80: new_line(qqfile);
81: put_line(qqfile,"THE SOLUTIONS : ");
82: new_line(qqfile);
83: put(qqfile,Length_Of(qqsols),Head_Of(qqsols).n,qqsols);
84: Close(qqfile);
85: end if;
86: end Save_Results;
87:
88: procedure Display_Menu ( choice : out character; gb : in natural ) is
89:
90: ans : character;
91:
92: begin
93: new_line;
94: put_line("MENU for Multi-Homogeneous Bezout Numbers :");
95: put (" 0. exit - current Bezout number is "); put(gb,1); new_line;
96: put_line(" 1. Apply heuristic partitioner");
97: put_line(" 2. Evaluate your own tuple of partitions.");
98: put("Type 0, 1, or 2 to make your choice : ");
99: Ask_Alternative(ans,"012"); choice := ans;
100: end Display_Menu;
101:
102: procedure Dispatch_Menu ( choice : in character; gb : in out natural ) is
103:
104: m : natural;
105:
106: begin
107: case choice is
108: when '1' => gb := Degree_Structure.Generalized_Bezout_Number(p);
109: when '2' => for i in p'range loop
110: put("Give the number of sets in partition ");
111: put(i,1); put(" : "); Read_Natural(m);
112: put("Give "); put(m,1); put(" sets : ");
113: declare
114: zz : Partition(1..m);
115: begin
116: Create(zz,p'length); get(zz);
117: Degree_Structure.Put(p,i,m,zz);
118: Clear(zz);
119: end;
120: end loop;
121: gb := Degree_Structure.Generalized_Bezout_Number;
122: when others => null;
123: end case;
124: Write_Results(Standard_Output,gb); Write_Results(file,gb);
125: end Dispatch_Menu;
126:
127: procedure Driver_for_Partitions
128: ( file : in file_type; gb : in out natural ) is
129:
130: timer : timing_widget;
131: method : character;
132:
133: begin
134: new_line(file);
135: put_line(file,"MULTI-HOMOGENIZATION :");
136: tstart(timer);
137: loop
138: Display_Menu(method,gb);
139: exit when method = '0';
140: Dispatch_Menu(method,gb);
141: end loop;
142: tstop(timer);
143: b := gb;
144: new_line(file);
145: print_times(file,timer,"Computation of multi-homogeneous Bezout number");
146: end Driver_for_Partitions;
147:
148: procedure Driver_for_Start_System ( file : in file_type ) is
149:
150: ans : character;
151: timer : timing_widget;
152: qq : Poly_Sys(p'range);
153: qqsols : Solution_List;
154:
155: begin
156: new_line;
157: put("Do you want a multi-homogeneous start system ? (y/n) ");
158: Ask_Yes_or_No(ans);
159: if ans = 'y'
160: then
161: tstart(timer);
162: GBQ(p,qq,qqsols);
163: tstop(timer);
164: Save_Results(qq,qqsols);
165: new_line(file);
166: put_line(file,"MULTI-HOMOGENEOUS START SYSTEM :");
167: put_line(file,qq);
168: q := qq; qsols := qqsols;
169: new_line(file);
170: put_line(file,"THE SOLUTIONS :");
171: new_line(file);
172: put(file,Length_Of(qqsols),Head_Of(qqsols).n,qqsols);
173: new_line(file);
174: print_times(file,timer,
175: "Construction of multi-homogeneous start system");
176: end if;
177: end Driver_for_Start_System;
178:
179: procedure Main_Driver is
180:
181: gb : natural := b;
182:
183: begin
184: Driver_for_Partitions(file,gb);
185: if not Degree_Structure.Empty
186: then Driver_for_Start_System(file);
187: end if;
188: end Main_Driver;
189:
190: begin
191: Main_Driver;
192: end Driver_for_Multi_Homogenization;
193:
194: end Drivers_for_Multi_Homogenization;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>