Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building problem with zero coefficients #77

Closed
salomonl opened this issue Jan 6, 2021 · 5 comments · Fixed by #79
Closed

Error when building problem with zero coefficients #77

salomonl opened this issue Jan 6, 2021 · 5 comments · Fixed by #79

Comments

@salomonl
Copy link

salomonl commented Jan 6, 2021

@mtanneau I am testing the native API of the Tulip solver on several examples, which are supposed to be feasible. Most are working, except this one.

On this particular example (sorry, I did not find another minimal example), I trigger the formatting exception line 164 of src/IMP/impdata.jl. It works for several similar other examples, so the dimensions format seem correct.

I try to solve the following problem:

min z5
s.c lb <= Az <= ub

with A of dimensions 49 * 34 and z of dimensions 34, lb and ub of dimensions 49.

So, A has more rows than columns.

import Tulip

# data
lb = [10.000000000000181;
      -4.160250050215518e-14;
      -5.859572377763578e-14;
      -3.0206746014582044e-13;
      7.000000000000127;
      1.4999999999999585;
      2.0000000000000235;
      2.000000000000257;
      29.999999999999186;
      20.0;
      0.010000000000095792;
      5.2001536749292135e-14;
      -0.2;
      0.0999999999999949;
      0.0;
      0.0;
      100.0;
      500.0;
      500.0;
      1000.449469529165;
      2.0;
      1998.9181819464666;
      2994.4712103355896;
      4997.836363892933;
      0.2;
      2.5999380519889845;
      0.0;
      100.0;
      4.0;
      0.0;
      579.9867487235355;
      10.0;
      249.77526523541746;
      750.2247347645825;
      249.85179092666596;
      10.0;
      10.74936862843041;
      100.01932718975416;
      277.358639666949;
      196.75629112130164;
      779.9814155966956;
      100.0;
      2.0;
      0.0;
      0.0;
      500.0;
      0.3071248179551529;
      1.3867931983347423;
      1.6396357593441846]
ub = [150.00000000000017;
      9.99999999999996;
      9.999999999999941;
      4.999999999999698;
      120.00000000000013;
      7.999999999999958;
      20.000000000000025;
      30.000000000000256;
      499.9999999999992;
      200.0;
      20.000000000000096;
      10.000000000000052;
      -0.001;
      1.999999999999995;
      1.0;
      2.0;
      1000.0;
      5000.0;
      5000.0;
      20000.449469529165;
      30.0;
      19998.918181946465;
      29994.47121033559;
      49997.83636389293;
      0.8;
      6.5999380519889845;
      20.0;
      400.0;
      15.0;
      10.0;
      10079.986748723535;
      50.0;
      4999.7752652354175;
      15000.224734764583;
      2999.851790926666;
      5000.0;
      45.74936862843041;
      3000.019327189754;
      477.358639666949;
      316.7562911213016;
      1979.9814155966956;
      1000.0;
      20.0;
      1.0;
      2.0;
      5000.0;
      1.307124817955153;
      2.3867931983347423;
      2.6396357593441846]
