Skip to content

Commit 73841bd

Browse files
committed
All about AI searcher in single one commit.
1 parent 7aee14b commit 73841bd

35 files changed

+1864
-128
lines changed

.DS_Store

-8 KB
Binary file not shown.

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
language: csharp
22
mono: none
3-
dotnet: 3.0.100
3+
dotnet: 6.0
44
solution: VSharp.sln
55
install:
66
- dotnet restore
7+
- dotnet tool restore
78
script:
89
- dotnet test -c Release

VSharp.API/VSharp.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Reflection;
77
using System.Text;
8+
using Microsoft.FSharp.Core;
89
using VSharp.CoverageTool;
910
using VSharp.CSharpUtils;
1011
using VSharp.Interpreter.IL;
@@ -178,6 +179,7 @@ private static Statistics StartExploration(
178179
explorationMode: explorationMode.NewTestCoverageMode(
179180
coverageZone,
180181
options.Timeout > 0 ? searchMode.NewFairMode(baseSearchMode) : baseSearchMode
182+
181183
),
182184
recThreshold: options.RecursionThreshold,
183185
solverTimeout: options.SolverTimeout,
@@ -188,8 +190,9 @@ private static Statistics StartExploration(
188190
checkAttributes: true,
189191
stopOnCoverageAchieved: 100,
190192
randomSeed: options.RandomSeed,
191-
stepsLimit: options.StepsLimit
192-
);
193+
stepsLimit: options.StepsLimit,
194+
aiAgentTrainingOptions: options.AIAgentTrainingOptions == null ? FSharpOption<AIAgentTrainingOptions>.None :FSharpOption<AIAgentTrainingOptions>.Some(options.AIAgentTrainingOptions),
195+
pathToModel: options.PathToModel == null ? FSharpOption<string>.None : FSharpOption<string>.Some(options.PathToModel));
193196

194197
var fuzzerOptions =
195198
new FuzzerOptions(
@@ -279,6 +282,7 @@ private static searchMode ToSiliMode(this SearchStrategy searchStrategy)
279282
SearchStrategy.ExecutionTree => searchMode.ExecutionTreeMode,
280283
SearchStrategy.ExecutionTreeContributedCoverage => searchMode.NewInterleavedMode(searchMode.ExecutionTreeMode, 1, searchMode.ContributedCoverageMode, 1),
281284
SearchStrategy.Interleaved => searchMode.NewInterleavedMode(searchMode.ShortestDistanceBasedMode, 1, searchMode.ContributedCoverageMode, 9),
285+
SearchStrategy.AI => searchMode.AIMode,
282286
_ => throw new UnreachableException("Unknown search strategy")
283287
};
284288
}

VSharp.API/VSharpOptions.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System.IO;
2+
using Microsoft.FSharp.Core;
3+
using VSharp.Explorer;
24

35
namespace VSharp;
46

@@ -38,7 +40,8 @@ public enum SearchStrategy
3840
/// <summary>
3941
/// Interleaves <see cref="ShortestDistance"/> and <see cref="ContributedCoverage"/> strategies.
4042
/// </summary>
41-
Interleaved
43+
Interleaved,
44+
AI
4245
}
4346

4447
/// <summary>
@@ -96,6 +99,7 @@ public readonly record struct VSharpOptions
9699
private const bool DefaultReleaseBranches = true;
97100
private const int DefaultRandomSeed = -1;
98101
private const uint DefaultStepsLimit = 0;
102+
private const string DefaultPathToModel = "models/model.onnx";
99103

100104
public readonly int Timeout = DefaultTimeout;
101105
public readonly int SolverTimeout = DefaultSolverTimeout;
@@ -109,6 +113,8 @@ public readonly record struct VSharpOptions
109113
public readonly bool ReleaseBranches = DefaultReleaseBranches;
110114
public readonly int RandomSeed = DefaultRandomSeed;
111115
public readonly uint StepsLimit = DefaultStepsLimit;
116+
public readonly AIAgentTrainingOptions AIAgentTrainingOptions = null;
117+
public readonly string PathToModel = DefaultPathToModel;
112118

113119
/// <summary>
114120
/// Symbolic virtual machine options.
@@ -125,6 +131,8 @@ public readonly record struct VSharpOptions
125131
/// <param name="releaseBranches">If true and timeout is specified, a part of allotted time in the end is given to execute remaining states without branching.</param>
126132
/// <param name="randomSeed">Fixed seed for random operations. Used if greater than or equal to zero.</param>
127133
/// <param name="stepsLimit">Number of symbolic machine steps to stop execution after. Zero value means no limit.</param>
134+
/// <param name="aiAgentTrainingOptions">Settings for AI searcher training.</param>
135+
/// <param name="pathToModel">Path to ONNX file with model to use in AI searcher.</param>
128136
public VSharpOptions(
129137
int timeout = DefaultTimeout,
130138
int solverTimeout = DefaultSolverTimeout,
@@ -137,7 +145,9 @@ public VSharpOptions(
137145
ExplorationMode explorationMode = DefaultExplorationMode,
138146
bool releaseBranches = DefaultReleaseBranches,
139147
int randomSeed = DefaultRandomSeed,
140-
uint stepsLimit = DefaultStepsLimit)
148+
uint stepsLimit = DefaultStepsLimit,
149+
AIAgentTrainingOptions aiAgentTrainingOptions = null,
150+
string pathToModel = DefaultPathToModel)
141151
{
142152
Timeout = timeout;
143153
SolverTimeout = solverTimeout;
@@ -151,11 +161,18 @@ public VSharpOptions(
151161
ReleaseBranches = releaseBranches;
152162
RandomSeed = randomSeed;
153163
StepsLimit = stepsLimit;
164+
AIAgentTrainingOptions = aiAgentTrainingOptions;
165+
PathToModel = pathToModel;
154166
}
155167

156168
/// <summary>
157169
/// <seealso cref="RenderedTestsDirectory"/>
158170
/// </summary>
159171
public DirectoryInfo RenderedTestsDirectoryInfo =>
160172
Directory.Exists(RenderedTestsDirectory) ? new DirectoryInfo(RenderedTestsDirectory) : null;
173+
174+
public string GetDefaultPathToModel()
175+
{
176+
return DefaultPathToModel;
177+
}
161178
}

0 commit comments

Comments
 (0)