DIRECTORY Basics, Random, RealFns, SC, SCInstUtil, SCNetUtil, SCPrivate, SCPlaceUtil, SCWidthUtil, SCRowUtil, SCUtil, RTSets, TerminalIO; SCSAPlaceImpl: CEDAR PROGRAM IMPORTS Random, RealFns, SC, SCInstUtil, SCNetUtil, SCPlaceUtil, SCRowUtil, SCWidthUtil, SCUtil, TerminalIO EXPORTS SCPrivate SHARES SC = { debug: BOOLEAN _ TRUE; ExchDescription: TYPE = RECORD [ inst1, inst2: SCPrivate.Instance _ NIL]; Freezing: PROCEDURE [score: REAL, temp: REAL] RETURNS [BOOLEAN] = { RETURN[TRUE]}; Equilibrium: PROCEDURE [score: REAL] RETURNS [BOOLEAN] = { RETURN[TRUE]}; Select: PROCEDURE [handle: SC.Handle, selectStream: Random.RandomStream] RETURNS [exch: ExchDescription _ [NIL, NIL]] = { structureData: SCPrivate.StructureData _ NARROW[handle.structureData]; numInstances: SCPrivate.ZMaxInstanceSr _ structureData.instances.count; numLogics: SCPrivate.ZMaxInstanceSr _ structureData.instances.numLogics; numIOs: SCPrivate.ZMaxInstanceSr _ structureData.instances.numIOs; index: SCPrivate.ZMaxInstanceSr _ Random.ChooseInt[selectStream, 1, numInstances]; otherIndex: SCPrivate.ZMaxInstanceSr; inst1, inst2: SCPrivate.Instance; IF 1 <= index AND index <= numIOs THEN { inst1 _ GetNextIo[index]; IF inst1 = NIL THEN RETURN ELSE { otherIndex _ Random.ChooseInt[selectStream, 1, numIOs]; inst2 _ GetNextIo[otherIndex]; IF inst2 = NIL THEN RETURN}} ELSE { logicIndex: SCPrivate.ZMaxInstanceSr _ index - numIOs; IF 1 <= logicIndex AND logicIndex <= numLogics THEN { inst1 _ GetNextLogic[logicIndex]; IF inst1 = NIL THEN RETURN ELSE { otherIndex _ Random.ChooseInt[selectStream, numIOs + 1, numInstances]; inst2 _ GetNextLogic[otherIndex]; IF inst2 = NIL THEN RETURN}} ELSE SC.Error[programmingError, "Invalid instance index"]}; RETURN[[inst1, inst2]]}; GetNextIo: PROCEDURE [index: SCPrivate.ZMaxInstanceSr] RETURNS [instance: SCPrivate.Instance]= { RETURN[instance]}; GetNextLogic: PROCEDURE [index: SCPrivate.ZMaxInstanceSr] RETURNS [instance: SCPrivate.Instance]= { RETURN[instance]}; Exchange: PROCEDURE [handle: SC.Handle, exch: ExchDescription] RETURNS [didIt: BOOLEAN _ TRUE] = { }; FullScore: PROCEDURE [handle: SC.Handle] RETURNS [score: REAL] = { RETURN[score]}; ModScore: PROCEDURE [handle: SC.Handle, exch: ExchDescription] RETURNS [score: REAL]= { RETURN[score]}; Random0To1: PROCEDURE [choiceStream: Random.RandomStream] RETURNS [value: REAL]= { RETURN[value]}; SAPlace: PUBLIC PROCEDURE [handle: SC.Handle, t0, alpha: REAL, seed: INT] = { layoutData: SCPrivate.LayoutData _ NARROW[handle.layoutData]; structureData: SCPrivate.StructureData _ NARROW[handle.structureData]; lgRows: SCPrivate.LgRows _ layoutData.lgRows; selectStream: Random.RandomStream _ Random.Create[LAST[INT], seed]; choiceStream: Random.RandomStream _ Random.Create[LAST[INT], seed]; startArea: SC.Number; temp: REAL _ t0; score: REAL _ FullScore[handle]; [lgRows.maxRowWidth, lgRows.numMaxRows] _ SCRowUtil.FindMaxRow[handle]; SCWidthUtil.AllChanWidths[handle, areaFom]; SCInstUtil.AsgnChanPos[handle]; startArea _ SCUtil.WriteResults["Position improvement\n starting area:", handle, 0]; UNTIL Freezing[score, temp] DO UNTIL Equilibrium[score] DO exch: ExchDescription _ Select[handle, selectStream]; didIt: BOOLEAN _ Exchange[handle, exch]; IF didIt THEN { trialScore: REAL _ ModScore[handle, exch]; deltaScore: REAL _ trialScore - score; IF deltaScore < 0.0 THEN score _ trialScore ELSE { random: REAL _ Random0To1[choiceStream]; IF random < RealFns.Exp[-deltaScore/temp] THEN { [] _ Exchange[handle, exch]; score _ ModScore[handle, exch]}}}; ENDLOOP; temp _ alpha * temp; ENDLOOP; SCInstUtil.AllOffsets[handle]; [lgRows.maxRowWidth, lgRows.numMaxRows] _ SCRowUtil.FindMaxRow[handle]; SCWidthUtil.AllChanWidths[handle, areaFom]; SCInstUtil.AsgnChanPos[handle]; [] _ SCUtil.WriteResults["End position improvement\n ending area:", handle, startArea]; IF debug THEN SCPlaceUtil.WriteCurPlace[handle]}; }. ”file: SCSAPlaceImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. got an IO, get another IO got a logic, get another logic Κν˜šœ™Icodešœ Οmœ0™;—J˜šΟk ˜ J˜Jšœ˜J˜Jšžœ˜Jšœ ˜ J˜ J˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ J˜Jšœ˜Jšœ ˜ J˜—šœžœž˜J˜JšžœžœP˜kJ˜Jšžœ ˜Jšžœžœ˜J˜Jšœžœžœ˜šœžœžœ˜ Jšœ#žœ˜(—J˜š Οnœž œ žœžœžœžœ˜CJ˜Jšžœžœ˜J˜—š Ÿ œž œ žœžœžœ˜:J˜Jšžœžœ˜J˜—š Ÿœž œ žœ,žœžœžœ˜yJ˜Jšœ)žœ˜FJšœG˜GJšœH˜HJšœB˜BJšœR˜RJšœ%˜%Jšœ!˜!šžœ žœžœ˜(Jšœ™Jšœ˜Jšžœ žœžœž˜šžœ˜Jšœ7˜7Jšœ˜Jšžœ žœžœžœ˜——šžœ˜Jšœ6˜6šžœžœžœ˜5Jšœ™Jšœ!˜!Jšžœ žœžœž˜šžœ˜JšœF˜FJšœ!˜!Jšžœ žœžœžœ˜——Jšžœžœ4˜;—Jšžœ˜J˜—šŸ œž œ#žœ"˜`J˜Jšžœ ˜J˜—šŸ œž œ#žœ"˜cJ˜Jšžœ ˜J˜—š Ÿœž œ žœ žœ žœ˜bJ˜Jšœ˜J˜—š Ÿ œž œ žœ žœ žœ˜BJ˜Jšžœ ˜J˜—š Ÿœž œ žœ žœ žœ˜WJ˜Jšžœ ˜J˜—šŸ œž œ%žœ žœ˜RJ˜Jšžœ ˜J˜—š Ÿœžœž œ žœžœžœ˜MJ˜Jšœ#žœ˜=Jšœ)žœ˜FJšœ-˜-Jšœ2žœžœ ˜CJšœ2žœžœ ˜CJšœ žœ˜Jšœžœ˜Jšœžœ˜ J˜JšœG˜GJšœ+˜+Jšœ˜JšœT˜TJ˜šžœž˜šžœž˜Jšœ5˜5Jšœžœ˜(šžœžœ˜Jšœ žœ˜*Jšœ žœ˜&Jšžœžœ˜+šžœ˜Jšœžœ˜(šžœ(žœ˜0Jšœ˜Jšœ"˜"———Jšžœ˜—J˜Jšžœ˜—J˜Jšœ˜JšœG˜GJšœ+˜+Jšœ˜J˜JšœW˜WJšžœžœ$˜1—Jšœ˜——…—FΗ