Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions VSharp.Explorer/AISearcher.fs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,12 @@ type internal AISearcher(oracle: Oracle, aiAgentTrainingMode: Option<AIAgentTrai
let parentOf = Array.zeroCreate (2 * numOfParentOfEdges)
let shapeOfHistory = [| 2L; numOfHistoryEdges |]
let historyIndex_vertexToState = Array.zeroCreate (2 * numOfHistoryEdges)
let shapeOfPcToState = [| 2L; gameState.States.Length |]
let index_pcToState = Array.zeroCreate (2 * gameState.States.Length)

let pathConditionNum =
gameState.States
|> Array.sumBy(fun s -> s.PathCondition.Length)
let shapeOfPcToState = [| 2L; pathConditionNum |]
let index_pcToState = Array.zeroCreate (2 * pathConditionNum)

let shapeOfHistoryAttributes =
[| int64 numOfHistoryEdges; int64 numOfHistoryEdgeAttributes |]
Expand All @@ -383,13 +387,13 @@ type internal AISearcher(oracle: Oracle, aiAgentTrainingMode: Option<AIAgentTrai

firstFreePositionInParentsOf <- firstFreePositionInParentsOf + state.Children.Length

index_pcToState.[firstFreePositionInPcToState] <-
int64 pathConditionVerticesIds[state.PathCondition.Id]

index_pcToState.[firstFreePositionInPcToState + gameState.States.Length] <-
int64 stateIds[state.Id]

firstFreePositionInPcToState <- firstFreePositionInPcToState + 1
state.PathCondition
|> Array.iteri (fun i pcId ->
let j = firstFreePositionInPcToState + i
index_pcToState[j] <- int64 pathConditionVerticesIds[pcId]
index_pcToState[numOfParentOfEdges + j] <- int64 stateIds[state.Id])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so strange position in index_pcToState to write?

firstFreePositionInPcToState <- firstFreePositionInPcToState + state.PathCondition.Length

state.History
|> Array.iteri (fun i historyElem ->
Expand Down
11 changes: 2 additions & 9 deletions VSharp.IL/Serializer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -495,20 +495,13 @@ let collectGameState (basicBlocks: ResizeArray<BasicBlock>) filterStates process
for term in pathCondition do
pathConditionDelta.AddRange(collectPathCondition term termsWithId processedPathConditionVertices)

let pathConditionRoot =
PathConditionVertex(
id = getFirstFreePathConditionVertexId (),
pathConditionVertexType = pathConditionVertexType.PathConditionRoot,
children = [| for p in pathCondition -> termsWithId.[p] |]
)

pathConditionDelta.Add pathConditionRoot
let pathCondition = [| for p in pathCondition -> termsWithId.[p] |]

State(
s.Id,
(uint <| s.CodeLocation.offset - currentBasicBlock.StartOffset + 1<byte_offset>)
* 1u<byte_offset>,
pathConditionRoot,
pathCondition,
s.VisitedAgainVertices,
s.VisitedNotCoveredVerticesInZone,
s.VisitedNotCoveredVerticesOutOfZone,
Expand Down
3 changes: 1 addition & 2 deletions VSharp.ML.GameServer/Messages.fs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ type pathConditionVertexType =
| StandardFunctionApplication = 45
| Cast = 46
| Combine = 47
| PathConditionRoot = 48


[<Struct>]
Expand Down Expand Up @@ -153,7 +152,7 @@ type StateHistoryElem =
type State =
val Id: uint<stateId>
val Position: uint<byte_offset> // to basic block id
val PathCondition: PathConditionVertex
val PathCondition: array<uint<pathConditionVertexId>>
val VisitedAgainVertices: uint
val VisitedNotCoveredVerticesInZone: uint
val VisitedNotCoveredVerticesOutOfZone: uint
Expand Down
Loading