-2

ERROR

Calculating DraftKings baseball linueps. 3 lineups Formulation baseball_formulation Overlap = 6 Stack size = 5

LoadError: UndefVarError: tic not defined in expression starting at C:\Users\Carlos Soto\Daily-Fantasy-Baseball-Contests-in-DraftKings-master\optimize_multiple_lineups_baseball.jl:43

Stacktrace: [1] top-level scope @ C:\Users\Carlos Soto\Daily-Fantasy-Baseball-Contests-in-DraftKings-master\optimize_multiple_lineups_baseball.jl:43 [2] include(fname::String) @ Base.MainInclude .\client.jl:451 [3] top-level scope @ In[29]:1 [4] eval @ .\boot.jl:373 [inlined] [5] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String) @ Base .\loading.jl:1196

CODE

This code solves for multiple baseball lineups
using DataFrames
using CSV
include(“data_cleaning.jl”)
include(“baseball_formulations.jl”) #this code has all the different formualations 

################################################################################################## ############## ################################################################################################## ############## ################################################################################################## ##############

#INPUT PARAMS

num_lineups is the total number of lineups
num_lineups = 3;

num_overlap is the maximum overlap of players between the lineups
num_overlap = 6

#number of hitters in the stack (number of consecutive hitters in the hitting order)
stack_size = 5;

#FORMULATION: formulation is the type of formulation that you would like to use.
formulation = baseball_formulation

path_pitchers = “2016-08-12 pitchers.csv”
path_hitters = “2016-08-12 hitters.csv”;

path_to_output is a string that gives the path to the csv file that will give the outputted 
results
path_to_output= string(string(formulation), “stacksize”, stack_size,“overlap”, 
num_overlap,“lineups”, num_lineups,".csv");

path_to_output_proj is a string that gives the path to the csv file that will give the 
outputted results with projected lineup points
path_to_output_proj = string(“proj_baseball_”, string(formulation), “stacksize”, 
stack_size,“overlap”, num_overlap,“lineups”, num_lineups,".csv");

path_to_output_actual is a string that gives the path to the csv file that will give the 
outputted results with projected and actual lineup points
path_to_output_actual = string(“actual_baseball_”, string(formulation), “stacksize”, 
stack_size,“overlap”, num_overlap,“lineups”, num_lineups,".csv");

#########################################################################

Running the code
println("Calculating DraftKings baseball linueps.\n “, num_lineups, " lineups\n”,"Formulation 
",formulation,
"\nOverlap = “, num_overlap,”\nStack size = ", stack_size)

tic()
create_lineups(num_lineups, num_overlap, stack_size,formulation, path_pitchers,path_hitters, 
path_to_output);
telapsed = toq();

println("\nCalculated DraftKings baseball lineups.\n\tNumber of lineups = ", num_lineups, " 
\n\tStack size = ",stack_size,
“\n\tOverlap = “, num_overlap,”\n” )

println("Took ", telapsed/60.0, " minutes to calculate “, num_lineups, " lineups”)

println(“Saving data to file “,path_to_output,”\nDK Mafia 4 life”)

#save the projected and actual points for the lineups
lineup_points_proj(path_to_output,path_hitters,path_pitchers,path_to_output_proj);
#lineup_points_actual(path_to_output,path_hitters,path_pitchers,path_to_output_actual);

1 Answer 1

1

Two parts to this answer:

  1. On the immediate issue: tic and toc were removed in Julia 0.7 in favour of the @time macro. So instead of writing
tic()
my_function_call(arg1, arg2, ...)
toc()

you now write

@time my_function_call(arg1, arg2, ...)
  1. In general, when updating code from older Julia versions it is recommended to first verify that it is indeed working using the version it was developed in, and then move forward version-by-version. That way you'll get deprecation warnings when something in your code isn't working in future versions. To see for this example, here's Julia 0.6.4:
julia> tic()
0x00043e524144a02b
julia> toc()
elapsed time: 2.043187801 seconds
2.043187801

and here's Julia 0.7:

julia> tic()
┌ Warning: `tic()` is deprecated, use `@time`, `@elapsed`, or calls to `time_ns()` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
0x00043e951b0f07c4

julia> toc()
┌ Warning: `toc()` is deprecated, use `@time`, `@elapsed`, or calls to `time_ns()` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
elapsed time: 1.73983 seconds
1.73983

Now you might think "oh wow that's annoying given I want to get to update to version 1.8" but the good news is that Julia follows SemVer, and everything after 1.0 is a minor version update (rather than an major one), which according to SemVer "add[s] functionality in a backwards compatible manner".

0.7 was a transitional release which basically prepared users for the breaking 1.0 release - you can think of it as "1.0 with deprecation warnings". It's therefore really helpful to get your code into a usable state for post-1.0 Julia versions.

That's not to say of course that you should necessarily stop there if you intend to continue using your code. Julia is developing fast and has made huge progress between 1.0 and 1.8, and in some instances you'll want to change your code to take advantage of new features - but that's much easier to do from a working base, so fixing deprecation warnings that you see on older versions is step one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.