Skip to content

Commit

Permalink
test issue is solwed, empty list is given as defoult to taken_courses…
Browse files Browse the repository at this point in the history
…; opt_configuration temp files are removed
  • Loading branch information
orhanabar committed Jul 30, 2019
1 parent 2848407 commit 46eaeb3
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 85 deletions.
4 changes: 0 additions & 4 deletions examples/Notebooks/Opt_Configurations-2_temp.csv

This file was deleted.

23 changes: 0 additions & 23 deletions examples/Notebooks/Opt_Configurations-3_temp.csv

This file was deleted.

23 changes: 0 additions & 23 deletions examples/Notebooks/Opt_Configurations-4_temp.csv

This file was deleted.

2 changes: 1 addition & 1 deletion examples/Notebooks/Opt_Configurations.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Term Count,6,
Term Count,8,
Min Credit,1,
Max Credit,19,
Objective Order,Balance;Toxicity;Prereq,
Expand Down
23 changes: 0 additions & 23 deletions examples/Notebooks/opt_Configurations_temp.csv

This file was deleted.

27 changes: 19 additions & 8 deletions src/DataHandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function read_csv(file_path::AbstractString)
course_count += 1
read_line = csv_line_reader(readline(csv_file), ',')
end
df_courses = CSV.File(file_path, header=courses_header, limit=course_count-1) |> DataFrame
df_courses = CSV.File(file_path, header=courses_header, limit=course_count-1, delim=',') |> DataFrame
if nrow(df_courses) != nrow(unique(df_courses, Symbol("Course ID")))
println("All courses must have a unique Course ID")
return false
Expand All @@ -120,7 +120,7 @@ function read_csv(file_path::AbstractString)
end
end
if additional_course_count > 1
df_additional_courses = CSV.File(file_path, header=additional_course_start, limit=additional_course_count-1) |> DataFrame
df_additional_courses = CSV.File(file_path, header=additional_course_start, limit=additional_course_count-1, delim=',') |> DataFrame
df_all_courses = vcat(df_courses,df_additional_courses)
else
df_all_courses = df_courses
Expand All @@ -135,7 +135,7 @@ function read_csv(file_path::AbstractString)
read_line = csv_line_reader(readline(csv_file), ',')
end
if learning_outcomes_count > 1
df_course_learning_outcomes = CSV.File(file_path, header=learning_outcomes_start, limit=learning_outcomes_count-1) |> DataFrame
df_course_learning_outcomes = CSV.File(file_path, header=learning_outcomes_start, limit=learning_outcomes_count-1, delim=',') |> DataFrame
end
end
course_learning_outcomes = Dict{Int, Array{LearningOutcome}}()
Expand All @@ -155,7 +155,7 @@ function read_csv(file_path::AbstractString)
read_line = csv_line_reader(readline(csv_file), ',')
end
if learning_outcomes_count > 1
df_curric_learning_outcomes = CSV.File(file_path, header=curric_learning_outcomes_start, limit=curric_learning_outcomes_count-1) |> DataFrame
df_curric_learning_outcomes = CSV.File(file_path, header=curric_learning_outcomes_start, limit=curric_learning_outcomes_count-1, delim=',') |> DataFrame
end
end

