/[ascend]/trunk/ascend4/TK/solver.tcl
ViewVC logotype

Contents of /trunk/ascend4/TK/solver.tcl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Fri Oct 29 20:54:12 2004 UTC (20 years, 4 months ago) by aw0a
File MIME type: text/x-tcl
File size: 17192 byte(s)
Setting up web subdirectory in repository
1 # solver.tcl
2 # by Benjamin A. Allan and Kirk A. Abbott
3 # Created: January 1994
4 # Part of ASCEND
5 # Revision: $Revision: 1.35 $
6 # Last modified on: $Date: 1998/06/18 15:55:40 $
7 # Last modified by: $Author: mthomas $
8 # Revision control file: $RCSfile: solver.tcl,v $
9 #
10 # This file is part of the ASCEND Tcl/Tk Interface.
11 #
12 # Copyright (C) 1994-1998 Carnegie Mellon University
13 #
14 # The ASCEND Tcl/Tk Interface is free software; you can redistribute
15 # it and/or modify it under the terms of the GNU General Public
16 # License as published by the Free Software Foundation; either
17 # version 2 of the License, or (at your option) any later version.
18 #
19 # The ASCEND Tcl/Tk Interface is distributed in hope that it will be
20 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with the program; if not, write to the Free Software
26 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the
27 # file named COPYING. COPYING is found in ../compiler.
28
29 # Module: solver.tcl
30 # Tcl version: 7.1 (Tcl/Tk/XF)
31 # Tk version: 3.4
32 # XF version: 2.2
33 #
34
35 # module contents
36 global moduleList
37 global autoLoadList
38 set moduleList(solver.tcl) { .solver}
39 set autoLoadList(solver.tcl) {0}
40
41 # procedures to show toplevel windows
42
43
44 # procedure to show window .solver
45 # proc ShowWindow.solver {args}
46 proc ShowWindow.solver {args} {# xf ignore me 7
47
48 global env ascGlobalVect ascSolvVect
49 StartupSrc.solver
50 set ascSolvVect(statreport) 1
51
52 # build widget .solver
53 if {"[info procs XFEdit]" != ""} {
54 catch "XFDestroy .solver"
55 } {
56 catch "destroy .solver"
57 }
58 toplevel .solver
59
60 # Window manager configurations
61 set ascSolvVect(geometry) [sanegeometry $ascSolvVect(geometry)]
62 set minw [lindex [split $ascSolvVect(minsize) x] 0]
63 set minh [lindex [split $ascSolvVect(minsize) x] 1]
64 set gw [lindex [split [lindex [split $ascSolvVect(geometry) +-] 0] x] 0]
65 set gh [lindex [split [lindex [split $ascSolvVect(geometry) +-] 0] x] 1]
66 set gp "+[lindex [split [split $ascSolvVect(geometry) x] +-] 1]+[lindex [split [split $ascSolvVect(geometry) x] +-] 2]"
67 if {[expr $gw < $minw]} {
68 set gw $minw
69 }
70 if {[expr $gh < $minh]} {
71 set gh $minh
72 }
73 set gwh "${gw}x${gh}"
74 wm positionfrom .solver user
75 wm sizefrom .solver user
76 wm minsize .solver $minw $minh
77 wm geometry .solver [osgpos $gwh$gp]
78 wm iconname .solver $ascSolvVect(iconname)
79 wm protocol .solver WM_DELETE_WINDOW {Toggle_Remote ascSolvVect}
80 wm title .solver "A4 Solver"
81
82 # build widget .solver.lbl_frm
83 frame .solver.lbl_frm \
84 -relief {raised}
85
86 # build widget .solver.lbl_frm.label
87 label .solver.lbl_frm.label \
88 -highlightthickness 0 \
89 -text {SOLVER: }
90
91 # build widget .solver.lbl_frm.entry5
92 menubutton .solver.lbl_frm.entry5 \
93 -menu .solver.lbl_frm.entry5.m \
94 -relief {raised} \
95 -highlightthickness 0 \
96 -textvariable {ascSolvStatVect(solver)}
97 menu .solver.lbl_frm.entry5.m \
98 -tearoff 0
99
100 menubutton .solver.lbl_frm.btn_opts \
101 -menu .solver.lbl_frm.btn_opts.m \
102 -relief {raised} \
103 -highlightthickness 0 \
104 -text {Options}
105 menu .solver.lbl_frm.btn_opts.m \
106 -tearoff 0
107
108 .solver.lbl_frm.btn_opts.m add checkbutton \
109 -offvalue 0 \
110 -onvalue 1 \
111 -variable ascSolvVect(statreport) \
112 -label {Pop-up status report} \
113 -accelerator Ctrl-p \
114 -underline -1
115
116 set ascSolvVect(saveparmenu) .solver.lbl_frm.btn_opts.m.savepar
117
118 .solver.lbl_frm.btn_opts.m add cascade \
119 -menu .solver.lbl_frm.btn_opts.m.savepar \
120 -label {Save solver's parameters} \
121 -underline -1
122 .solver.lbl_frm.btn_opts.m add command \
123 -command {Solve_do_Parms open General} \
124 -accelerator Ctrl-g \
125 -label {General ...}
126 .solver.lbl_frm.btn_opts.m add separator
127
128 # The savepar menu under the options menu
129 menu .solver.lbl_frm.btn_opts.m.savepar \
130 -tearoffcommand .SOLVER.LBL_FRM.BTN_OPTS.M.SAVEPAR \
131 -tearoff 0
132 .solver.lbl_frm.btn_opts.m.savepar add command \
133 -command {View_Save_Solvers_Params} \
134 -label {All Solvers}
135
136
137 label .solver.lbl_frm.lbl_run \
138 -bitmap {feet} \
139 -padx 15
140
141 # build widget .solver.lbl_frm.btn_int
142 button .solver.lbl_frm.btn_int \
143 -command Solve_do_Interrupt \
144 -bitmap {stop}
145
146 # build widget .solver.lbl_frm.lbl_int
147 button .solver.lbl_frm.lbl_int \
148 -command Solve_do_Interrupt \
149 -text {Halt}
150
151 # pack widget .solver.lbl_frm
152 pack append .solver.lbl_frm \
153 .solver.lbl_frm.label {left frame center filly} \
154 .solver.lbl_frm.entry5 {left frame center filly} \
155 .solver.lbl_frm.btn_opts {left frame center filly} \
156 .solver.lbl_frm.lbl_int {right frame center filly} \
157 .solver.lbl_frm.btn_int {right frame center filly} \
158 .solver.lbl_frm.lbl_run {right frame center filly padx 20}
159
160 # build widget .solver.main_frm
161 frame .solver.main_frm
162
163 # build widget .solver.main_frm.inst_entry
164 entry .solver.main_frm.inst_entry \
165 -exportselection 0 \
166 -font $ascSolvVect(font) \
167 -highlightthickness 0 \
168 -state {disabled} \
169 -exportselection 0 \
170 -textvariable {ascSolvVect(instname)}
171
172 # build widget .solver.main_frm.objvar_entry
173 entry .solver.main_frm.objvar_entry \
174 -exportselection 0 \
175 -font $ascSolvVect(font) \
176 -highlightthickness 0 \
177 -state {disabled} \
178 -exportselection 0 \
179 -textvariable {ascSolvVect(objvarname)}
180
181 if {$ascSolvVect(modelbar)} {
182 # build widget .solver.main_frm.instpath
183 frame .solver.main_frm.instpath
184
185 # build widget .solver.main_frm.btn_expo
186 menubutton .solver.main_frm.btn_expo \
187 -font $ascGlobalVect(font) \
188 -menu {.solver.main_frm.btn_expo.m} \
189 -text {Import} \
190 -underline {0}
191
192 # build widget .solver.main_frm.btn_expo.m
193 menu .solver.main_frm.btn_expo.m \
194 -tearoffcommand .SOLVER.MAIN_FRM.BTN_EXPO.M \
195 -font $ascGlobalVect(font) \
196 -tearoff 0
197
198 .solver.main_frm.btn_expo.m add command \
199 -command {Solve_do_Import} \
200 -label {This model}
201
202 # pack widget .solver.main_frm
203 pack append .solver.main_frm \
204 .solver.main_frm.inst_entry {bottom frame center fill} \
205 .solver.main_frm.objvar_entry {bottom frame center fill} \
206 .solver.main_frm.instpath {left frame center fill} \
207 .solver.main_frm.btn_expo {right frame center}
208 } else {
209 pack append .solver.main_frm \
210 .solver.main_frm.inst_entry {top frame center fill} \
211 .solver.main_frm.objvar_entry {top frame center fill}
212 }
213
214
215 #
216 # Build the menu bar and submenus
217 #
218 menu .solver.menubar \
219 -tearoffcommand .SOLVER.MENUBAR \
220 -tearoff 0
221
222 # The Ananlyze menu
223 menu .solver.menubar.analyze \
224 -tearoffcommand .SOLVER.MENUBAR.ANALYZE \
225 -tearoff 0
226 .solver.menubar.analyze add command \
227 -command {Solve_do_Reanalyze} \
228 -label {Reanalyze} \
229 -accelerator {Alt-a r} \
230 -underline 0 \
231 -state {disabled}
232 .solver.menubar.analyze add command \
233 -command {Solve_do_Debug} \
234 -label {Debugger} \
235 -accelerator {Alt-a g} \
236 -underline 4 \
237 -state {disabled}
238 .solver.menubar.analyze add command \
239 -command {Solve_do_Overspecified} \
240 -label {Overspecified} \
241 -accelerator {Alt-a o} \
242 -underline 0
243 .solver.menubar.analyze add cascade \
244 -menu {.solver.menubar.analyze.depend} \
245 -label {Find dependent eqns.} \
246 -accelerator {Alt-a d} \
247 -underline 5
248 .solver.menubar.analyze add command \
249 -command {Solve_do_FindUnAssEqns} \
250 -label {Find unassigned eqns.} \
251 -accelerator {Alt-a u} \
252 -underline 7
253 .solver.menubar.analyze add command \
254 -command {Solve_do_EvalUnincluded} \
255 -label {Evaluate unincluded eqns.} \
256 -accelerator {Alt-a e} \
257 -underline 0
258 .solver.menubar.analyze add command \
259 -command {Solve_Find_Near_Bounds} \
260 -label {Find vars near bounds} \
261 -accelerator {Alt-a b} \
262 -underline 15
263 .solver.menubar.analyze add command \
264 -command {Solve_Find_Far_From_Nominals} \
265 -label {Find vars far from nominal} \
266 -accelerator {Alt-a n} \
267 -underline 19
268
269 # The Dependency menu under the Analyze menu
270 menu .solver.menubar.analyze.depend \
271 -tearoffcommand .SOLVER.MENUBAR.ANALYZE.DEPEND \
272 -tearoff 0
273 .solver.menubar.analyze.depend add command \
274 -command {Solve_do_NumDepends} \
275 -label {Numeric Dependency} \
276 -underline 0
277 .solver.menubar.analyze.depend add command \
278 -command {Solve_do_StrucDepends} \
279 -label {Structural Dependency} \
280 -underline 0
281
282 # The Display menu
283 menu .solver.menubar.display \
284 -tearoffcommand .SOLVER.MENUBAR.DISPLAY \
285 -tearoff 0
286 .solver.menubar.display add command \
287 -command {Solve_do_Display_Status} \
288 -accelerator {Alt-d s}\
289 -label {Status} \
290 -underline 0
291 .solver.menubar.display add command \
292 -command {Solve_do_DispUnattached} \
293 -label {Unattached variables} \
294 -accelerator {Alt-d v} \
295 -underline 11
296 .solver.menubar.display add command \
297 -command {Solve_do_DispUnincluded} \
298 -label {Unincluded relations} \
299 -accelerator {Alt-d r} \
300 -underline 11
301 .solver.menubar.display add command \
302 -command {Solve_do_DispIncidence} \
303 -label {Incidence matrix} \
304 -accelerator {Alt-d i} \
305 -underline 0
306
307 # The Edit menu
308 menu .solver.menubar.edit \
309 -tearoffcommand .SOLVER.MENUBAR.EDIT \
310 -tearoff 0
311 .solver.menubar.edit add command \
312 -command {Solve_do_Flush} \
313 -label {Remove instance} \
314 -accelerator {Alt-e r} \
315 -underline 0
316 .solver.menubar.edit add command \
317 -command {Solve_do_Select_Objective} \
318 -state {disabled} \
319 -label {Select objective ...} \
320 -accelerator {Alt-e o} \
321 -underline 7
322
323 # The File menu
324 menu .solver.menubar.file \
325 -tearoffcommand .SOLVER.MENUBAR.FILE \
326 -tearoff 0
327 .solver.menubar.file add command \
328 -command {Solve_do_Close} \
329 -label {Close Window} \
330 -accelerator {Alt-f c} \
331 -underline 0
332 .solver.menubar.file add command \
333 -command {Solve_do_Exit} \
334 -label {Exit ASCEND} \
335 -accelerator {Alt-f e} \
336 -underline 0
337
338 # The Execute menu
339 menu .solver.menubar.execute \
340 -tearoffcommand .SOLVER.MENUBAR.EXECUTE \
341 -tearoff 0
342 .solver.menubar.execute add command \
343 -command {Solve_do_Solve} \
344 -label {Solve} \
345 -accelerator {F5} \
346 -underline -1
347 .solver.menubar.execute add command \
348 -command {Solve_do_Iterate} \
349 -label {Single step} \
350 -accelerator {F6} \
351 -underline 2
352 .solver.menubar.execute add command \
353 -command {Solve_do_Integrate} \
354 -label {Integrate} \
355 -accelerator {F7} \
356 -underline 0
357
358
359 # The Export menu
360 menu .solver.menubar.export \
361 -tearoffcommand .SOLVER.MENUBAR.EXPORT \
362 -tearoff 0
363 .solver.menubar.export add command \
364 -command {Solve_do_Export2Browser} \
365 -label {to Browser} \
366 -accelerator {Alt-x b} \
367 -underline 3
368 .solver.menubar.export add command \
369 -command {Solve_do_Export2Probe} \
370 -label {to Probe} \
371 -accelerator {Alt-x p} \
372 -underline 3
373
374
375 # The Help menu
376 menu .solver.menubar.help \
377 -tearoffcommand .SOLVER.MENUBAR.HELP \
378 -tearoff 0
379 .solver.menubar.help add command \
380 -command {Solve_do_Help} \
381 -label {On Solvers} \
382 -underline 3
383
384
385 # The View menu
386 menu .solver.menubar.view \
387 -tearoffcommand .SOLVER.MENUBAR.VIEW \
388 -tearoff 0
389 .solver.menubar.view add command \
390 -command {Solve_do_Font} \
391 -label {Font ...} \
392 -accelerator {Alt-v f} \
393 -underline 0
394 .solver.menubar.view add checkbutton \
395 -offvalue {0} \
396 -onvalue {1} \
397 -variable {ascSolvVect(visibility)} \
398 -label {Open automatically} \
399 -accelerator {Alt-v o} \
400 -underline 0
401 .solver.menubar.view add command \
402 -command {View_Set_Save_Options solver} \
403 -label {Save Solver appearance} \
404 -accelerator {Alt-v s} \
405 -underline 0
406
407
408 #
409 # Add the menus as cascades of the toplevel's menu;
410 # add the toplevel's menu to the toplevel
411 #
412 .solver.menubar add cascade \
413 -menu .solver.menubar.file \
414 -label {File} \
415 -underline 0
416 .solver.menubar add cascade \
417 -menu .solver.menubar.edit \
418 -label {Edit} \
419 -underline 0
420 .solver.menubar add cascade \
421 -menu .solver.menubar.display \
422 -label {Display} \
423 -underline 0
424 .solver.menubar add cascade \
425 -menu .solver.menubar.execute \
426 -label {Execute} \
427 -underline 3
428 .solver.menubar add cascade \
429 -menu .solver.menubar.analyze \
430 -label {Analyze} \
431 -underline 0
432 .solver.menubar add cascade \
433 -menu .solver.menubar.view \
434 -label {View} \
435 -underline 0
436 .solver.menubar add cascade \
437 -menu .solver.menubar.export \
438 -label {Export} \
439 -underline 1
440 .solver.menubar add cascade \
441 -menu .solver.menubar.help \
442 -label {Help} \
443 -underline 0
444 .solver configure \
445 -menu .solver.menubar
446
447 # build widget .solver.msg_frm
448 entry .solver.msg_frm \
449 -font $ascSolvVect(font) \
450 -relief {raised} \
451 -exportselection 0 \
452 -state {disabled} \
453 -textvariable {ascSolvVect(modeltype)}
454
455 # build widget .solver.text_frm
456 frame .solver.text_frm
457
458 # build widget .solver.text_frm.text2
459 text .solver.text_frm.text2 \
460 -exportselection 0 \
461 -borderwidth 2 \
462 -height 2 \
463 -relief raised \
464 -width 10 \
465 -wrap none \
466 -state disabled \
467 -yscrollcommand {.solver.text_frm.scrollbar1 set} \
468 -xscrollcommand {.solver.text_frm.scrollbar3 set} \
469 -font $ascSolvVect(font)
470
471 # yes, at the moment the scroll bars might be redundant.
472 # build widget .solver.text_frm.scrollbar1
473 scrollbar .solver.text_frm.scrollbar1 \
474 -command {.solver.text_frm.text2 yview}
475
476 # build widget .solver.text_frm.scrollbar3
477 scrollbar .solver.text_frm.scrollbar3 \
478 -orient horizontal \
479 -command {.solver.text_frm.text2 xview}
480
481 # pack widget .solver.text_frm
482 pack append .solver.text_frm \
483 .solver.text_frm.scrollbar1 {right frame center filly} \
484 .solver.text_frm.text2 {top frame center expand fill} \
485 .solver.text_frm.scrollbar3 {top frame center fillx}
486
487 # build text and table region
488 # pack widget .solver
489 pack append .solver \
490 .solver.lbl_frm {top frame center fillx} \
491 .solver.main_frm {top frame center fillx} \
492 .solver.msg_frm {top frame center fillx} \
493 .solver.text_frm {top frame center expand fill}
494
495
496 EndSrc.solver
497
498 if {"[info procs XFEdit]" != ""} {
499 catch "XFMiscBindWidgetTree .solver"
500 after 2 "catch {XFEditSetShowWindows}"
501 }
502 }
503
504 # proc DestroyWindow.solver {}
505 proc DestroyWindow.solver {} {# xf ignore me 7
506 if {[info procs XFEdit] != ""} {
507 if {[info commands .solver] != ""} {
508 global xfShowWindow.solver
509 set xfShowWindow.solver 0
510 XFEditSetPath .
511 after 2 "XFSaveAsProc .solver; XFEditSetShowWindows"
512 }
513 } else {
514 catch "destroy .solver"
515 update
516 }
517 }
518
519 # proc StartupSrc.solver {args}
520 #-----------
521 # This function defines the labels in the cells
522 # The function Solve_Update_TableVect (in SolverProc.tcl) defines
523 # the values in the cells.
524 #-----------
525 proc StartupSrc.solver {args} {
526 # solver startup entrance
527 global ascSolvTableVect
528 global ascSolvStatVect
529
530 set ascSolvTableVect(0,0) {Relations:}
531 set ascSolvTableVect(1,0) { Active:}
532 set ascSolvTableVect(2,0) { included equalities:}
533 set ascSolvTableVect(3,0) { included inequalities:}
534 set ascSolvTableVect(6,0) { Inactive:}
535 set ascSolvTableVect(7,0) { included equalities:}
536 set ascSolvTableVect(8,0) { included inequalities:}
537 set ascSolvTableVect(9,0) {Unincluded:}
538 set ascSolvTableVect(11,0) {Objective:}
539 set ascSolvTableVect(13,0) {Error:}
540
541 set ascSolvTableVect(0,2) {Variables:}
542 set ascSolvTableVect(1,2) {Active:}
543 set ascSolvTableVect(2,2) { free:}
544 set ascSolvTableVect(3,2) { fixed:}
545 set ascSolvTableVect(4,2) {State:}
546 set ascSolvTableVect(6,2) {Inactive:}
547 set ascSolvTableVect(7,2) { free:}
548 set ascSolvTableVect(8,2) { fixed:}
549 set ascSolvTableVect(9,2) {Unattached:}
550 set ascSolvTableVect(11,2) {Blocks:}
551 set ascSolvTableVect(12,2) {Iterations:}
552 set ascSolvTableVect(13,2) {Current block:}
553 set ascSolvTableVect(14,2) {Solved variables:}
554 }
555
556 # proc EndSrc.solver {}
557 proc EndSrc.solver {} {
558 # solver startup exit
559 # this is getting messy enought that it ought to go to SovlerProc
560 global ascSolvVect
561 if {$ascSolvVect(initialstate)!="iconic" && \
562 $ascSolvVect(initialstate)!="iconified" && \
563 $ascSolvVect(initialstate) !="withdrawn"} {
564 wm deiconify .solver
565 }
566 set ascSolvVect(statTable) .solver.text_frm.text2.statTable
567 set ascSolvVect(statButton) .solver.text_frm.text2.statbutton
568 set ascSolvVect(textBox) .solver.text_frm.text2
569 set ascSolvVect(oldwidth) 0
570 bind .solver.text_frm.text2 <Configure> {
571 Solv_Update_Stattable
572 }
573 if {"$ascSolvVect(initialstate)"=="withdrawn"} {
574 wm withdraw .solver
575 }
576 # bindings on the toplevel descend to all subwidgets. beware? be grateful?
577 # bind .solver <Configure> { puts %W }
578 }
579
580
581 # User defined procedures
582
583
584
585 # Internal procedures
586
587 # eof
588 #

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22