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
sensitivity = 1; | |
epsilon = 0.1; | |
scale = sensitivity/epsilon; | |
for i=1:520 | |
laplace = round(randlap(0,scale)); | |
dsrand(i,1) = dsrand(i,1) + laplace; % our function | |
end |
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
function y = randlap(mu, sigma) | |
% mean mu and standard deviation sigma. | |
% mu : mean | |
% sigma : standard deviation | |
% Generate Laplacian noise | |
u = rand(1, 1)-0.5; | |
b = sigma / sqrt(2); |
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
for i=1:520 | |
ageValue = dsrand(i,1); | |
if ageValue >=10 && ageValue < 20 | |
dsrand(i,1) = 1; | |
end | |
if ageValue >=20 && ageValue < 30 | |
dsrand(i,1) = 2; | |
end | |
if ageValue >=30 && ageValue < 40 | |
dsrand(i,1) = 3; |
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
% shufle dataset | |
[D,n] = size(dataset); | |
dsrand = dataset(randperm(D), :); | |
t = dsrand(:,17); | |
x = dsrand(:,1:16); | |
%---------FFNN | |
target_t = []; | |
for i=1:520 |
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
class LoadSimulator{ | |
@Inject | |
lateinit var propertiesConfiguration: PropertiesConfiguration | |
/** | |
* Process the request | |
*/ | |
suspend fun processLoad(): HelloWorld { |
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
@MicronautTest(propertySources = ["application.yml"]) | |
class RestControllerTest{ | |
@Inject | |
@field:Client("/") | |
lateinit var client : RxHttpClient | |
@Test | |
@Property(name = "microservice.returnMessage", value = "My message") | |
fun shoudReturnMyMessage() { |
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
@MicronautTest | |
internal class ResourceValidatorTest{ | |
@Test | |
internal fun shouldValidateIdAsValidUUID() { | |
val validator: Validator<Resource> = ResourceValidator() | |
val resource = Resource(UUID.randomUUID().toString()) | |
val result: ValidationResult = validator.validate(resource) |
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
@MicronautTest | |
internal class ResourceValidatorTest{ | |
@Test | |
internal fun shouldValidadeIdAsInvalidUUID() { | |
val validator: Validator<Resource> = ResourceValidator() | |
val resource: Resource = Resource("invalidId") | |
val result: ValidationResult = validator.validate(resource) |
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
@MicronautTest(propertySources = ["application.yml"]) | |
@Property(name = "microservice.threads", value = "1") | |
class LoadSimulatorTest{ | |
@Inject | |
lateinit var loadSimulator: LoadSimulator | |
@Test | |
@Property(name = "microservice.processingTime", value = "1000") | |
fun shouldTakeTimeDefinedForProcessing() = runBlocking<Unit> { |
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
class ResourceValidator() : AbstractValidator<Resource>() { | |
val UUID_REGEX: String = "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" | |
override fun rules() { | |
ruleFor(Resource::id) | |
.must(stringMatches(UUID_REGEX)) | |
.`when`(not(nullValue())) | |
.withMessage("The Resource Id is not valid") |
NewerOlder