*--------------------------------------
* Prog : Separating Equilibrium - Core prog
* Author : Mag@softlabo.org
* Version 1 : January 28, 2006
* Based on : SOFTLAB® Mandelbrot Set Explorer and SOFTLAB® BiffDuag
* Available at : http://www.softlabo.org/TheMag/Informatics/sepacont/SepaContCoreProg.htm
*--------------------------------------
*THIS.Enabled=.F.
*--- Clockwise bounds : see SOFTLAB® Mandelbrot Set Explorer
X1=0 && 09:00
Y1=1 && 12:00
X2=1 && 15:00
Y2=0 && 18:00
WorkDate=DATE()
nBegRapport=SECONDS()
StartTime=SUBST(TIME(0),1,8)+":"+RIGHT(TIME(0),2)
EndTime="Running!!!"
Duration="Running!!!" && Duration=oSLFormSet.AffiHour(0)
oSLFormSet.SlCommandPanel.txtWorkDate.REFRESH
oSLFormSet.SlCommandPanel.txtStartTime.REFRESH
oSLFormSet.SlCommandPanel.txtEndTime.REFRESH
oSLFormSet.SlCommandPanel.txtDuration.REFRESH
*isRunning=.T. && is drawing
*oSLFormSet.SlCommandPanel.chkForceWH.VALID && Valide Forcing Width/Height : Aspect ratio
*--- Prepare Graphic panel
oSLFormSet.slGraf.slOleboundcontrol.VISIBLE=.F.
oSLFormSet.slGraf.slEdit.VISIBLE=.F.
oSLFormSet.slGraf.Picture=""
oSLFormSet.slGraf.BackColor=aColors[12]
oSLFormSet.slGraf.Cls
oSLFormSet.slGraf.REFRESH
* Tracing a rectangular zone around the map
xWidth =oSLFormSet.slGraf.WIDTH &&-> X axe
yHeight=oSLFormSet.slGraf.HEIGHT-40 &&-> Y axe -40=To Write properties
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
**Symmetry axes
nXCenter=xWidth/2
nYCenter=yHeight/2
*--- Beg Mapping ---*
xRange=X2-X1
xDelta=xRange/xWidth && 3.2/780=0.0041 <=> 1 pixel corresponds = delta(x)=0.0041
yRange=Y1-Y2 && A l'envers.
yDelta=yRange/yHeight && 2.4/400=0.0060 <=> 1 pixel correspond = delta(y)=0.0060
*--- End Mapping ---*
* Visual Point : Plot Axes (0,0)
vX0=(0-X1)/xDelta && Be aware of div
vY0=(Y1-0)/yDelta && Be aware of div
*=== Beg Conditional Axes featuring ===*
*--- Beg Conditional Standard Axes featuring ---*
IF ShowAxesStan=1
oSLFormSet.slGraf.DrawWidth=1
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Line(vX0,0,vX0,yHeight) && Vertical line
oSLFormSet.slGraf.Line(0,vY0-0,xWidth,vY0-0) && Horizontal line
* Visual Point : Plot (X,Y)
* To plot a patricular point, Generalize above formula replacing (0,0) WITH (X,Y)
* Correct, but deactivated by The Mag since itsn't nice to write "O" in the Origin the graph
* oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
* oSLFormSet.slGraf.PSet(vX0-2,vY0-6) && Pointer : Don't change ForeColor
* oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
* oSLFormSet.slGraf.Print("0") && Write it NOW !!!
ENDIF ShowAxesStan=1
*--- End Conditional Standard Axes featuring ---*
*--- Beg Conditional Symmetry Axes featuring ---*
IF ShowAxesSymm=1
oSLFormSet.slGraf.DrawWidth=1
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Line(nXCenter,0,nXCenter,yHeight) && Vertical line
oSLFormSet.slGraf.Line(0,nYCenter,xWidth,nYCenter) && Horizontal line
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
* Correct, but deactivated by The Mag since itsn't nice to write "S" in the center the graph
* oSLFormSet.slGraf.PSet(nXCenter-2,nYCenter-6) && Pointer : Don't change ForColor
* oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
* oSLFormSet.slGraf.Print("S") && Write it NOW !!!
ENDIF ShowAxesSymm=1
*--- End Conditional Symmetry Axes featuring ---*
*=== End Conditional Axes featuring ===*
*--- Explore full area and plot point with the inherent color
xRef=X1 && Cartesian value of X coresponding to current pixel
xDeltaStep=xDelta*xStep
yDeltaStep=yDelta*yStep
oSLFormSet.slGraf.DrawWidth=PenWidth
STORE 0 TO xAAA,xAAR,xARR,xARA,xRAA,xRAR,xRRA,xRRR && Aboslute value
STORE 0 TO yAAA,yAAR,yARR,yARA,yRAA,yRAR,yRRA,yRRR && Relative value
*See associated Article to understand everything
*High Risk-LowRisk-Banker (XXX):=> X| A=Accepts R=Rejects
zlblAAA="AAA="
zlblAAR="AAR="
zlblARR="ARR="
zlblARA="ARA="
zlblRAA="RAA="
zlblRAR="RAR="
zlblRRA="RRA="
zlblRRR="RRR="
FOR x=0 TO xWidth STEP xStep
* isRunning=.T. && is drawing
xRef=xRef+xDeltaStep && Adjusted to step and scale
* Update the Dynamic X,Y position on the Controls Panel.
IF ShowDynaX=1
oSLFormSet.SlCommandPanel.lblDynamicX.Caption = TRANSFORM(xRef,"999 999.999 999 999 999 999")
ENDIF ShowDynaX=1
yRef=Y1 && Cartesian value of Y corresponding to current pixel
FOR y=0 TO yHeight STEP yStep &&
yRef=yRef-yDeltaStep && Minus cause downstairs
IF ShowDynaY=1
oSLFormSet.SlCommandPanel.lblDynamicY.Caption = TRANSFORM(yRef,"999 999.999 999 999 999 999")
ENDIF ShowDynaY=1
* High Risk Participation constraint
IF aH*xRef+bH*yRef<=cH
lHighRisk=.T.
ELSE
lHighRisk=.F.
ENDIF aH*xRef+bH*yRef<=cH
* Low Risk Participation constraint
IF aL*xRef+bL*yRef<=cL
lLowRisk=.T.
ELSE
lLowRisk=.F.
ENDIF aL*xRef+bL*yRef<=cL
* Banker Break even constraint
IF dN*xRef+eN*yRef>=fN
lBanker=.T.
ELSE
lBanker=.F.
ENDIF dN*xRef+eN*yRef>=fN
* Decision making
DO CASE
CASE lHighRisk AND lLowRisk AND lBanker
nColor=aColors[1]
cEquilibrium="AAA"
xAAA=xAAA+1
CASE lHighRisk AND lLowRisk AND !lBanker
nColor=aColors[2]
cEquilibrium="AAR"
xAAR=xAAR+1
CASE lHighRisk AND !lLowRisk AND !lBanker
nColor=aColors[3]
cEquilibrium="ARR"
xARR=xARR+1
CASE lHighRisk AND !lLowRisk AND lBanker
nColor=aColors[4]
cEquilibrium="ARA"
xARA=xARA+1
CASE !lHighRisk AND lLowRisk AND lBanker
nColor=aColors[5]
cEquilibrium="RAA"
xRAA=xRAA+1
CASE !lHighRisk AND lLowRisk AND !lBanker
nColor=aColors[6]
cEquilibrium="RAR"
xRAR=xRAR+1
CASE !lHighRisk AND !lLowRisk AND lBanker
nColor=aColors[7]
cEquilibrium="RRA"
xRRA=xRRA+1
CASE !lHighRisk AND !lLowRisk AND !lBanker
cEquilibrium="RRR"
nColor=aColors[8]
xRRR=xRRR+1
ENDCASE
*--- Plot decision with the adequat color
oSLFormSet.slGraf.ForeColor = nColor
oSLFormSet.slGraf.PSet(x,y)
*-- Conditional Decision visualization
IF ShowDynaZ=1
oSLFormSet.SlCommandPanel.lblDynamicZ.Caption = cEquilibrium
ENDIF ShowDynaZ=1
ENDFOR y=Y1 TO Y2
ENDFOR x=X1 TO X2
DenoMina=xAAA+xAAR+xARR+xARA+xRAA+xRAR+xRRA+xRRR && Aboslute value
IF DenoMina#0
yAAA=xAAA/DenoMina
yAAR=xAAR/DenoMina
yARR=xARR/DenoMina
yARA=xARA/DenoMina
yRAA=xRAA/DenoMina
yRAR=xRAR/DenoMina
yRRA=xRRA/DenoMina
yRRR=xRRR/DenoMina
* Good, but we want to use it/them eslwhere too !
*oSLFormSet.SlColorPanel.lblAAA.Caption="AAA="+TRANSFORM(yAAA,".9999")
zlblAAA="AAA="+TRANSFORM(yAAA,".9999")
zlblAAR="AAR="+TRANSFORM(yAAR,".9999")
zlblARR="ARR="+TRANSFORM(yARR,".9999")
zlblARA="ARA="+TRANSFORM(yARA,".9999")
zlblRAA="RAA="+TRANSFORM(yRAA,".9999")
zlblRAR="RAR="+TRANSFORM(yRAR,".9999")
zlblRRA="RRA="+TRANSFORM(yRRA,".9999")
zlblRRR="RRR="+TRANSFORM(yRRR,".9999")
oSLFormSet.SlColorPanel.lblAAA.Caption=zlblAAA
oSLFormSet.SlColorPanel.lblAAR.Caption=zlblAAR
oSLFormSet.SlColorPanel.lblARR.Caption=zlblARR
oSLFormSet.SlColorPanel.lblARA.Caption=zlblARA
oSLFormSet.SlColorPanel.lblRAA.Caption=zlblRAA
oSLFormSet.SlColorPanel.lblRAR.Caption=zlblRAR
oSLFormSet.SlColorPanel.lblRRA.Caption=zlblRRA
oSLFormSet.SlColorPanel.lblRRR.Caption=zlblRRR
oSLFormSet.SlColorPanel.REFRESH
ENDIF DenoMina#0
EndTime=SUBST(TIME(0),1,8)+":"+RIGHT(TIME(0),2)
nEndRapport=SECONDS()
IF nEndRapport<nBegRapport && Across a day
nDuraRapport=nEndRapport+(86400-nBegRapport) && 24h*60mn*60ss = 86400
ELSE
nDuraRapport=nEndRapport-nBegRapport
ENDIF nEndRapport<nBegRapport && Across a day. Why should we always work overnight?
Duration=oSLFormSet.AffiHour(nDuraRapport/3600) && AffiHour(nRealHour)
oSLFormSet.SlCommandPanel.txtEndTime.REFRESH
oSLFormSet.SlCommandPanel.txtDuration.REFRESH
oSLFormSet.slGraf.DrawWidth=1
*--- Beg Conditional printing Date - Time - Duration issues ---*
IF PrintDate=1
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(3*xWidth/4 ,yHeight+1) && Middle of visible Y axis
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
* iMaxiIter="DateTime="+TRANSFORM(DATETIME()) && Too Long ?
iMaxiIter="Date="+TRANSFORM(DATE())
oSLFormSet.slGraf.Print(iMaxiIter) && Write it NOW !!!
ENDIF PrintDate=1
IF PrintStart=1
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(3*xWidth/4,yHeight+11) && Middle of visible Y axis
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
iMaxiIter="Start="+StartTime
oSLFormSet.slGraf.Print(iMaxiIter) && Write it NOW !!!
ENDIF PrintIter=1
IF PrintEnd=1
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(3*xWidth/4,yHeight+21) && Middle of visible Y axis
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
iMaxiIter="End ="+EndTime
oSLFormSet.slGraf.Print(iMaxiIter) && Write it NOW !!!
ENDIF PrintEnd=1
IF PrintDura=1
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(3*xWidth/4,yHeight+31) && Middle of visible Y axis
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
iMaxiIter="Dura="+Duration
oSLFormSet.slGraf.Print(iMaxiIter) && Write it NOW !!!
ENDIF PrintDura=1
*--- End Conditional printing Date - Time - Duration issues ---*
*=== Beg Conditional Axes featuring ===*
*--- Beg Conditional Standard Axes featuring ---*
IF ShowAxesStan=1
oSLFormSet.slGraf.DrawWidth=1
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Line(vX0,0,vX0,yHeight) && Vertical line
oSLFormSet.slGraf.Line(0,vY0-0,xWidth,vY0-0) && Horizontal line
* Visual Point : Plot (X,Y)
* To plot a patricular point, Generalize above formula replacing (0,0) WITH (X,Y)
* Correct, but deactivated by The Mag since itsn't nice to write "O" in the Origin the graph
* oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
* oSLFormSet.slGraf.PSet(vX0-2,vY0-6) && Pointer : Don't change ForColor
* oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
* oSLFormSet.slGraf.Print("0") && Write it NOW !!!
ENDIF ShowAxesStan=1
*--- End Conditional Standard Axes featuring ---*
*--- Beg Conditional Symmetry Axes featuring ---*
IF ShowAxesSymm=1
oSLFormSet.slGraf.DrawWidth=1
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Line(nXCenter,0,nXCenter,yHeight) && Vertical line
oSLFormSet.slGraf.Line(0,nYCenter,xWidth,nYCenter) && Horizontal line
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
* Correct, but deactivated by The Mag since itsn't nice to write "S" in the center the graph
* oSLFormSet.slGraf.PSet(nXCenter-2,nYCenter-6) && Pointer : Don't change ForColor
* oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
* oSLFormSet.slGraf.Print("S") && Write it NOW !!!
ENDIF ShowAxesSymm=1
*--- End Conditional Symmetry Axes featuring ---*
*=== End Conditional Axes featuring ===*
*--- Beg Conditional printing Financial parameters ---*
IF PrinInequations=1
TextHigh=" High :"+TRANSFORM(aH)+"X+"+TRANSFORM(bH)+"Y<="+TRANSFORM(cH)
TextLow =" Low :"+TRANSFORM(aL)+"X+"+TRANSFORM(bL)+"Y<="+TRANSFORM(cL)
TextBank=" Bank :"+TRANSFORM(dN)+"X+"+TRANSFORM(eN)+"Y>="+TRANSFORM(fN)
TextMag =" Magloire LANHA" && " © 2006 Magloire LANHA - SOFTLAB®"
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(0,yHeight+1)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(TextHigh)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(0,yHeight+11)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(TextLow)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(0,yHeight+21)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(TextBank)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(0,yHeight+31)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(TextMag)
ENDIF PrinInequations=1
*--- End Conditional printing Financial parameters ---*
*--- Beg Conditional printing Results ---*
IF PrintResults=1
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(1*xWidth/4,yHeight+1)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(zlblAAA)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(1*xWidth/4,yHeight+11)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(zlblAAR)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(1*xWidth/4,yHeight+21)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(zlblARR)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(1*xWidth/4,yHeight+31)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(zlblARA)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(2*xWidth/4,yHeight+1)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(zlblRAA)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(2*xWidth/4,yHeight+11)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(zlblRAR)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(2*xWidth/4,yHeight+21)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(zlblRRA)
oSLFormSet.slGraf.ForeColor=aColors[12] && TO make it invisible for humann being
oSLFormSet.slGraf.PSet(2*xWidth/4,yHeight+31)
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
oSLFormSet.slGraf.Print(zlblRRR)
ENDIF PrintResults=1
*--- End Conditional printing Results ---*
*--- Conditional Ending Beep
IF BeepAfteGraf=1
SET BELL TO CurrEndBeepFile,0
??CHR(7)
ENDIF BeepAfteGraf=1
MessText="The End"
WAIT WIND MessText AT SROW()/2,(SCOL()-LEN(MessText))/2 TIMEOUT 1
isRunning=.F.
*---- AutoSaveImage
*IF AutoSave=1
* oSLFormSet.SlGaleryMan.cmdSave.Click
*ENDIF AutoSave=1
*--- Set Focus to Who ?
*THIS.PARENT.cmdClose.SETFOCUS
RETURN
|