Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Binary paint shop problem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
Binary paint shop problem
Commits
415324b0
Commit
415324b0
authored
2 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
algo/maxcut: Hacky na menší počet jader v juliových knihovnách
parent
6ed2051e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
algo/maxcut.cpp
+14
-3
14 additions, 3 deletions
algo/maxcut.cpp
with
14 additions
and
3 deletions
algo/maxcut.cpp
+
14
−
3
View file @
415324b0
...
@@ -42,7 +42,10 @@ void calc_maxcut_naive(Nd * nd, int nd_size)
...
@@ -42,7 +42,10 @@ void calc_maxcut_naive(Nd * nd, int nd_size)
void
calc_maxcut_gw
(
Nd
*
nd
,
int
nd_size
)
void
calc_maxcut_gw
(
Nd
*
nd
,
int
nd_size
)
{
{
auto
[
p_stdin
,
p_stdout
]
=
lib
::
dualpopen
(
"julia"
);
int
thread_num
=
4
;
char
cmd
[
1000
];
sprintf
(
cmd
,
"OMP_NUM_THREADS=%d julia -t %d"
,
thread_num
,
thread_num
);
auto
[
p_stdin
,
p_stdout
]
=
lib
::
dualpopen
(
cmd
);
{
{
vector
<
vector
<
int
>>
matrix
(
nd_size
,
vector
<
int
>
(
nd_size
,
0
));
vector
<
vector
<
int
>>
matrix
(
nd_size
,
vector
<
int
>
(
nd_size
,
0
));
fo
(
i
,
nd_size
)
fo
(
i
,
nd_size
)
...
@@ -50,10 +53,18 @@ void calc_maxcut_gw(Nd * nd, int nd_size)
...
@@ -50,10 +53,18 @@ void calc_maxcut_gw(Nd * nd, int nd_size)
matrix
[
i
][
target
-
nd
]
+=
weight
;
matrix
[
i
][
target
-
nd
]
+=
weight
;
fprintf
(
p_stdin
,
fprintf
(
p_stdin
,
"include(
\"
MaxCut.jl/src/MaxCut.jl
\"
);\
"import LinearAlgebra;\
import LinearAlgebra;\
LinearAlgebra.BLAS.set_num_threads(%d);\
import Convex;\
Convex.MOI.NumberOfThreads() = %d;\
import SCS;\
SCS.MOI.NumberOfThreads() = %d;\
include(
\"
MaxCut.jl/src/MaxCut.jl
\"
);\
using Random;\
using Random;\
Random.seed!(3);\
Random.seed!(3);\
MaxCut.maxcut(["
);
MaxCut.maxcut(["
,
thread_num
,
thread_num
,
thread_num
);
fo
(
i
,
nd_size
)
fo
(
i
,
nd_size
)
{
{
fo
(
j
,
nd_size
)
fprintf
(
p_stdin
,
" %d"
,
matrix
[
i
][
j
]);
fo
(
j
,
nd_size
)
fprintf
(
p_stdin
,
" %d"
,
matrix
[
i
][
j
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment