fix test with data
This commit is contained in:
19
examples/data/tests/maximization.mps
Normal file
19
examples/data/tests/maximization.mps
Normal file
@@ -0,0 +1,19 @@
|
||||
* Generated by MPModelProtoExporter
|
||||
* Name : SupportedMaximizationProblem
|
||||
* Format : Free
|
||||
* Constraints : 0
|
||||
* Variables : 1
|
||||
* Binary : 0
|
||||
* Integer : 0
|
||||
* Continuous : 1
|
||||
NAME SupportedMaximizationProblem
|
||||
OBJSENSE
|
||||
MAX
|
||||
ROWS
|
||||
N COST
|
||||
COLUMNS
|
||||
X_ONE COST 1
|
||||
BOUNDS
|
||||
UP BOUND X_ONE 4
|
||||
ENDATA
|
||||
|
||||
7
examples/data/tests/small_model.lp
Normal file
7
examples/data/tests/small_model.lp
Normal file
@@ -0,0 +1,7 @@
|
||||
min: x + y;
|
||||
bin: b1, b2, b3;
|
||||
1 <= x <= 42;
|
||||
constraint_num1: 5 b1 + 3b2 + x <= 7;
|
||||
4 y + b2 - 3 b3 <= 2;
|
||||
constraint_num2: -4 b1 + b2 - 3 z <= -2;
|
||||
|
||||
@@ -17,6 +17,7 @@ import math
|
||||
|
||||
from ortools.model_builder.python import model_builder
|
||||
import unittest
|
||||
import os
|
||||
|
||||
|
||||
class ModelBuilderTest(unittest.TestCase):
|
||||
@@ -123,8 +124,7 @@ ENDATA
|
||||
self.assertEqual(model.name, 'SupportedMaximizationProblem')
|
||||
|
||||
def test_import_from_mps_file(self):
|
||||
mps_path = resources.GetResourceFilename('ortools.linear_solver/'
|
||||
'testdata/maximization.mps')
|
||||
mps_path = f'{os.path.dirname(__file__)}/../data/tests/maximization.mps'
|
||||
model = model_builder.ModelBuilder()
|
||||
self.assertTrue(model.import_from_mps_file(mps_path))
|
||||
self.assertEqual(model.name, 'SupportedMaximizationProblem')
|
||||
@@ -147,7 +147,7 @@ ENDATA
|
||||
self.assertEqual('x', model.var_from_index(0).name)
|
||||
|
||||
def test_import_from_lp_file(self):
|
||||
lp_path = resources.GetResourceFilename('testdata/small_model.lp')
|
||||
lp_path = f'{os.path.dirname(__file__)}/../data/tests/small_model.lp'
|
||||
model = model_builder.ModelBuilder()
|
||||
self.assertTrue(model.import_from_lp_file(lp_path))
|
||||
self.assertEqual(6, model.num_variables)
|
||||
|
||||
Reference in New Issue
Block a user