File tree Expand file tree Collapse file tree 2 files changed +46
-6
lines changed Expand file tree Collapse file tree 2 files changed +46
-6
lines changed Original file line number Diff line number Diff line change 11package problem
22
3- import "github.com/MatProGo-dev/MatProInterface.go/optim"
3+ import (
4+ "github.com/MatProGo-dev/MatProInterface.go/optim"
5+ )
46
57// ObjSense represents whether an optimization objective is to be maximized or
68// minimized. This implementation conforms to the Gurobi encoding
7- type ObjSense int
9+ type ObjSense string
810
911// Objective senses (minimize and maximize) encoding using Gurobi's standard
1012const (
11- SenseMinimize ObjSense = 1
12- SenseMaximize = - 1
13- SenseFind ObjSense = 0
13+ SenseMinimize ObjSense = "Minimize"
14+ SenseMaximize = "Maximize"
15+ SenseFind ObjSense = "Find"
1416)
1517
1618/*
Original file line number Diff line number Diff line change 11package problem_test
22
33import (
4+ "fmt"
5+ "testing"
6+
47 "github.com/MatProGo-dev/MatProInterface.go/optim"
58 "github.com/MatProGo-dev/MatProInterface.go/problem"
6- "testing"
79)
810
911/*
@@ -52,3 +54,39 @@ func TestObjectiveSense_ToObjSense2(t *testing.T) {
5254 problem .SenseMaximize , objSense )
5355 }
5456}
57+
58+ /*
59+ TestObjectiveSense_String1
60+ Description:
61+
62+ Tests that we can extract strings from the three normal ObjSense values
63+ (Minimize, Maximize, Find).
64+ */
65+ func TestObjectiveSense_String1 (t * testing.T ) {
66+ // Test Minimize
67+ minSense := problem .SenseMinimize
68+ if fmt .Sprintf ("%v" , minSense ) != "Minimize" {
69+ t .Errorf (
70+ "minSense's string is \" %v\" ; expected \" Minimize\" " ,
71+ minSense ,
72+ )
73+ }
74+
75+ // Test Maximize
76+ maxSense := problem .SenseMaximize
77+ if fmt .Sprintf ("%v" , maxSense ) != "Maximize" {
78+ t .Errorf (
79+ "maxSense's string is \" %v\" ; expected \" Maximize\" " ,
80+ maxSense ,
81+ )
82+ }
83+
84+ // Test Find
85+ findSense := problem .SenseFind
86+ if fmt .Sprintf ("%v" , findSense ) != "Find" {
87+ t .Errorf (
88+ "findSense's string is \" %v\" ; expected \" Find\" " ,
89+ findSense ,
90+ )
91+ }
92+ }
You can’t perform that action at this time.
0 commit comments