osqp

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 3 Imported by: 0

README

osqp.go

Status GitHub Issues GitHub Pull Requests License


Few lines describing your project.

📝 Table of Contents

🧐 Problem Statement

Currently, there is no Go interface for Quadratic Programming implementation on C. Users who want to use Quadratic Programming in Go have to write their own interface or use an existing one that may not be optimized for their specific use case. Without a Go interface for OSQP implementation on C, users who want to use Quadratic Programming in Go will have to spend time and resources writing their own interface or using an existing one that may not be optimized for their specific use case. This can lead to suboptimal performance and increased development time.

  • IDEAL: The goal of this project is to create a Go interface for OSQP implementation on C. The interface should be easy to use and should allow users to solve optimization problems using OSQP in Go.
  • REALITY: Currently, there is no Go interface for OSQP implementation on C. Users who want to use OSQP in Go have to write their own interface or use an existing one that may not be optimized for their specific use case.
  • CONSEQUENCES: Without a Go interface for OSQP implementation on C, users who want to use OSQP in Go will have to spend time and resources writing their own interface or using an existing one that may not be optimized for their specific use case. This can lead to suboptimal performance and increased development time.

💡 Idea / Solution

To achieve this goal, we will create a Go package that provides a simple and intuitive interface for OSQP implementation on C. The package will be designed to be easy to use and will provide users with all the functionality they need to solve optimization problems using OSQP in Go.

⛓️ Dependencies / Limitations

  • OSQP implementation on C

🚀 Future Scope

Write about what you could not develop during the course of the project; and about what your project can achieve in the future.

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine.

Prerequisites

  • OSQP Library
    You can find detailed instructions on using build a osqp library and many tips in its documentation own here.

Installing

To get started you need to have binaries build of OSQP in C or you can copy from libs directory in the example.

To install the library you can run the command below.

go get -u github.com/jerensl/osqp.go

🎈 Usage

See example/ for a variety of examples.

Simple:

package main
import (
	"fmt"
	"github.com/jerensl/osqp.go"
)

func main() {
	newOSQP := osqp.NewOSQP()
	p_mat, err := osqp.NewCSCMatrix([][]float64{{4, 1}, {0, 2}})
	if err != nil {
		fmt.Println(err)
		return
	}
	a_mat, err := osqp.NewCSCMatrix([][]float64{{1, 1}, {1, 0}, {0, 1}})
	if err != nil {
		fmt.Println(err)
		return
	}
	q := []float64{1.0, 1.0}
	l := []float64{1.0, 0.0, 0.0}
	u := []float64{1.0, 0.7, 0.7}
	newOSQP.Setup(p_mat, q, a_mat, l, u)
	newOSQP.Solve()
	fmt.Println(newOSQP.Solution())
	newOSQP.CleanUp()
}

⛏️ Built With

  • OSQP - OSQP Library in C

✍️ Authors

See also the list of contributors who participated in this project.

🎉 Acknowledgments

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockDiag

func BlockDiag(blocks []*mat.Dense) *mat.Dense

func DenseEye

func DenseEye(size int, val float64) *mat.Dense

func DenseEyeK

func DenseEyeK(size int, val float64, k int) *mat.Dense

func ToNegative

func ToNegative(matDense mat.Matrix) mat.Matrix

func ToNegativeDense

func ToNegativeDense(vecDense mat.Dense) *mat.Dense

func ToNegativeVecDense

func ToNegativeVecDense(vecDense mat.VecDense) *mat.Dense

func VStack

func VStack(matrix []mat.Matrix) *mat.Dense

func VecZeros

func VecZeros(num int) mat.Matrix

Types

type Data

type Data struct {
	M     int64
	N     int64
	P_mat SparseMatrix
	Q     []float64
	A_mat SparseMatrix
	L     []float64
	U     []float64
}

type OSQPConfig

type OSQPConfig struct {
	// contains filtered or unexported fields
}

func NewOSQP

func NewOSQP() *OSQPConfig

func (OSQPConfig) CleanUp

func (o OSQPConfig) CleanUp()

func (OSQPConfig) Setup

func (o OSQPConfig) Setup(p SparseMatrix, q []float64, a SparseMatrix, l []float64, u []float64)

func (OSQPConfig) Solution

func (o OSQPConfig) Solution() (float32, float32)

func (OSQPConfig) Solve

func (o OSQPConfig) Solve()

func (OSQPConfig) UpdateAMat

func (o OSQPConfig) UpdateAMat(aNew []float64)

func (OSQPConfig) UpdateBounds

func (o OSQPConfig) UpdateBounds(lNew, uNew []float64)

func (OSQPConfig) UpdateLinCost

func (o OSQPConfig) UpdateLinCost(qNew []float64)

func (OSQPConfig) UpdatePMat

func (o OSQPConfig) UpdatePMat(pNew []float64)

type SparseMatrix

type SparseMatrix struct {
	// contains filtered or unexported fields
}

func NewCSCDenseMatrix

func NewCSCDenseMatrix(matrix mat.Matrix) (SparseMatrix, error)

func NewCSCMatrix

func NewCSCMatrix(matrix [][]float64) (SparseMatrix, error)

func NewDiagCSCMatrix

func NewDiagCSCMatrix(size int, value float64) (*SparseMatrix, error)

func (SparseMatrix) Data

func (s SparseMatrix) Data() []float64

func (SparseMatrix) Dimension

func (s SparseMatrix) Dimension() (int, int)

func (SparseMatrix) Ind

func (s SparseMatrix) Ind() []int

func (SparseMatrix) IndPtr

func (s SparseMatrix) IndPtr() []int

func (SparseMatrix) NNZ

func (s SparseMatrix) NNZ() int64

func (SparseMatrix) ToDense

func (s SparseMatrix) ToDense() *mat.Dense

func (SparseMatrix) Transpose

func (s SparseMatrix) Transpose(matrix [][]float64) [][]float64

Directories

Path Synopsis
example
mpc
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL