Can i enable/disable features from the main.go?

I’m debugging my nextroute model, comparing various constraint combinations but it’s too tedious to manually disable features from my input file for each run, can I disable them from the main.go instead?

Yes! For example, consider a function called solver where you are instantiating a vehicle routing model. Given that options are read in from the runner, you can modify the options directly in your code to disable constraints. An example of this would be options.Model.Constraints.Disable.Precedence = true. Here is an example:

func solver(
	ctx context.Context,
	input schema.Input,
	options options,
) (runSchema.Output, error) {
	// Customize options in the code.
	options.Model.Objectives.TravelDuration = 0.5
	options.Model.Objectives.UnplannedPenalty = 0.3
	options.Model.Constraints.Disable.Capacity = true
	options.Model.Constraints.Disable.Attributes = true
	options.Model.Constraints.Disable.Precedence = true
	options.Solve.Duration = time.Duration(11) * time.Second
	options.Solve.Iterations = 51
	options.Format.Disable.Progression = true

	model, err := factory.NewModel(input, options.Model)
	if err != nil {
		return runSchema.Output{}, err
	}

	solver, err := nextroute.NewParallelSolver(model)
	if err != nil {
		return runSchema.Output{}, err
	}

	solutions, err := solver.Solve(ctx, options.Solve)
	if err != nil {
		return runSchema.Output{}, err
	}

	return nextroute.Format(ctx, options, solver, solutions.Last()), nil
}

The output should show which options were disabled:

  "options": {
    "format": {
      "disable": {
        "progression": true
      }
    },
    "model": {
      "constraints": {
        "disable": {
          "arrival_time_windows": false,
          "attributes": true,
          "capacity": true,
          "distance_limit": false,
          "groups": false,
          "maximum_duration": false,
          "maximum_stops": false,
          "maximum_wait_stop": false,
          "maximum_wait_vehicle": false,
          "precedence": true,
          "vehicle_end_time": false,
          "vehicle_start_time": false
        },
        "enable": {
          "cluster": false
        }
      },
      "objectives": {
        "cluster": 0,
        "early_arrival_penalty": 1,
        "late_arrival_penalty": 1,
        "travel_duration": 0.5,
        "unplanned_penalty": 0.3,
        "vehicle_activation_penalty": 1
      },
      "properties": {
        "disable": {
          "durations": false,
          "initial_solution": false
        }
      }
    },
    "solve": {
      "duration": 11000000000,
      "iterations": 51,
      "parallel_runs": 1,
      "run_deterministically": true,
      "start_solutions": 1
    }
  }