allwpilib icon indicating copy to clipboard operation
allwpilib copied to clipboard

Simulated Annealing

Open Ashray-g opened this issue 2 years ago • 5 comments

Ashray-g avatar Jun 12 '22 12:06 Ashray-g

C++ port still needed

Ashray-g avatar Jun 12 '22 12:06 Ashray-g

/wpiformat

calcmogul avatar Jun 12 '22 20:06 calcmogul

Ideally, the user should be able to solve multiple problems with different initial conditions but the same solver settings. Here's the API our solver functions have had in the optimization branch:

  /**
  Find the optimal solution using a sequential quadratic programming solver.

  A sequential quadratic programming (SQP) problem has the form:

  @verbatim
       min_x f(x)
  subject to b(x) ≥ 0
             c(x) = 0
  @endverbatim

  where f(x) is the cost function, b(x) are the inequality constraints, and c(x)
  are the equality constraints.

  @param x The initial guess.
  */
  Eigen::VectorXd SQP(const Eigen::Ref<const Eigen::VectorXd>& x);

If each solver had configuration, we'd make SQP a class with configuration passed to the constructor and a solve() method that takes an initial guess. I suggest doing that for SimulatedAnnealing.

After doing that, the class doesn't need to have a private ctor or be final anymore.

calcmogul avatar Jun 14 '22 18:06 calcmogul

At the WPILib meeting, it was pointed out that we should probably implement a traveling salesman problem solver, or solvers for other problems that are suited for simulated annealing, so we can test-drive the API to make sure we got it right.

FWIW we generally do include use cases, like how the state-space PR came with example projects for drivetrains, elevators, flywheels, etc. Simulated annealing itself may be too low-level to have an example, but we should have an example that uses it somewhere in the abstraction layers.

calcmogul avatar Jun 17 '22 02:06 calcmogul

TODO: C++

Ashray-g avatar Jun 17 '22 16:06 Ashray-g

Abandoned by author.

calcmogul avatar Nov 23 '23 06:11 calcmogul