run

package
v0.20.7 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 6 Imported by: 18

README

Run

Package run provides tools for running solvers. When run.Run is called by your application, the runner configured by the environment variable NEXTMV_RUNNER will be used. Valid values are cli (default) and http.

See godocs for package docs.

Documentation

Overview

Package run provides tools for running solvers. When `run.Run` is called by your application, the runner configured by the environment variable `NEXTMV_RUNNER` will be used. Valid values are `cli` (default) and `http`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode added in v0.20.4

func Decode(f func() decode.Decoder) func(Runner)

Decode sets the decoder of a runner using f.

func Encode added in v0.20.4

func Encode(f func() encode.Encoder) func(Runner)

Encode sets the encoder of a runner using f.

func Run

func Run[T any](
	handler func(T, store.Options) (store.Solver, error),
	options ...Option,
)

Run a solver via a handler.

func main() {
	handler := func(v int, opt store.Options) (store.Solver, error) {
		s := store.New()
		x := store.NewVar(s, v)
		s = s.Value(...).Format(...).Generate(...) // Modify the Store.
		return s.Maximizer(opt), nil
		// return s.Minimizer(opt), nil
		// return s.Satisfier(opt), nil
	}
	run.Run(handler)
}

Types

type Option added in v0.20.4

type Option func(Runner)

An Option configures a Runner.

type Runner added in v0.20.4

type Runner interface {
	// Run invokes a solver by invoking the associated handler.
	Run()

	// SetDecoder sets decoder to be used to decode input.
	SetDecoder(decoder decode.Decoder)
	// SetEncoder sets encoder to be used to encode output.
	SetEncoder(encoder encode.Encoder)
	// SetHandler sets the handler to be used by the run invocation.
	SetHandler(any)
}

Runner defines the interface of the runner.

Directories

Path Synopsis
Package decode provides decoders for output of a runner.
Package decode provides decoders for output of a runner.
Package encode provides encoders for input of a runner.
Package encode provides encoders for input of a runner.

Jump to

Keyboard shortcuts

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