About the parallel solving by multiple Thread?

19 views
Skip to first unread message

jh chen

unread,
Sep 30, 2021, 5:02:49 AM9/30/21
to OptaPlanner development
Hi, ,guys! Current I try to solve problems like the following:

1. get a dateset,for example, 4000 individuals
2. split the dataset into 4 pieces, d1,d2 ,d3,d4
3.initalize solving contexts: c1,c2,c3,c4
4. initialize a thread pool "mypool" with 2 core threads, new a semaphore "semaphore"with 2 permits.
5. a for loop to start each thread, 

for i in contexts.sized():
   mythread->run t{
semaphore.acquire();
new solving(ci,seamphore);//in here, i try use the same solver, and different solver.
                                                //new a completely different sover for each thread is a favorable way
}

solving(ci,semaphore){
.........
this.solvemanger(ci)
semaphore.release()
}


----------------------------------------------------------------------------------------------------------------------------------------------
From my description, you can know that I want to solve the problem by multi-thread, but something wrong happened.




when the semaphore=1. core thread=1: c1 finished, c2 initialized, but didn't continue. i.e., c2can get an initial score, and then nothing happens, everything stops. it seems like all done.

when the semaphore=2. core thread=2: c1,c2 finished, c3,c4 initialized, but didn't continue. i.e., c3, c4 can get an initial score, and then nothing happens, everything stops. it seems like all done.

after the above situation appears, if you send a request, it will run into a new same procedure like the above. is anything wrong about my idea?
-------------------------------------------------------------------------------------------------------------------------------------------
I found in the manual of optaplanner that “Multitenancy: solve different datasets in parallel: The SolverManager will make it even easier to set this up, in a future version.”

I would like to ask you sirs, on this version, if I want to solve different data sets in parallel, how to set it up.

Or, could such an idea be implemented in the current version?

演示文稿1.jpg
Reply all
Reply to author
Forward
0 new messages