Expand Down Expand Up @@ -588,7 +588,7 @@ function read_Opt_Config(file_path)
course_count += 1
read_line = csv_line_reader(readline(csv_file), ',')
end
df_fixedCourses = CSV.File(file_path, header=header, limit=course_count) |> DataFrame
df_fixedCourses = CSV.File(file_path, header=header, limit=course_count, delim=',') |> DataFrame
header += course_count+1
for row in DataFrames.eachrow(df_fixedCourses)
fixedCourses[row[Symbol("Course ID")]] = row[Symbol("Term")]
Expand All @@ -611,7 +611,7 @@ function read_Opt_Config(file_path)
consecutivePairCount += 1
read_line = csv_line_reader(readline(csv_file), ',')
end
df_consecutivePair = CSV.File(file_path, header=header, limit=consecutivePairCount) |> DataFrame
df_consecutivePair = CSV.File(file_path, header=header, limit=consecutivePairCount, delim=',') |> DataFrame
header += consecutivePairCount+1
for row in DataFrames.eachrow(df_consecutivePair)
consequtiveCourses[row[Symbol("Prior Course ID")]] = row[Symbol("Next Course ID")]
Expand All @@ -634,7 +634,7 @@ function read_Opt_Config(file_path)
termRangeCount += 1
read_line = csv_line_reader(readline(csv_file), ',')
end
df_termRange = CSV.File(file_path, header=header, limit=termRangeCount) |> DataFrame
df_termRange = CSV.File(file_path, header=header, limit=termRangeCount, delim=',') |> DataFrame
header += termRangeCount+1
for row in DataFrames.eachrow(df_termRange)
termRange[row[Symbol("Course Id")]] = (row[Symbol("Min Term")], row[Symbol("Max Term")])
Expand All @@ -661,12 +661,23 @@ function read_Opt_Config(file_path)
diffMaxCount += 1
read_line = csv_line_reader(readline(csv_file), ',')
end
df_diffMax = CSV.File(file_path, header=header, limit=diffMaxCount) |> DataFrame
df_diffMax = CSV.File(file_path, header=header, limit=diffMaxCount, delim=',') |> DataFrame
header += diffMaxCount+1
for row in DataFrames.eachrow(df_diffMax)
diffMax[row[Symbol("Term")]] = row[Symbol("Max Credit")]
end
# If there is a term without max credit, assign default max credit hours
for term_id in 1:termCount
if !(term_id in keys(diffMax))
diffMax[term_id] = max_credits_per_term
end
end
end
end
# Current file is the temp file created by remove_empty_lines(), remove the file.
if file_path[end-8:end] == "_temp.csv"
GC.gc()
rm(file_path)
end
return consequtiveCourses, fixedCourses, termRange, termCount, min_credits_per_term, max_credits_per_term, obj_order, diffMax
end
5 changes: 4 additions & 1 deletion src/Optimization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ function optimize_plan(config_file, curric_degree_file, toxic_score_file= "")
c_count = length(curric.courses)
# Create a map from course ID in curriculum to vertex ID of course in the curriculum graph.
vertex_map = Dict{Int,Int}(c.id => c.vertex_id[curric.id] for c in courses)
taken_course_ids = [c.id for c in input[2]]
taken_course_ids = []
if isa(input, Tuple)
taken_course_ids = [c.id for c in input[2]]
end
credit = [c.credit_hours for c in curric.courses]
# The mask vector is used to determine the term that a course is in, via dot product with a row of the x matrix
mask = [i for i in 1:term_count]
Expand Down
4 changes: 2 additions & 2 deletions test/DataHandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ curric1 = Curriculum("Underwater Basket Weaving", [A,B,C,D,E,F], institution="AC
# write curriculum to secondary storage
@test write_csv(curric1, "./UBW-curric.csv") == true
# read from same location
# curric2 = read_csv("./UBW-curric.csv")
# @test string(curric1) == string(curric2) # read/write invariance test
curric2 = read_csv("./UBW-curric.csv")
@test string(curric1) == string(curric2) # read/write invariance test
rm("./UBW-curric.csv")

terms = Array{Term}(undef, 3)
Expand Down
13 changes: 13 additions & 0 deletions test/UBW_curric.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Curriculum,Underwater Basket Weaving,,,,,,,,,
Institution,ACME State University,,,,,,,,,
Degree Type,BS,,,,,,,,,
System Type,semester,,,,,,,,,
CIP,445786,,,,,,,,,
Courses,,,,,,,,,,
"Course ID","Course Name",Prefix,Number,Prerequisites,Corequisites,Strict-Corequisites,Credit Hours,Institution,Canonical Name
300052638,"Basket Materials & Decoration","BW","214","4037212392",,,3,"ACME State University","Basket Materials",
1050322132,"Introduction to Baskets","BW","101",,,,3,"ACME State University","Baskets I",
1888571219,"Swimming","PE","115",,,,3,"ACME State University","Physical Education",
2012165139,"Advanced Basketry","CS","300","3989163861",,,3,"ACME State University","Baskets II",
3989163861,"Basic Basket Forms","BW","111","1050322132;1888571219","4037212392",,3,"ACME State University","Baskets I",
4037212392,"Basic Basket Forms Lab","BW","111L",,,,1,"ACME State University","Baskets I Laboratory",

0 comments on commit 46eaeb3

Please sign in to comment.