예제 #1
0
파일: decoder_test.py 프로젝트: IreneZR/les
 def test_decode_10teams_mps(self):
   test1_filename = os.path.join(TEST_DATA_DIR, '10teams.mps')
   decoder = mps.decode(test1_filename)
   self.assert_equal('10teams', decoder.get_name())
   self.assert_equal(2025, len(decoder.get_objective_coefficients()))
   self.assert_equal(230, decoder.get_rows_coefficients().shape[0])
   self.assert_equal(230, len(decoder.get_rows_rhs()))
예제 #2
0
파일: decoder_test.py 프로젝트: IreneZR/les
 def test_decode_test1_mps(self):
   test1_filename = os.path.join(TEST_DATA_DIR, 'test1.mps')
   decoder = mps.decode(test1_filename)
   self.assert_equal('TESTPROB', decoder.get_name())
   self.assert_equal(['L', 'G', 'E'], decoder.get_rows_senses())
   self.assert_equal(['X', 'Y', 'Z'], decoder.get_columns_names())
   self.assert_equal(['LIM1', 'LIM2', 'LIM3'], decoder.get_rows_names())
   self.assert_equal([5.0, 10.0, 7.0], decoder.get_rows_rhs())
   self.assert_equal([1.0, 4.0, 9.0], decoder.get_objective_coefficients())
   rows_coefs = sparse.lil_matrix([[1.0,  1.0, 0.0],
                                   [1.0,  0.0, 1.0],
                                   [0.0, -1.0, 1.0]])
예제 #3
0
파일: encoder_test.py 프로젝트: IreneZR/les
 def test_encode(self):
   model1 = mp_model_builder.MPModelBuilder.build_from(
     [8, 2, 5, 5, 8, 3, 9, 7, 6],
     [[2, 3, 4, 1, 0, 0, 0, 0, 0],
      [1, 2, 3, 2, 0, 0, 0, 0, 0],
      [0, 0, 1, 4, 3, 4, 2, 0, 0],
      [0, 0, 2, 1, 1, 2, 5, 0, 0],
      [0, 0, 0, 0, 0, 0, 2, 1, 2],
      [0, 0, 0, 0, 0, 0, 3, 4, 1]],
     ['L'] * 6,
     [7, 6, 9, 7, 3, 5])
   model1.set_name('DEMO1')
   model1.set_objective_name('PRODUCT')
   stream = StringIO.StringIO()
   mps.encode(stream, model1)
   model2 = mp_model_builder.MPModelBuilder.build_from(mps.decode(stream))
   self.assert_equal(model1.get_name(), model2.get_name())
   self.assert_equal(model1.get_num_columns(), model2.get_num_columns())
   self.assert_equal(model1.get_num_rows(), model2.get_num_rows())