A = [0.0 0.0 0.0 0.024495949415647516 0.2477654684642663 0.0 -0.011119658429724254 1.2228081648911448e-16 -0.02223931685944833 0.0 -1.5444999971558658e-18 0.0 0.0 0.0 0.0 -4.633367913734631e-16 0.0 0.2600827551833563 -0.2600827551833563 0.4058269499899332 0.0 0.005806029719914009 0.2864485283509324 -4.051468122850578e-16 -3.9190061124904336e-16 -4.63299639313543e-16 0.0 0.0 0.0 0.0 0.0 -0.2032110401969258 -2.0261494930936026e-18 -3.265833968102728e-18;
     0.0 0.0 0.0 -0.019865773474634207 0.2070920855092544 0.0 0.4499895688046492 -2.969927233278397e-17 -0.21805485114059647 0.0 3.475804001008223e-19 0.0 0.0 0.0 0.0 1.0450213846969295e-16 0.0 0.19219900830735728 -0.19219900830735728 -0.10131289433179796 0.0 -0.0014494495141722757 -0.3463506326022579 9.060323444968781e-17 8.715408023996434e-17 1.0459464184353835e-16 0.0 0.0 0.0 0.0 0.0 0.05073073299601369 4.514593846151991e-19 7.266142848492211e-19;
     0.0 0.0 0.0 -0.028094446274859377 0.29287243598731627 0.0 -0.6285297129373957 -4.223110773813765e-17 0.32407940420939807 0.0 4.891571448740823e-19 0.0 0.0 0.0 0.0 1.4656170678748429e-16 0.0 0.2718104442229239 -0.2718104442229239 -0.14327806920730107 0.0 -0.0020498311609175313 -0.48981376196261417 1.2629237085359786e-16 1.2202784755816392e-16 1.4669252631334175e-16 0.0 0.0 0.0 0.0 0.0 0.07174409063209088 6.336684426562909e-19 1.0180046923935259e-18;
     0.0 0.0 0.0 0.013329586870028262 0.19048154980934828 0.0 0.017686318086479736 -1.9687839174413231e-16 0.0353726361729593 0.0 2.61139139430658e-18 0.0 0.0 0.0 0.0 7.8349203899890905e-16 0.0 0.21583334762147532 -0.21583334762147532 -0.645486061550352 0.0 -0.009234752047010557 0.5895766933052783 6.899784706781798e-16 6.68626317913213e-16 7.836495760647963e-16 0.0 0.0 0.0 0.0 0.0 0.3232163216452669 3.4499975993835424e-18 5.5729038174830675e-18;
     0.0 0.0 0.0 0.017147164590953258 0.17343582792498646 0.0 -0.0077837609008068725 8.559657154238012e-17 -0.015567521801613879 0.0 -1.081149998009106e-18 0.0 0.0 0.0 0.0 -3.243357539614242e-16 0.0 0.18205792862834946 -0.18205792862834946 0.2840788649929533 0.0 0.0040642208039398066 0.20051396984565262 -2.8360276859954047e-16 -2.7433042787433036e-16 -3.243097475194801e-16 0.0 0.0 0.0 0.0 0.0 -0.14224772813784806 -1.418304645165522e-18 -2.28608377767191e-18;
     0.0 0.0 0.0 -0.019865773474634203 0.20709208550925434 0.0 0.4499895688046493 -2.9699272332783967e-17 -0.21805485114059647 0.0 3.4758040010082237e-19 0.0 0.0 0.0 0.0 1.0450213846969291e-16 0.0 0.19219900830735728 -0.19219900830735728 -0.10131289433179798 0.0 -0.001449449514172275 -0.34635063260225785 9.060323444968786e-17 8.715408023996433e-17 1.0459464184353833e-16 0.0 0.0 0.0 0.0 0.0 0.05073073299601368 4.514593846151991e-19 7.266142848492214e-19;
     0.0 0.0 0.0 0.0031844734240341786 0.032209510900354635 0.0 -0.0014455555958641545 1.5896506143584886e-17 -0.0028911111917282835 0.0 -2.0078499963026272e-19 0.0 0.0 0.0 0.0 -6.023378287855022e-17 0.0 0.03381075817383636 -0.03381075817383636 0.05275750349869137 0.0 0.0007547838635888217 0.037238308685621266 -5.266908559705755e-17 -5.0947079462375685e-17 -6.02289531107606e-17 0.0 0.0 0.0 0.0 0.0 -0.026417435225600378 -2.6339943410216863e-19 -4.245584158533549e-19;
     0.0 0.0 0.0 0.003682977379840559 -0.16440569563625282 0.0 0.012860422734150183 1.6303794767130798e-16 0.025720845468300498 0.0 -2.2439031706833463e-18 0.0 0.0 0.0 0.0 -6.732120296658963e-16 0.0 -0.17262314189704298 0.17262314189704298 -0.4693584939470894 0.0 0.007564932791720189 -0.19110340141372273 -5.958557646369564e-16 -5.781183869154841e-16 -6.732366187761362e-16 0.0 0.0 0.0 0.0 0.0 -0.26477264771012254 -2.9789281816317022e-18 -4.817463581403262e-18;
     0.0 0.0 0.0 0.0018414886899202794 -0.08220284781812655 0.0 -0.007244147269796774 -5.292561556386879e-16 -0.014488294539593476 0.0 7.053928058912055e-18 0.0 0.0 0.0 0.0 2.116238770089633e-15 0.0 -0.08631157094852142 0.08631157094852142 0.2643849368538975 0.0 -0.024777307503025956 -0.09555170070686136 1.864838611355606e-15 1.8073541272602294e-15 2.1162264755345127e-15 0.0 0.0 0.0 0.0 0.0 0.8672057626056332 9.324182030306174e-18 1.5060899229944685e-17;
     0.0 0.0 0.0 0.049870719479576275 0.0002764385600500723 0.0 1.8065205161585194e-5 -1.9410492414211895e-19 3.6130410323172576e-5 0.0 2.2517222666263698e-21 0.0 0.0 0.0 0.0 6.756370778918779e-19 0.0 0.0001795188617644395 -0.0001795188617644395 -0.0006593140569921849 0.0 -9.432584528329142e-6 -0.002253946471758722 5.8337368849753e-19 5.623387558497746e-19 6.758367217593351e-19 0.0 0.0 0.0 0.0 0.0 0.0003301404584913903 2.9175085073919777e-21 4.68768008763356e-21;
     0.0 0.0 0.0 0.0 1.3625371989532675e-17 0.0 -5.6276869015575715e-18 6.23009673364483e-17 -1.1255373803115143e-17 0.0 -8.2924525536196e-19 0.0 0.0 0.0 0.0 -2.487159783681747e-16 0.0 -6.813533027713592e-18 6.813533027713592e-18 -7.712234984750405e-19 0.0 9.255833946508751e-16 5.859350412631623e-19 -0.00499993750117207 -2.1228678537266177e-16 -2.487159783681747e-16 0.0 0.0 0.0 0.0 0.0 2.6445427404463324e-17 0.9999875002343702 -1.768604793866979e-18;
     0.0 0.0 0.0 0.0 7.392903563635533e-18 0.0 -3.0560948736935156e-18 3.382710778154774e-17 -6.0986372202309624e-18 0.0 -4.497744949920335e-19 0.0 0.0 0.0 0.0 -1.3530843112619095e-16 0.0 -3.699839913606784e-18 3.699839913606784e-18 -4.1928130889087867e-19 0.0 5.023650766211585e-16 3.1763735522036263e-19 -1.1882855810441129e-16 -0.008333043996551135 -1.3444106938820255e-16 0.0 0.0 0.0 0.0 0.0 1.435297329122412e-17 -5.929230630780102e-19 0.9999652795861224;
     0.0 0.0 0.0 0.0 -1.6940658945086007e-21 0.0 1.6940658945086007e-21 6.776263578034403e-21 3.3881317890172014e-21 0.0 0.9999944444907404 0.0 0.0 0.0 0.0 0.0 0.0 8.470329472543003e-22 -8.470329472543003e-22 2.117582368135751e-22 0.0 6.776263578034403e-21 0.0 0.0 -1.0842021724855044e-19 -0.0033333148149691347 0.0 0.0 0.0 0.0 0.0 0.0 -8.470329472543003e-22 -8.470329472543003e-22;
     0.0 0.0 0.0 0.0 -0.017614394442704878 0.0 0.010542091369171164 -0.05290832135876376 0.021084182738342318 0.0 4.5514786025117795e-20 0.0 0.0 0.0 0.0 1.7875783318854754e-17 0.0 0.008807197221352443 -0.008807197221352443 0.0014442665175764485 0.0 -0.9968859897124329 -0.0007574189610363099 -0.025130824374803403 -0.030861044331200297 1.7367563550502174e-17 0.0 0.0 0.0 0.0 0.0 -0.028482456848935616 -0.00012565412187310164 -0.00025717536942617233;
     0.0 0.0 0.0 0.0 -0.005093362018242666 0.0 0.008200038762387908 0.02830000804060586 0.016400077524775812 0.0 -0.0016898622062368812 0.0 0.0 0.0 0.0 -0.5069642947450851 0.0 0.0025466810091213346 -0.0025466810091213346 0.0011234053104472305 0.0 0.026671227304458357 -0.00021901456678434858 -0.49350945318946754 -0.4904218996450341 -0.5069586618710643 0.0 0.0 0.0 0.0 0.0 0.0007620350658464641 -0.002467547265947828 -0.004086849163708883;
     1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.9974143895915252 0.005528771201001569 0.0 0.00036130410323176223 -3.882098482842509e-18 0.0007226082064635208 0.0 4.503444533253034e-20 0.0 0.0 0.0 0.0 1.3512741557837343e-17 0.0 0.003590377235288976 -0.003590377235288976 -0.013186281139845267 0.0 -0.0001886516905665881 -0.04507892943517663 1.166747376995119e-17 1.1246775116996476e-17 1.3516734435188982e-17 0.0 0.0 0.0 0.0 0.0 0.006602809169828494 5.835017014783872e-20 9.375360175268435e-20;
     0.0 0.0 0.0 0.0 0.6655096913916039 0.0 0.0002274583216080798 -0.0007878058556446685 0.00045491664321615935 0.0 -8.607079977310684e-6 0.0 0.0 0.0 0.0 -0.002582152683459795 0.0 -0.33275484569580205 0.33275484569580205 3.1161790060307367e-5 0.0 -0.01742369682106859 0.028616916729838966 -0.0029562865577270696 -0.0030414948843299956 -0.002582123993193204 0.0 0.0 0.0 0.0 0.0 -0.0004978199091735217 -1.4781432788621721e-5 -2.534579070274257e-5;
     0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 0.00022745832160807968 0.0 0.1990736713373403 0.0003257031950447 0.39814734267468044 0.0 1.3856935594236776e-5 0.0 0.0 0.0 0.0 0.004157126868056346 0.0 -0.00011372916080403988 0.00011372916080403988 0.027273092973215604 0.0 0.01029055809045807 9.78070782914672e-6 0.004311728092500266 0.004346818536100747 0.004157080678271032 0.0 0.0 0.0 0.0 0.0 0.00029401594544171424 2.1558640462495703e-5 3.62234878008365e-5;
     0.0 0.0 0.0 0.0 -0.0007878058556446683 0.0 0.0003257031950447003 0.9963998190758995 0.0006514063900894001 0.0 4.78231140240197e-5 0.0 0.0 0.0 0.0 0.01434709361758599 0.0 0.00039390292782233427 -0.00039390292782233427 4.4621337721121425e-5 0.0 -0.05349836024892367 -3.3875651792723184e-5 0.01263669176134418 0.012246137652301464 0.014346934207205909 0.0 0.0 0.0 0.0 0.0 -0.001528524578541286 6.318345880678321e-5 0.00010205114710254602;
     0.0 0.0 0.0 0.0 0.00045491664321615935 0.0 0.3981473426746804 0.0006514063900894 0.7962946853493609 0.0 2.771387118847355e-5 0.0 0.0 0.0 0.0 0.008314253736112692 0.0 -0.00022745832160807978 0.00022745832160807978 0.05454618594643121 0.0 0.020581116180916136 1.9561415658293444e-5 0.00862345618500053 0.008693637072201494 0.008314161356542064 0.0 0.0 0.0 0.0 0.0 0.0005880318908834286 4.311728092499141e-5 7.2446975601673e-5;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 -8.607079977310684e-6 0.0 1.3856935594236772e-5 4.782311402401969e-5 2.771387118847354e-5 0.0 8.255353379522243e-6 0.0 0.0 0.0 0.0 -0.000856699801601254 0.0 4.3035399886553445e-6 -4.3035399886553445e-6 1.8984001764105851e-6 0.0 4.507069901575734e-5 -3.7010443902421405e-7 -0.0008339629733655104 -0.0008287454333210395 0.002476606013887481 0.0 0.0 0.0 0.0 0.0 1.2877342576011728e-6 -4.16981486682838e-6 -6.9062119443424454e-6;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 -0.0025821526834597965 0.0 0.004157126868056346 0.014347093617585988 0.00831425373611269 0.0 -0.000856699801601254 0.0 0.0 0.0 0.0 0.7429872038536185 0.0 0.001291076341729899 -0.001291076341729899 0.0005695263809237636 0.0 0.013521359940390587 -0.00011103256538872762 -0.250191671886231 -0.2486263924810896 -0.2570099404803762 0.0 0.0 0.0 0.0 0.0 0.00038632456972787714 -0.0012509583594314036 -0.002071886604009215;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 -0.33275484569580205 0.0 -0.00011372916080403989 0.0003939029278223342 -0.0002274583216080797 0.0 4.303539988655342e-6 0.0 0.0 0.0 0.0 0.0012910763417298978 0.0 0.6663774228479008 0.33362257715209914 -1.5580895030153683e-5 0.0 0.008711848410534295 -0.014308458364919485 0.0014781432788635348 0.0015207474421649978 0.001291061996596602 0.0 0.0 0.0 0.0 0.0 0.00024890995458676083 7.390716394310861e-6 1.2672895351371284e-5;
     0.0 0.0 0.0 0.0 0.33275484569580205 0.0 0.00011372916080403989 -0.0003939029278223342 0.0002274583216080797 0.0 -4.303539988655342e-6 0.0 0.0 0.0 0.0 -0.0012910763417298978 0.0 0.33362257715209914 0.6663774228479008 1.5580895030153683e-5 0.0 -0.008711848410534295 0.014308458364919485 -0.0014781432788635348 -0.0015207474421649978 -0.001291061996596602 0.0 0.0 0.0 0.0 0.0 -0.00024890995458676083 -7.390716394310861e-6 -1.2672895351371284e-5;
     0.0 0.0 0.0 0.0 3.116179006030691e-5 0.0 0.02727309297321561 4.462133772112389e-5 0.054546185946431215 0.0 1.8984001764104384e-6 0.0 0.0 0.0 0.0 0.0005695263809237195 0.0 -1.5580895030153463e-5 1.5580895030153463e-5 0.0037364137373307044 0.0 0.0014098064583927556 1.3399569725931008e-6 0.0005907067486725365 0.0005955141394458025 0.0005695200529231316 0.0 0.0 0.0 0.0 0.0 4.028018452551486e-5 2.9535337433619116e-6 4.962617828714602e-6;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 -0.01742369682106859 0.0 0.010290558090458077 -0.05349836024892369 0.020581116180916143 0.0 4.5070699015757624e-5 0.0 0.0 0.0 0.0 0.013521359940390673 0.0 0.008711848410534299 -0.008711848410534299 0.0014098064583927532 0.0 0.004691308463981791 -0.0007492189633059519 -0.011890063926249923 -0.017684788761150847 0.013521209704727288 0.0 0.0 0.0 0.0 0.0 0.0001340373846761278 -5.945031963032403e-5 -0.0001473732396757547;
     0.0 0.0 0.0 0.0 0.028616916729838963 0.0 9.78070782914743e-6 -3.387565179272074e-5 1.956141565829485e-5 0.0 -3.701044390243593e-7 0.0 0.0 0.0 0.0 -0.00011103256538877119 0.0 -0.014308458364919487 0.014308458364919487 1.3399569725932164e-6 0.0 -0.0007492189633059493 0.0012305274193829972 -0.000127120321982264 -0.00013078428002618982 -0.00011103133170730777 0.0 0.0 0.0 0.0 0.0 -2.1406256094461428e-5 -6.35601609910734e-7 -1.0898690002179303e-6;
     0.0 0.0 0.0 0.0 -0.0029562865577270705 0.0 0.004311728092500266 0.01263669176134418 0.00862345618500053 0.0 -0.0008339629733655104 0.0 0.0 0.0 0.0 -0.250191671886231 0.0 0.0014781432788635363 -0.0014781432788635363 0.0005907067486725794 0.0 -0.011890063926249996 -0.00012712032198222155 0.7557918619038599 -0.24280340701107112 -0.2501888920096531 0.0 0.0 0.0 0.0 0.0 -0.0003397161121764293 0.0037789593095190815 -0.002023361725092378;
     0.0 0.0 0.0 0.0 -0.0030414948843299964 0.0 0.004346818536100747 0.012246137652301464 0.008693637072201492 0.0 -0.0008287454333210396 0.0 0.0 0.0 0.0 -0.2486263924810896 0.0 0.0015207474421649993 -0.0015207474421649993 0.0005955141394458451 0.0 -0.01768478876115092 -0.00013078428002614764 -0.24280340701107112 0.7584645166690953 -0.24862362999631185 0.0 0.0 0.0 0.0 0.0 -0.0005052796788879503 -0.0012140170350555678 0.006320537638909014;
     0.0 0.0 0.0 0.0 -0.002582123993193205 0.0 0.004157080678271032 0.014346934207205907 0.008314161356542062 0.0 0.002476606013887481 0.0 0.0 0.0 0.0 -0.2570099404803762 0.0 0.0012910619965966035 -0.0012910619965966035 0.0005695200529231755 0.0 0.013521209704727201 -0.00011103133170726421 -0.2501888920096531 -0.24862362999631185 0.7429818041662442 0.0 0.0 0.0 0.0 0.0 0.00038632027728035184 -0.0012509444600485142 -0.0020718635833027335;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0;
     0.0 0.0 0.0 0.0 -0.0004978199091733883 0.0 0.0002940159454416593 -0.0015285245785406768 0.0005880318908833183 0.0 1.2877342575930751e-6 0.0 0.0 0.0 0.0 0.0003863245697254478 0.0 0.00024890995458669426 -0.00024890995458669426 4.0280184525507234e-5 0.0 0.00013403738468518897 -2.140625609445577e-5 -0.0003397161121785693 -0.0005052796788900241 0.00038632027727792247 0.0 0.0 0.0 0.0 0.0 3.829639562358267e-6 -1.6985805608664007e-6 -4.210663990735849e-6;
     0.0 0.0 0.0 0.0 -1.4781432788635351e-5 0.0 2.1558640462501328e-5 6.318345880672091e-5 4.311728092500265e-5 0.0 -4.169814866827552e-6 0.0 0.0 0.0 0.0 -0.001250958359431155 0.0 7.390716394317682e-6 -7.390716394317682e-6 2.953533743362897e-6 0.0 -5.945031963124998e-5 -6.356016099111078e-7 0.003778959309519301 -0.0012140170350553555 -0.0012509444600482655 0.0 0.0 0.0 0.0 0.0 -1.698580560882146e-6 1.8894796547375137e-5 -1.011680862546189e-5;
     0.0 0.0 0.0 0.0 -2.5345790702749968e-5 0.0 3.622348780083956e-5 0.0001020511471025122 7.244697560167909e-5 0.0 -6.9062119443419965e-6 0.0 0.0 0.0 0.0 -0.0020718866040090795 0.0 1.2672895351374994e-5 -1.2672895351374994e-5 4.962617828715376e-6 0.0 -0.00014737323967625764 -1.0898690002178968e-6 -0.0020233617250922592 0.00632053763890913 -0.002071863583302599 0.0 0.0 0.0 0.0 0.0 -4.210663990732919e-6 -1.0116808625463065e-5 5.2671146990812545e-5]
