Optimization - hill climbing - designing functions (travelling salesman problem with truck load)

I would really encourage you to review the following guide, FAQ: Tips for writing R-related questions.
For example, the guide emphasizes asking coding questions with formatted code-chunks and a reprex.

You may have noticed folks here requesting minimal reprexes, that's because asking questions this way saves answerers a lot of time.

Reproducible Examples:

  • help make your question clear and replicable
  • increases the probability folks will reach out and try to help,
  • reduces the number of back-and-forths required to understand the question,
  • and makes your question and suggested solutions more useful to folks in the future researching similar problems.

But also please bear in mind the forum homework policy.

It seems that you recently asked a question that originated from a class or workshop, and I wanted to make sure you were seeking help here in a way that maximizes the chances of getting good help (without violating our homework policies).

Our homework guide is here: FAQ: Homework Policy

How should one ask a homework question?

  1. Never copy-paste instructions from an assignment (even for online courses).
  2. Explicitly mention the course you are taking and use the #homework tag.
  3. Ask your question as a reproducible example (reprex), preferably prepared for posting using the reprex package.

What's the best way to ask a specific homework-related question?

We made a short guide for helping folks pose their R-coding questions here.