# Question about environment

**URL:** <https://discourse.julialang.org/t/question-about-environment/116129>\
**Category:** General Usage\
**Created:** [June 24, 2024, 3:19am UTC](https://discourse.julialang.org/t/question-about-environment/116129 "2024-06-24T03:19:55Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 24, 2024, 3:19am UTC](https://discourse.julialang.org/t/question-about-environment/116129/1 "2024-06-24T03:19:55Z")

</div>

Recently，I am subject to a problem like this:  
I have a package “MyPackage” depending on the “CBLS.jl” which in turn depends on JuMP@v0.21.5, but I also need “MyPackage” to depend on JuMP@v1.22.2. When I upgraded all the package in the present activated environment, the “CBLS” does not work at all, vice verse. I do not want to reload “CBLS” to adapt to the latest version of JuMP@v1.22.2, since it is tedious to revise the codes. How can you deal with such a situation?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [June 24, 2024, 3:23am UTC](https://discourse.julialang.org/t/question-about-environment/116129/2 "2024-06-24T03:23:59Z")

</div>

You cannot have two versions of the same package.

In this case, you cannot use JuMP v1 and CBLS at the same time.

But it also looks like v0.2 of CBLS supports JuMP v1?

> <https://github.com/JuliaConstraints/CBLS.jl/blob/439624367c53fc74f755cf9b689595411496f63b/Project.toml#L22>

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [June 24, 2024, 3:25am UTC](https://discourse.julialang.org/t/question-about-environment/116129/3 "2024-06-24T03:25:14Z")

</div>

Ah, @Azzaare hasn’t made a release yet.

Do

```julia
] add CBLS#main

```

to install the latest greatest version.

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 24, 2024, 3:29am UTC](https://discourse.julialang.org/t/question-about-environment/116129/4 "2024-06-24T03:29:55Z")

</div>

the latest CBLS@0.2.0 seems not to work with the latest MathOptInterface. The package even can not pass the basic tests.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [June 24, 2024, 3:42am UTC](https://discourse.julialang.org/t/question-about-environment/116129/5 "2024-06-24T03:42:26Z")

</div>

> The package even can not pass the basic tests.

Then I assume @Azzaare hasn’t finished updating it, which is why there isn’t a new release 😄

---

<div class="post-metadata">

**Author:** ![Azzaare](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/azzaare/32/21008_2.png) [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Post date:** [June 24, 2024, 4:02am UTC](https://discourse.julialang.org/t/question-about-environment/116129/6 "2024-06-24T04:02:24Z")

</div>

I have been working on it the last couple of days (also on the documentation).

It should be finished soon (I will update the post here once it is done).

That being said, we’re working hard on all the CBLS ecosystem at the moment, so we will have a lot of changes in the coming months.

---

<div class="post-metadata">

**Author:** ![Azzaare](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/azzaare/32/21008_2.png) [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Post date:** [June 24, 2024, 4:13am UTC](https://discourse.julialang.org/t/question-about-environment/116129/7 "2024-06-24T04:13:34Z")

</div>

@lionisxn

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/b/0bfa4f427f4628bc3172c811a952be203337e601.png)

As I released CBLSv0.2.0 yesterday, it might just be a question of timing with the different servers hosting the Julia General registry, but I have no issue with the latest versions of JuMP, MathOptInterface and CBLS.

I was not planning to tag it in the repo before I fix some doc issues, but I will try to make it available today or tomorrow. Will update here again!

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 24, 2024, 5:14am UTC](https://discourse.julialang.org/t/question-about-environment/116129/8 "2024-06-24T05:14:33Z")

</div>

Looking forward to the new features!

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 24, 2024, 5:27am UTC](https://discourse.julialang.org/t/question-about-environment/116129/9 "2024-06-24T05:27:17Z")

</div>

Hi, @Azzaare, could you please help me test the following code in your environment?

> Pkg.generate(“D:/testCBLS”)\>  
> Pkg.activate(“D:/testCBLS”)\>  
> [Pkg.add(x) for x in [“CBLS”, “LocalSearchSolvers”, “JuMP”]]
> 
> using CBLS, LocalSearchSolvers, JuMP
> 
> n = 3\>  
> N = n^2\>  
> m = JuMP.Model(CBLS.Optimizer)\>  
> @variable(m, X[1:N, 1:N], DiscreteSet(1:N))\>  
> for i in 1:N\>  
> @constraint(m, X[i,:] in AllDifferent()) # All variables on the same row must be different\>  
> @constraint(m, X[:,i] in AllDifferent()) # All variables on the same column must be different
> 
> end
> 
> for i in 0:(n-1), j in 0:(n-1)\>  
> @constraint(m, vec(X[(i_n+1):(n_(i+1)), (j_n+1):(n_(j+1))]) in AllDifferent()) # All variables on the same block must be different\>  
> end
> 
> @objective(m, Min, ScalarFunction(x → x[1,1]))

My machine (windows 11) throws that

 ![微信截图_20240624132638](https://global.discourse-cdn.com/julialang/original/3X/3/5/352839ba476ad1249e6bac5e6a83fe06460b2c97.jpeg)

---

<div class="post-metadata">

**Author:** ![Azzaare](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/azzaare/32/21008_2.png) [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Post date:** [June 24, 2024, 6:28am UTC](https://discourse.julialang.org/t/question-about-environment/116129/10 "2024-06-24T06:28:02Z")

</div>

Interesting. I went through your example and it seems to be a printing issue. I did not see it in the basic CBLS tests as I don’t print the model once the objective is added.

It seems I still have many things to update for JuMP v1 !

Thank you, I will also try to fix this asap.

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 24, 2024, 7:33am UTC](https://discourse.julialang.org/t/question-about-environment/116129/11 "2024-06-24T07:33:57Z")

</div>

Appreciate your support! Looking forward to your great news!

---

<div class="post-metadata">

**Author:** ![Azzaare](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/azzaare/32/21008_2.png) [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Post date:** [June 27, 2024, 8:51am UTC](https://discourse.julialang.org/t/question-about-environment/116129/12 "2024-06-27T08:51:10Z")

</div>

Hey @lionisxn,

I’ve just released CBLS v0.2.1 that addresses your issue. It took me some time as I made sure to update the tests to the latest version of MathOptInterface.

Although it is still a draft, we are tackling the documentation for JuliaConstraints this summer. You can access it at [https://juliaconstraints.github.io/](https://juliaconstraints.github.io/)

I understand if you prefer to wait for a while before using CBLS as we are still building it, but in the event you play around with and find some issues, or if you have some features that you want us to make a priority, please ask.

(For instance, one can use continuous variable in our CBLS framework, but we haven’t implemented yet an efficient LocalSearch for these domains. We will do that during July. If you have some use case in mind, we can target related features, as it is mainlya questino of sorting our priorities)

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 27, 2024, 9:00am UTC](https://discourse.julialang.org/t/question-about-environment/116129/13 "2024-06-27T09:00:45Z")

</div>

Wonderful! I’ll try the new release later, and report you issues, if any.

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 30, 2024, 4:15am UTC](https://discourse.julialang.org/t/question-about-environment/116129/14 "2024-06-30T04:15:27Z")

</div>

Hi, Azzaare, is there a way to turn off the distributed computation mode of “LocalSearchSolvers”?

---

<div class="post-metadata">

**Author:** ![Azzaare](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/azzaare/32/21008_2.png) [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Post date:** [June 30, 2024, 9:25am UTC](https://discourse.julialang.org/t/question-about-environment/116129/15 "2024-06-30T09:25:18Z")

</div>

Currently, you can control the maximum number of threads `t` (the value is currently shared, so you can have `t` threads per process).

If I recall the syntax should be:  
`set_attribute(model, MOI.NumberOfThreads(), t)`

By default, CBLS will use all processes (and their associated threads) available.

Having a process-thread dictionary `PT = Dict{Int, Int}()` defined as a MathOptInterface’s solver attribute is definitely possible. I can probably do it tomorrow. (I need to if I want a finer control on my own local cluster anyway)

Let me know if you have specific needs regarding threads/processes. CBLS interface is based on the LocalSearchSolvers framework in Julia, so the parallel computing capabilities (and limitations) are similar.

As a side note, GPU CBLS is in the queue for this summer.

---

<div class="post-metadata">

**Author:** ![Azzaare](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/azzaare/32/21008_2.png) [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Post date:** [June 30, 2024, 3:32pm UTC](https://discourse.julialang.org/t/question-about-environment/116129/16 "2024-06-30T15:32:49Z")

</div>

@odow would it make sense to add a solver attribute for MOI/JuMP that provides a collection of pairs `process_id => threads`. So maybe something along the lines of `MOI.ProcessThreads` ?  
Local Search Solvers can leverage that easily, but I am not sure for classical optimization.

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [July 1, 2024, 2:01am UTC](https://discourse.julialang.org/t/question-about-environment/116129/17 "2024-07-01T02:01:22Z")

</div>

I think such a solution might be much better since many packages do not support distributed computation very well, the keywords like “remotecall” “@threads” are expected to be able to be bypassed according to users’ preference

---

<div class="post-metadata">

**Author:** ![Azzaare](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/azzaare/32/21008_2.png) [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Post date:** [July 12, 2024, 8:31am UTC](https://discourse.julialang.org/t/question-about-environment/116129/18 "2024-07-12T08:31:12Z")

</div>

Hi @lionisxn

Sorry to get back to you so late. I stumble upon an issue with Distributed and I was not sure on how to handle it.

I finally settled on making your request working first. With CBLS v0.2.2 (registration ongoing, so it should be less than half an hour), you can do:

```julia
# To set the number of threads on the first process
set_optimizer_attribute(model, "threads", 2)
get_optimizer_attribute(model, "threads") == 2 # should return true

# To set a threads per process mapping, 2 threads on process 1, etc.
T = Dict(1 => 2, 2 => 3, 3 => 1)
set_optimizer_attribute(model, "process_threads_map", T)
get_optimizer_attribute(model, "process_threads_map") == T # should return true

```

I plan to release a finer control later on during summer, but that should let you handle your current issue.

If you find some odd behavior regarding the resources used, please let me know (my tests were not extensive at all)

Next update should be about logs (files and console).