ind = 5

# preliminary checks: all dimensions are correct
println("Dimensions of A: ", size(A))
println("Dimensions of ub: ", length(ub))
println("Dimensions of lb: ", length(lb))
println("All lb are strictly inferior to ub: ", all(lb .< ub))

# problem

# Initialize the model
linear_model = Tulip.Model{Float64}()
pb = linear_model.pbdata

# Create variables
variables = Int[]
for i in 1:ind-1
    push!(variables, Tulip.add_variable!(pb, Int[], Float64[], 0.0, -Inf, Inf, "z" * string(i)))
end
push!(variables, Tulip.add_variable!(pb, Int[], Float64[], 1.0, -Inf, Inf, "z" * string(ind)))
for i in ind+1:size(A, 2)
    push!(variables, Tulip.add_variable!(pb, Int[], Float64[], 0.0, -Inf, Inf, "z" * string(i)))
end

println("Number of variables: ", length(variables))

# Create constraints
rows = Int[]
for i in 1:size(A, 1)
    push!(rows, Tulip.add_constraint!(pb, variables, A[i, :], lb[i], ub[i], "row" * string(i)))
end

# Set some parameters
Tulip.set_parameter(linear_model, "Presolve_Level", 0) # disable presolve

# Solve the problem
Tulip.optimize!(linear_model)

