-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create ApplicationBlockGraph interface, jvm impl
- Loading branch information
Showing
15 changed files
with
1,327 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ buildSrc/.gradle | |
|
||
# Ignore Idea directory | ||
.idea | ||
|
||
# Ignore MacOS-specific files | ||
/**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
usvm-path-selection/src/main/kotlin/org/usvm/MLMachineOptions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.usvm | ||
|
||
enum class MLPathSelectionStrategy { | ||
/** | ||
* Collects features according to states selected by any other path selector. | ||
*/ | ||
FEATURES_LOGGING, | ||
|
||
/** | ||
* Collects features and feeds them to the ML model to select states. | ||
* Extends FEATURE_LOGGING path selector. | ||
*/ | ||
MACHINE_LEARNING, | ||
|
||
/** | ||
* Selects states with best Graph Neural Network state score | ||
*/ | ||
GNN, | ||
} | ||
|
||
data class MLMachineOptions( | ||
val basicOptions: UMachineOptions, | ||
val pathSelectionStrategy: MLPathSelectionStrategy, | ||
val heteroGNNModelPath: String = "" | ||
) |
53 changes: 53 additions & 0 deletions
53
usvm-path-selection/src/main/kotlin/org/usvm/MLPathSelectorStrategy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.usvm | ||
|
||
import org.usvm.ps.ExceptionPropagationPathSelector | ||
import org.usvm.ps.GNNPathSelector | ||
import org.usvm.statistics.CoverageStatistics | ||
import org.usvm.statistics.StateVisitsStatistics | ||
|
||
fun <Method, Statement, BasicBlock, State : UState<*, Method, Statement, *, *, State>> createPathSelector( | ||
initialState: State, | ||
options: MLMachineOptions, | ||
applicationGraph: ApplicationBlockGraph<Method, BasicBlock, Statement>, | ||
stateVisitsStatistics: StateVisitsStatistics<Method, Statement, State>, | ||
coverageStatistics: CoverageStatistics<Method, Statement, State>, | ||
): UPathSelector<State> { | ||
val selector = when (options.pathSelectionStrategy) { | ||
MLPathSelectionStrategy.GNN -> createGNNPathSelector( | ||
stateVisitsStatistics, | ||
coverageStatistics, applicationGraph, options.heteroGNNModelPath | ||
) | ||
|
||
else -> { | ||
throw NotImplementedError() | ||
} | ||
} | ||
|
||
val propagateExceptions = options.basicOptions.exceptionsPropagation | ||
|
||
val resultSelector = selector.wrapIfRequired(propagateExceptions) | ||
resultSelector.add(listOf(initialState)) | ||
|
||
return selector | ||
} | ||
|
||
private fun <State : UState<*, *, *, *, *, State>> UPathSelector<State>.wrapIfRequired(propagateExceptions: Boolean) = | ||
if (propagateExceptions && this !is ExceptionPropagationPathSelector<State>) { | ||
ExceptionPropagationPathSelector(this) | ||
} else { | ||
this | ||
} | ||
|
||
private fun <Method, Statement, BasicBlock, State : UState<*, Method, Statement, *, *, State>> createGNNPathSelector( | ||
stateVisitsStatistics: StateVisitsStatistics<Method, Statement, State>, | ||
coverageStatistics: CoverageStatistics<Method, Statement, State>, | ||
applicationGraph: ApplicationBlockGraph<Method, BasicBlock, Statement>, | ||
heteroGNNModelPath: String, | ||
): UPathSelector<State> { | ||
return GNNPathSelector( | ||
coverageStatistics, | ||
stateVisitsStatistics, | ||
applicationGraph, | ||
heteroGNNModelPath | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.