> | restart; |
> | with(Maplets[Elements]): |
> | with(LinearAlgebra): |
> | cent_cit_m:=proc(p1,p2,b1)
local A,b,b2,l,i,j,h,M; b2:=p1-b1+p2; if b2<0 then " Attenzione: b2 < 0 !" else A:=<<1,0,0,0>|<1,1,0,0>|<0,-1,1,0>|<0,0,1,0>>; b:=<p1,p1-b1,p2,0>; l:=LinearSolve(A,b,free='t',method='subs'); h:=[seq(sort(l[i],t[1],ascending),i=1..4)]; M:=NULL; for j to 4 do if (type(op(h[j])[1], negative) and evalb(op(h[j])[2]=-t[1])) then M:=M,j; end if; end do; if nops([M]) > 0 then "non ci possono essere soluzioni >=0 perché c'e' una condizione del tipo: -n-t; scegli altri valori di p1,p2 e b1."; else ["b2 = Kw:",b2, "Condizioni:",h]; end if; end if; end proc: intervallo:=proc(hh) local i,M1,j,M2,k,l,h; h:=[seq(sort(hh[i],t[1],ascending),i=1..4)]; M1:=NULL; for j to 4 do if type(op(h[j])[1], negative) then M1:=M1,-op(h[j])[1]; end if; end do; M1; M2:=NULL; for k to 4 do if (type(op(h[k])[1], positive) and evalb(op(h[k])[2]=-t[1])) then M2:=M2,op(h[k])[1]; end if; end do; M2; if nops([M1])=3 then "t[1]>=", max(M1); elif nops([M1])=2 then if nops([M2])=1 then if max(M2) >= max(M1) then max(M2),">= t[1]>=", max(M1); else "non ci sono soluzioni."; end if; else "t[1]>=", max(M1); end if; elif nops([M1])=1 then if nops([M2])>=1 then if min(M2) >= max(M1) then min(M2),">=t[1]>=",max(M1); else "non ci sono soluzioni"; end if; else "t[1] >=",max(M1); end if; elif nops([M1])=0 then if nops([M2])>=1 then min(M2),">=t[1]>=",0; else "t[1]>=",0; end if; end if; end proc: sost:=proc(L,u) "x_11 = Kw:",(eval(L,[t[1]=u]))[1],"x_12 = Kw:",(eval(L,[t[1]=u]))[2],"x_21 = Kw:", (eval(L,[t[1]=u]))[3],"x_22 = Kw:",(eval(L,[t[1]=u]))[4]; end proc: maplet_c_t := Maplet( 'onstartup' = RunWindow( 'W1' ),Font['F1']( 'family' = "helvetica",'size'=12 ),Window['W1']( "Centrali e Città", [ BoxCell( 'center', TextBox( 'editable' = 'false', 'width' = 70,'font' = 'F1', "Produzione: Aurisina p_1 Kw, Monfalcone p_2 Kw. Richiesta: Ts: b_1 Kw, Go: b_2 Kw.")), BoxCell( 'center', TextBox( 'editable' = 'false', 'width' = 70,'font' = 'F1', "Aurisina eroga x_11 Kw a Ts e x_12 Kw a Go. Monfalcone eroga x_21 Kw a Ts e x_22 Kw a Go. ")),BoxCell( 'center', TextBox( 'editable' = 'false', 'width' = 70,'font' = 'F1', "Inserendo i valori di p_1, p_2 e b_1, trovi b_2 e delle condizioni in t[1]. Poi devi scegliere t[1] in modo che tutte le coordinate siano >= 0.")), ["p_1 = Kw: ", TextField['TF1']()], ["p_2 = Kw: ", TextField['TF2']()], ["b_1 = Kw: ", TextField['TF3']()], TextBox['TB1']('editable' = 'false', 3..40 ), TextBox['TB2']('editable' = 'false', 3..40 ), TextBox['TB3']('editable' = 'false', 3..40 ), ["3.Inserisci un valore di t[1] fra quelli possibili mostrati nel secondo display:", TextField['TF4']()], [Button("1.Condizioni in t[1]", Evaluate('TB1' = 'cent_cit_m(TF1,TF2,TF3)')), Button("2.Scelte possibili di t[1]", Evaluate('TB2' = 'intervallo(cent_cit_m(TF1,TF2,TF3)[4])')), Button("4.Soluzioni", Evaluate('TB3' = 'sost((cent_cit_m(TF1,TF2,TF3)[4]),TF4)')), Button("Esci", Shutdown(['TF1', 'TF2','TF3','TF4', 'TB1', 'TB2','TB3'])), Button("Cancella", Action(SetOption('TF1' = ""),SetOption('TF2' = ""),SetOption('TF3' = ""),SetOption('TF4' = ""),SetOption('TB1' = ""),SetOption('TB2' = ""),SetOption('TB3' = "")))]] )): Maplets[Display]( maplet_c_t); |
> |