-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestSampling.jl
89 lines (74 loc) · 2.6 KB
/
testSampling.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
include("MESDP.jl")
include("ReadGSet.jl")
using LaTeXStrings
using Plots
using Plots.PlotMeasures
using BenchmarkTools
#Single graph with individual bound on the gradient
function exp1(inputFile, outputfile; linesearch=false, ε=1e-2, v0=nothing, t0=0, bound=true, mode="A", startεd0=0.0)
file = inputFile
print("Readfile ")
@time A, C = readfile(file)
#disp(size(A))
A = A / 2
C = C / 4
global m = size(A, 1)
global n = size(A, 2)
D = spzeros(n)
sumai = 0
for i in 1:n
D[i] = 2 * C[i, i]
sumai = sumai + D[i]
end
disp(sumai)
sumai = sqrt(sumai)
v = B(A, d=1 / m)
t = 5
if v0 !== nothing
v = v0
t = t0
end
if bound
upper = sumai
else
D = ones(n)
upper = 1e16
end
if mode == "A"
result1 = Solve(A_s, v, t0=t, D=D, lowerBound=0, upperBound=upper, plot=true, linesearch=linesearch, ε=ε, numSample=1, mode=mode, logfilename=outputfile, startεd0=startεd0)
elseif mode == "C"
result1 = Solve(C, v, t0=t, D=D, lowerBound=0, upperBound=upper, plot=true, linesearch=linesearch, ε=ε, numSample=1, mode=mode, logfilename=outputfile, startεd0=startεd0)
end
return (v=result1.v, t=result1.t, z=result1.z)
end
#=
opt = 12083.2
ε1 = 10^(-1.5)
inputfile = "C:/Users/pchib/Desktop/MASTER/MESDP/Gset/g1.txt"
#disp(@benchmark exp1(inputfile, nothing, opt, nothing, ε=ε1, linesearch=true, bound=true, color=:black, mode="A"))
u = @benchmark exp1(inputfile, nothing, opt, nothing, ε=ε1, linesearch=true, bound=true, color=:black, mode="C")
println(mean(u).memory)
println(mean(u).time)
=#
#=========================================================================================
=#
ε1 = 10^(-2)
file = ["1e4n3d.txt", "1e4n3d2.txt", "1e4n5d.txt", "1e4n5d2.txt", "1e4n10d.txt", "1e4n10d2.txt"]
for i = 1:length(file)
inputfile = "BigExample/" * file[i]
outputfile = "Result/exp5/" * chop(file[i], tail=4) * "log.txt"
println(inputfile)
println(outputfile)
print("Solve ")
@time exp1(inputfile, outputfile, ε=ε1, linesearch=true, bound=true, mode="C", startεd0=0.0)
end
#=========================================================================================
outputfile = "MATLABplot/G48log-1.txt"
exp1(inputfile, outputfile, ε=ε1, linesearch=true, bound=true, mode="C", startεd0=-1.0)
outputfile = "MATLABplot/G48log-2.txt"
exp1(inputfile, outputfile, ε=ε1, linesearch=true, bound=true, mode="C", startεd0=-2.0)
=#
#=
outputfile = "MATLABplot/G49log-3.txt"
exp1(inputfile, outputfile, ε=ε1, linesearch=true, bound=true, mode="C", startεd0=-3.0)
=#