[CP-SAT] ScalProd -> WeightedSum
This commit is contained in:
@@ -1922,7 +1922,7 @@ def bus_driver_scheduling(minimize_drivers, max_num_drivers):
|
||||
model.Add(
|
||||
cp_model.LinearExpr.Sum(working_times) == total_driving_time +
|
||||
num_drivers * (setup_time + cleanup_time) +
|
||||
cp_model.LinearExpr.ScalProd(delay_literals, delay_weights))
|
||||
cp_model.LinearExpr.WeightedSum(delay_literals, delay_weights))
|
||||
|
||||
if minimize_drivers:
|
||||
# Minimize the number of working drivers
|
||||
@@ -1931,7 +1931,7 @@ def bus_driver_scheduling(minimize_drivers, max_num_drivers):
|
||||
# Minimize the sum of delays between tasks, which in turns minimize the
|
||||
# sum of working times as the total driving time is fixed
|
||||
model.Minimize(
|
||||
cp_model.LinearExpr.ScalProd(delay_literals, delay_weights))
|
||||
cp_model.LinearExpr.WeightedSum(delay_literals, delay_weights))
|
||||
|
||||
if not minimize_drivers and FLAGS.output_proto:
|
||||
print('Writing proto to %s' % FLAGS.output_proto)
|
||||
|
||||
@@ -127,7 +127,7 @@ def solve_with_duplicate_items(data, max_height, max_width):
|
||||
model.AddNoOverlap2D(x_intervals, y_intervals)
|
||||
|
||||
## Objective.
|
||||
model.Maximize(cp_model.LinearExpr.ScalProd(is_used, item_values))
|
||||
model.Maximize(cp_model.LinearExpr.WeightedSum(is_used, item_values))
|
||||
|
||||
# Output proto to file.
|
||||
if FLAGS.output_proto:
|
||||
@@ -217,7 +217,7 @@ def solve_with_duplicate_optional_items(data, max_height, max_width):
|
||||
model.AddNoOverlap2D(x_intervals, y_intervals)
|
||||
|
||||
## Objective.
|
||||
model.Maximize(cp_model.LinearExpr.ScalProd(is_used, item_values))
|
||||
model.Maximize(cp_model.LinearExpr.WeightedSum(is_used, item_values))
|
||||
|
||||
# Output proto to file.
|
||||
if FLAGS.output_proto:
|
||||
@@ -330,7 +330,7 @@ def solve_with_rotations(data, max_height, max_width):
|
||||
model.AddNoOverlap2D(x_intervals, y_intervals)
|
||||
|
||||
# Objective.
|
||||
model.Maximize(cp_model.LinearExpr.ScalProd(is_used, item_values))
|
||||
model.Maximize(cp_model.LinearExpr.WeightedSum(is_used, item_values))
|
||||
|
||||
# Output proto to file.
|
||||
if FLAGS.output_proto:
|
||||
|
||||
@@ -288,7 +288,7 @@ def solve_shift_scheduling(params, output_proto):
|
||||
# Exactly one shift per day.
|
||||
for e in range(num_employees):
|
||||
for d in range(num_days):
|
||||
model.Add(sum(work[e, s, d] for s in range(num_shifts)) == 1)
|
||||
model.AddExactlyOne([work[e, s, d] for s in range(num_shifts)])
|
||||
|
||||
# Fixed assignments.
|
||||
for e, s, d in fixed_assignments:
|
||||
|
||||
Reference in New Issue
Block a user