# How to start a new Julia session from script

**URL:** <https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 30, 2021, 5:39pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848 "2021-06-30T17:39:17Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![Micah\_Mungal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/micah_mungal/32/14660_2.png) [@Micah\_Mungal](https://discourse.julialang.org/u/Micah_Mungal)\
**Post date:** [July 1, 2021, 8:45pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848/21 "2021-07-01T20:45:08Z")

</div>

Can you provide me with some documentation for doing this?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [July 1, 2021, 8:50pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848/22 "2021-07-01T20:50:44Z")

</div>

This seems correct, and a definite improvement from before.

Side note, `CSV.read(file)` is deprecated. You can do `CSV.read(file, DataFrame)` to get the data frame directly.

---

<div class="post-metadata">

**Author:** ![Micah\_Mungal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/micah_mungal/32/14660_2.png) [@Micah\_Mungal](https://discourse.julialang.org/u/Micah_Mungal)\
**Post date:** [July 5, 2021, 7:15pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848/23 "2021-07-05T19:15:08Z")

</div>

Unfortunately, getting rid of the global variables did not solve my problem.

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [July 5, 2021, 9:18pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848/24 "2021-07-05T21:18:27Z")

</div>

> [@Micah\_Mungal](#):
>
> `temp_StartUpCost = StartUpCost`

Note that Julia does not copy on assignment - any modification to `temp_` will also modify the original. You need to explicitly `copy` arrays:

```julia
julia> cost1, cost2 = rand(1), rand(1)
([0.10489078104085436], [0.24938919112321623])

julia> tmp_cost1, tmp_cost2 = cost1, copy(cost2)
([0.10489078104085436], [0.24938919112321623])

julia> tmp_cost1[1] = tmp_cost2[1] = 0
0

julia> cost1, cost2
([0.0], [0.24938919112321623])

```

This may be what’s causing you to see irregular Guirobi results when doing multiple runs at once: you’re currently modifying your `StartUpCost` parameter on each iteration.

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [July 5, 2021, 9:53pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848/25 "2021-07-05T21:53:32Z")

</div>

Some other notes:

- You’ll spare yourself a lot of indexing pain if you use 2D arrays instead of 1D (e.g. `test2_limit = zeros(2, num_gp)` instead of `zeros(1, (2*num_gp))`. If you need to treat a 2D array as 1D for some reason, you can easily reshape it using `vec(arr)`, which refers to the same underlying chunk of memory.
- You don’t need to set global variables as constants _if_ you’re passing them as function arguments. “Dynamic multiple dispatch” means that Julia figures out which methods to call based on a function’s argument types at run-time, but as long as those function arguments have a concrete type, there’s no need to set them as constant.
- `Array{Float64}` (as used in your `StartUpCost` initialization) is not a concrete type, since you didn’t specify the dimension of the array:

```julia
julia> isconcretetype(Array{Float64})
false

julia> isconcretetype(Array{Float64, 1})
true

```

- Unlike Matlab, Julia has built-in 1D arrays, and “row vectors” like `reshape(..., (1, nUnits))` are not considered idiomatic in cases where a 1D array would do the same thing.
- Multiple function definitions can (and typically do) coexist in the same file - there’s no need to split things across multiple files unless it helps you with code organization.

---

<div class="post-metadata">

**Author:** ![Micah\_Mungal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/micah_mungal/32/14660_2.png) [@Micah\_Mungal](https://discourse.julialang.org/u/Micah_Mungal)\
**Post date:** [July 7, 2021, 12:55pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848/27 "2021-07-07T12:55:21Z")

</div>

Thanks everyone, the problem has been resolved.

---

<div class="post-metadata">

**Author:** ![Micah\_Mungal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/micah_mungal/32/14660_2.png) [@Micah\_Mungal](https://discourse.julialang.org/u/Micah_Mungal)\
**Post date:** [July 7, 2021, 12:55pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848/28 "2021-07-07T12:55:36Z")

</div>

Thank you, the problem has been resolved.

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [July 7, 2021, 11:46pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848/29 "2021-07-07T23:46:12Z")

</div>

It would be nice if you could change the title so that another person with a similar issue can find this. In the end, the post was not solved by starting new sessions from a script.

[Previous page](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848.md?page=1)