Here, what is obtained:

> julia wrong_example.jl
Dimensions of A: (49, 34)
Dimensions of ub: 49
Dimensions of lb: 49
All lb are strictly inferior to ub: true
Number of variables: 34
ERROR: LoadError: Found 633 non-zero coeffs (expected 1715)

I use the Julia 1.5.3 version release.

It does not seem a formatting normal error. Do you have any idea ?

@mtanneau
Copy link
Member

mtanneau commented Jan 6, 2021

The error is caused by the presence of zero coefficients in A.
It doesn't fix the bug in my code, but sparsifying A before building the problem does removes the error.

BTW, if you already know A, lb, ub and the objective vector c, then you can load the problem directly using the (internal) function load_problem! as follows:

# Assume A, lb, ub, c are known
m, n = size(A)
lp = Tulip.Model{Float64}()
Tulip.load_problem!(lp.pbdata,
    "LP",                         # problem name
    true, c, 0.0,                 # objective
    sparse(A), lb, ub,            # rows
    fill(-Inf, n), fill(Inf, n),  # variable bounds
    fill("", m), fill("", n)      # row and column names
)

@mtanneau
Copy link
Member

mtanneau commented Jan 6, 2021

Found the bug. When adding constraints, those numerical zeros are kept in the rows but not in the columns.
I'll have a patch ready soon.

@mtanneau mtanneau changed the title Using native API: dimensions matching but raise an error; any prerequite on matrix rank of A? Error when building problem with zero coefficients Jan 7, 2021
@salomonl
Copy link
Author

salomonl commented Jan 7, 2021

@mtanneau It solves my problem ! Thanks !

@mtanneau
Copy link
Member

mtanneau commented Jan 7, 2021

Great! :D I'll leave the issue open until I push a fix.

@mtanneau
Copy link
Member

mtanneau commented Jan 8, 2021

@amontoison @salomonl I have just tagged v0.7.1 which includes the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants