Skip to content

Commit d52d8c9

Browse files
authored
removed pathConditionRoot from the states in V#
removing pathConditionRoot from the states
2 parents 47a76a3 + 156fa71 commit d52d8c9

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

VSharp.Explorer/AISearcher.fs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,18 @@ type internal AISearcher(oracle: Oracle, aiAgentTrainingMode: Option<AIAgentTrai
295295

296296
OrtValue.CreateTensorValueFromMemory(attributes, shape)
297297

298-
let states, numOfParentOfEdges, numOfHistoryEdges =
298+
let states, numOfParentOfEdges, numOfPathConditionEdges, numOfHistoryEdges =
299299
let mutable numOfParentOfEdges = 0
300+
let mutable numOfPathConditionEdges = 0
300301
let mutable numOfHistoryEdges = 0
301302
let shape = [| int64 gameState.States.Length; numOfStateAttributes |]
302303
let attributes = Array.zeroCreate (gameState.States.Length * numOfStateAttributes)
303304

304305
for i in 0 .. gameState.States.Length - 1 do
305306
let v = gameState.States.[i]
306-
numOfHistoryEdges <- numOfHistoryEdges + v.History.Length
307307
numOfParentOfEdges <- numOfParentOfEdges + v.Children.Length
308+
numOfPathConditionEdges <- numOfPathConditionEdges + v.PathCondition.Length
309+
numOfHistoryEdges <- numOfHistoryEdges + v.History.Length
308310
stateIds.Add(v.Id, i)
309311
let j = i * numOfStateAttributes
310312
attributes.[j] <- float32 v.Position
@@ -314,7 +316,7 @@ type internal AISearcher(oracle: Oracle, aiAgentTrainingMode: Option<AIAgentTrai
314316
attributes.[j + 4] <- float32 v.StepWhenMovedLastTime
315317
attributes.[j + 5] <- float32 v.InstructionsVisitedInCurrentBlock
316318

317-
OrtValue.CreateTensorValueFromMemory(attributes, shape), numOfParentOfEdges, numOfHistoryEdges
319+
OrtValue.CreateTensorValueFromMemory(attributes, shape), numOfParentOfEdges, numOfPathConditionEdges, numOfHistoryEdges
318320

319321
let pcToPcEdgeIndex =
320322
let shapeOfIndex = [| 2L; numOfPcToPcEdges |]
@@ -361,8 +363,8 @@ type internal AISearcher(oracle: Oracle, aiAgentTrainingMode: Option<AIAgentTrai
361363
let parentOf = Array.zeroCreate (2 * numOfParentOfEdges)
362364
let shapeOfHistory = [| 2L; numOfHistoryEdges |]
363365
let historyIndex_vertexToState = Array.zeroCreate (2 * numOfHistoryEdges)
364-
let shapeOfPcToState = [| 2L; gameState.States.Length |]
365-
let index_pcToState = Array.zeroCreate (2 * gameState.States.Length)
366+
let shapeOfPcToState = [| 2L; numOfPathConditionEdges |]
367+
let index_pcToState = Array.zeroCreate (2 * numOfPathConditionEdges)
366368

367369
let shapeOfHistoryAttributes =
368370
[| int64 numOfHistoryEdges; int64 numOfHistoryEdgeAttributes |]
@@ -383,13 +385,13 @@ type internal AISearcher(oracle: Oracle, aiAgentTrainingMode: Option<AIAgentTrai
383385

384386
firstFreePositionInParentsOf <- firstFreePositionInParentsOf + state.Children.Length
385387

386-
index_pcToState.[firstFreePositionInPcToState] <-
387-
int64 pathConditionVerticesIds[state.PathCondition.Id]
388-
389-
index_pcToState.[firstFreePositionInPcToState + gameState.States.Length] <-
390-
int64 stateIds[state.Id]
391-
392-
firstFreePositionInPcToState <- firstFreePositionInPcToState + 1
388+
state.PathCondition
389+
|> Array.iteri (fun i pcId ->
390+
let j = firstFreePositionInPcToState + i
391+
index_pcToState[j] <- int64 pathConditionVerticesIds[pcId]
392+
index_pcToState[numOfPathConditionEdges + j] <- int64 stateIds[state.Id])
393+
394+
firstFreePositionInPcToState <- firstFreePositionInPcToState + state.PathCondition.Length
393395

394396
state.History
395397
|> Array.iteri (fun i historyElem ->

VSharp.IL/Serializer.fs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,20 +495,13 @@ let collectGameState (basicBlocks: ResizeArray<BasicBlock>) filterStates process
495495
for term in pathCondition do
496496
pathConditionDelta.AddRange(collectPathCondition term termsWithId processedPathConditionVertices)
497497

498-
let pathConditionRoot =
499-
PathConditionVertex(
500-
id = getFirstFreePathConditionVertexId (),
501-
pathConditionVertexType = pathConditionVertexType.PathConditionRoot,
502-
children = [| for p in pathCondition -> termsWithId.[p] |]
503-
)
504-
505-
pathConditionDelta.Add pathConditionRoot
498+
let pathCondition = [| for p in pathCondition -> termsWithId.[p] |]
506499

507500
State(
508501
s.Id,
509502
(uint <| s.CodeLocation.offset - currentBasicBlock.StartOffset + 1<byte_offset>)
510503
* 1u<byte_offset>,
511-
pathConditionRoot,
504+
pathCondition,
512505
s.VisitedAgainVertices,
513506
s.VisitedNotCoveredVerticesInZone,
514507
s.VisitedNotCoveredVerticesOutOfZone,

VSharp.ML.GameServer/Messages.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ type pathConditionVertexType =
7272
| StandardFunctionApplication = 45
7373
| Cast = 46
7474
| Combine = 47
75-
| PathConditionRoot = 48
7675

7776

7877
[<Struct>]
@@ -153,7 +152,7 @@ type StateHistoryElem =
153152
type State =
154153
val Id: uint<stateId>
155154
val Position: uint<byte_offset> // to basic block id
156-
val PathCondition: PathConditionVertex
155+
val PathCondition: array<uint<pathConditionVertexId>>
157156
val VisitedAgainVertices: uint
158157
val VisitedNotCoveredVerticesInZone: uint
159158
val VisitedNotCoveredVerticesOutOfZone: uint

0 commit comments

Comments
 (0)