My Project
OSosrl2ampl.cpp
Go to the documentation of this file.
1/* $Id: OSosrl2ampl.cpp 4210 2011-06-28 09:44:54Z Gassmann $ */
23#include <iostream>
24#include "OSrLReader.h"
25#include "OSosrl2ampl.h"
26#include "OSResult.h"
27#include "OSErrorClass.h"
28#include "OSMathUtil.h"
29#include "OSOutput.h"
30
31#include "CoinHelperFunctions.hpp"
32
33
34#include "nlp.h"
35#include "getstub.h"
36#include "r_opn.hd" /* for N_OPS */
37#include "opcode.hd"
38
39#ifdef HAVE_CMATH
40# include <cmath>
41#else
42# ifdef HAVE_CMATH_H
43# include <cmath.h>
44# endif
45#endif
46
47#include <sstream>
48
49#include <asl.h>
50//#include "sufinfo.h"
51
52using std::endl;
53
54#ifdef HAVE_STDINT_H
55#include <stdint.h>
56#endif
57
58#ifdef HAVE_STDLIB_H
59#include <stdlib.h>
60#endif
61
62
66
70
71bool OSosrl2ampl::writeSolFile(std::string osrl, ASL *asl, std::string solfile)
72{
73 OSrLReader *osrlreader = NULL;
75 std::ostringstream outStr;
76
77 if (osrl == "")
78 {
79// std::string solMsg = "No solution returned!";
80 std::string solMsg = " ";
81 solve_result_num = 550;
82 write_sol(const_cast<char*>(solMsg.c_str()), NULL, NULL , NULL);
83 return true;
84 }
85 else
86 {
87#ifndef NDEBUG
88 outStr.str("");
89 outStr.clear();
90 outStr << std::endl << osrl << std::endl << std::endl << std::endl;
92#endif
93
94 double *x = NULL;
95 double *y = NULL;
96 std::string *otherVar = NULL;
97 std::string *otherObj = NULL;
98 std::string *otherCon = NULL;
99
100 double **rData = NULL;
101 int **iData = NULL;
102 double* rvalues = NULL;
103 int* ivalues = NULL;
104 int nSuffixes = 0;
105
106 try
107 {
108 osrlreader = new OSrLReader();
109 osresult = osrlreader->readOSrL( osrl);
110 // do the following so output is not written twice
111 // see page 23 of hooking solver to AMPL
112 // need_nl = printf( sReport.c_str());
113
117 int numSols = osresult->getSolutionNumber();
118
119 if (numSols == 0)
120 {
121// std::string solMsg = "No solution returned!";
122 std::string solMsg = " ";
123 solve_result_num = 550;
124 write_sol(const_cast<char*>(solMsg.c_str()), NULL, NULL , NULL);
125 return true;
126 }
127
128 //
129 int i;
130 int vecSize;
131 int numVars = osresult->getVariableNumber();
132 int numObjs = osresult->getObjectiveNumber();
133 int numCons = osresult->getConstraintNumber();
134
135 if (numVars > 0)
136 {
137 x = new double[ numVars];
138 otherVar = new std::string[numVars];
139 }
140 if (numCons > 0)
141 {
142 y = new double[ numCons];
143 otherCon = new std::string[numCons];
144 }
145 if (numObjs > 0)
146 {
147 otherObj = new std::string[numObjs];
148 }
149
150 std::vector<IndexValuePair*> primalValPair;
151 std::vector<IndexValuePair*> dualValPair;
152 dualValPair = osresult->getOptimalDualVariableValues( 0);
153 primalValPair = osresult->getOptimalPrimalVariableValues( 0);
154
155 for (i = 0; i < numVars; i++)
156 {
157 x[i] = 0.0;
158 }
159 vecSize = primalValPair.size();
160 for (i = 0; i < vecSize; i++)
161 {
162 x[ primalValPair[i]->idx ] = primalValPair[i]->value;
163#ifndef NDEBUG
164 outStr.str("");
165 outStr.clear();
166 outStr << "index = " << primalValPair[i]->idx << std::endl;
167 outStr << "value = " << primalValPair[i]->value << std::endl;
169#endif
170 }
171
172 for (i = 0; i < numCons; i++)
173 {
174 y[i] = 0.0;
175 }
176 vecSize = dualValPair.size();
177 for (i = 0; i < vecSize; i++)
178 {
179 y[ dualValPair[i]->idx ] = dualValPair[i]->value;
180#ifndef NDEBUG
181 outStr.str("");
182 outStr.clear();
183 outStr << "index = " << dualValPair[i]->idx << std::endl;
184 outStr << "value = " << dualValPair[i]->value << std::endl;
186#endif
187 }
188
189 // return all solution results that are indexed over variables, objectives or constraints as suffixes
190
191 int n;
192 bool have_basic_var = false;
193 bool have_basic_con = false;
194 SufDecl *suftab = NULL;
195
196 // First determine the number of suffixes that need to be handled
197
199 if (n > 0) nSuffixes += n;
201 if (n > 0) nSuffixes += n;
203 if (n > 0) nSuffixes += n;
204
205 if ( (osresult->optimization != NULL)
206 && (osresult->optimization->solution[0] != NULL)
207 && (osresult->optimization->solution[0]->variables != NULL)
209 {
210 have_basic_var = true;
211 nSuffixes++;
212 }
213 if ( (osresult->optimization != NULL)
214 && (osresult->optimization->solution[0] != NULL)
215 && (osresult->optimization->solution[0]->constraints != NULL)
217 {
218 have_basic_con = true;
219 nSuffixes++;
220 }
221
222 if (nSuffixes > 0)
223 {
224 // Create a suffix table
225
226 int k = 0;
227 suftab = new SufDecl[nSuffixes];
228 SufDecl temp;
229 std::string s;
230 char* p;
231
232 for (i=0; i < osresult->getNumberOfOtherVariableResults(0); i++, k++)
233 {
235 suftab[k].name = new char[s.size()+1];
236 s.copy(suftab[k].name, s.size(), 0);
237 suftab[k].name[s.size()] = '\0';
238
239#ifndef NDEBUG
240 outStr.str("");
241 outStr.clear();
242 outStr << s << " has length " << s.size() << " p = " << suftab[k].name << std::endl;
244#endif
245
246 suftab[k].table = NULL;
247 suftab[k].kind = ASL_Sufkind_var;
248 suftab[k].nextra = 1;
249 }
250 for (i=0; i < osresult->getNumberOfOtherObjectiveResults(0); i++, k++)
251 {
253 suftab[k].name = new char[s.size()+1];
254 s.copy(suftab[k].name, s.size(), 0);
255 suftab[k].name[s.size()] = '\0';
256
257#ifndef NDEBUG
258 outStr.str("");
259 outStr.clear();
260 outStr << s << " has length " << s.size() << " p = " << suftab[k].name << std::endl;
262#endif
263
264 suftab[k].table = NULL;
265 suftab[k].kind = ASL_Sufkind_obj;
266 suftab[k].nextra = 1;
267 }
268 for (i=0; i < osresult->getNumberOfOtherConstraintResults(0); i++, k++)
269 {
271 suftab[k].name = new char[s.size()+1];
272 s.copy(suftab[k].name, s.size(), 0);
273 suftab[k].name[s.size()] = '\0';
274
275#ifndef NDEBUG
276 outStr.str("");
277 outStr.clear();
278 outStr << s << " has length " << s.size() << " p = " << suftab[k].name << std::endl;
280#endif
281
282 suftab[k].table = NULL;
283 suftab[k].kind = ASL_Sufkind_con;
284 suftab[k].nextra = 1;
285 }
286 if (have_basic_var)
287 {
288 s = "sstatus";
289 suftab[k].name = new char[s.size()+1];
290 s.copy(suftab[k].name, s.size(), 0);
291 suftab[k].name[s.size()] = '\0';
292
293#ifndef NDEBUG
294 outStr.str("");
295 outStr.clear();
296 outStr << s << " has length " << s.size() << " p = " << suftab[k].name << std::endl;
298#endif
299
300 suftab[k].table = NULL;
301 suftab[k].kind = ASL_Sufkind_var;
302 suftab[k].nextra = 1;
303 k++;
304 }
305 if (have_basic_con)
306 {
307 s = "sstatus";
308 suftab[k].name = new char[s.size()+1];
309 s.copy(suftab[k].name, s.size(), 0);
310 suftab[k].name[s.size()] = '\0';
311
312#ifndef NDEBUG
313 outStr.str("");
314 outStr.clear();
315 outStr << s << " has length " << s.size() << " p = " << suftab[k].name << std::endl;
317#endif
318
319 suftab[k].table = NULL;
320 suftab[k].kind = ASL_Sufkind_con;
321 suftab[k].nextra = 1;
322 }
323
324#ifndef NDEBUG
325 outStr.str("");
326 outStr.clear();
327 for (i=0; i < nSuffixes; i++)
328 outStr << i << ": suffix " << suftab[i].name << " of kind " << suftab[i].kind << std::endl;
330#endif
331
332 // make sure to inform AMPL of the suffixes you want to send back
333
334 suf_declare(suftab, nSuffixes);
335
336/* Now go through the suffixes again and prepare the data for writing
337 *
338 * ASL suf_iput and suf_rput do not actually produce any output; rather
339 * they store pointers to the material that is to be printed in a later
340 * call to routine write_sol. For that reason it is necessary to copy
341 * *all* the array-indexed results. Since ASL only handles real and integer
342 * values, this is done in two pointer arrays.
343 */
344 rData = new double*[nSuffixes];
345 iData = new int*[nSuffixes];
346
347 std::string resultType;
348 std::string resultName;
349
350 for (i=0; i<nSuffixes; i++)
351 {
352 rData[i] = NULL;
353 iData[i] = NULL;
354 }
355
356 int iSuf = 0;
357
358 for (i=0; i < osresult->getNumberOfOtherVariableResults(0); i++, iSuf++)
359 {
360 if ( (osresult->optimization->solution[0]->variables->other[i]->var != NULL) ||
362 {
363 if (numVars > 0)
364 n = osresult->getOtherVariableResultArrayDense(0, i, otherVar, numVars);
365 else
366 n = 0;
367 if (n < 0)
368 throw ErrorClass("unspecified error in routine getOtherVariableResultArrayDense()");
369 else if (n > 0)
370 {
371 resultType = osresult->getOtherVariableResultArrayType(0, i);
372 resultName = osresult->getOtherVariableResultName(0, i);
373
374#ifndef NDEBUG
375 outStr.str("");
376 outStr.clear();
377 outStr << "found variable suffix " << resultName
378 << " of type " << resultType << std::endl;
380
381 outStr.str("");
382 outStr.clear();
383 outStr << "retrieved these values:";
384 for (int m=0; m<n; m++)
385 outStr << " " << otherVar[m];
386 outStr << std::endl;
388#endif
389
390 if ( (resultType == "real")
391 || (resultType == "double")
392 || (resultType == "numeric")
393// || (resultType == "") // some versions of OSSolverService may not return a type
394 )
395 {
396 rData[iSuf] = new double[n];
397 for (int m=0; m<n; m++)
398 rData[iSuf][m] = os_strtod(otherVar[m].c_str(), NULL);
399#ifndef NDEBUG
400 outStr.str("");
401 outStr.clear();
402 outStr << "values (real): ";
403 for (int m=0; m<n; m++)
404 outStr << rData[iSuf][m] << " ";
405 outStr << std::endl << std::endl;
407#endif
408
409 suf_rput(resultName.c_str(), ASL_Sufkind_var, rData[iSuf]);
410 }
411 else if (resultType == "integer")
412 {
413 iData[iSuf] = new int[n];
414 for (int m=0; m<n; m++)
415 iData[iSuf][m] = atoi(otherVar[m].c_str());
416#ifndef NDEBUG
417 outStr.str("");
418 outStr.clear();
419 outStr << "values (integer): ";
420 for (int m=0; m<n; m++)
421 outStr << iData[iSuf][m] << " ";
422 outStr << std::endl << std::endl;
424#endif
425 suf_iput(resultName.c_str(), ASL_Sufkind_var, iData[iSuf]);
426 }
427 else
428 throw ErrorClass("otherVariableResult has unsupported type in OSosrl2ampl()");
429 }
430 }
431 }
432
433 // Suffixes associated with the objectives
434
435 for (i=0; i < osresult->getNumberOfOtherObjectiveResults(0); i++, k++)
436 {
437 if ( (osresult->optimization->solution[0]->objectives->other[i]->obj != NULL) ||
439 {
440 n = osresult->getOtherObjectiveResultArrayDense(0, i, otherObj, numObjs);
441 if (n < 0)
442 throw ErrorClass("unspecified error in routine getOtherObjectiveResultArrayDense()");
443 else if (n > 0)
444 {
445 resultType = osresult->getOtherObjectiveResultArrayType(0, i);
446 resultName = osresult->getOtherObjectiveResultName(0, i);
447#ifndef NDEBUG
448 outStr.str("");
449 outStr.clear();
450 outStr << "found objective suffix " << resultName
451 << " of type " << resultType << std::endl;
453
454 outStr.str("");
455 outStr.clear();
456 outStr << "retrieved these values:";
457 for (int m=0; m<n; m++)
458 outStr << " " << otherObj[m];
459 outStr << std::endl;
461#endif
462
463 if ( (resultType == "real")
464 || (resultType == "double")
465 || (resultType == "numeric")
466// || (resultType == "") // some versions of OSSolverService may not return a type
467 )
468 {
469 rData[iSuf] = new double[n];
470 for (int m=0; m<n; m++)
471 rData[iSuf][m] = os_strtod(otherObj[m].c_str(), NULL);
472#ifndef NDEBUG
473 outStr.str("");
474 outStr.clear();
475 outStr << "values (real): ";
476 for (int m=0; m<n; m++)
477 outStr << rData[iSuf][m] << " ";
478 outStr << std::endl << std::endl;
480#endif
481 suf_rput(resultName.c_str(), ASL_Sufkind_obj, rData[iSuf]);
482// delete [] rData; //creates a segfault...
483 }
484 else if (resultType == "integer")
485 {
486 iData[iSuf] = new int[n];
487 for (int m=0; m<n; m++)
488 iData[iSuf][m] = atoi(otherObj[m].c_str());
489#ifndef NDEBUG
490 outStr.str("");
491 outStr.clear();
492 outStr << "values (integer): ";
493 for (int m=0; m<n; m++)
494 outStr << iData[iSuf][m] << " ";
495 outStr << std::endl << std::endl;
497#endif
498 suf_iput(resultName.c_str(), ASL_Sufkind_obj, iData[iSuf]);
499// delete [] iData; //creates a segfault...
500 }
501 else
502 throw ErrorClass("otherObjectiveResult has unsupported type in OSosrl2ampl()");
503 }
504 }
505 }
506
507 // Suffixes associated with constraints
508
509 for (i=0; i < osresult->getNumberOfOtherConstraintResults(0); i++, k++)
510 {
511 if ( (osresult->optimization->solution[0]->constraints->other[i]->con != NULL) ||
513 {
514 if (numCons > 0)
515 n = osresult->getOtherConstraintResultArrayDense(0, i, otherCon, numCons);
516 else
517 n = 0;
518 if (n < 0)
519 throw ErrorClass("unspecified error in routine getOtherConstraintResultArrayDense()");
520 else if (n > 0)
521 {
523 resultName = osresult->getOtherConstraintResultName(0, i);
524#ifndef NDEBUG
525 outStr.str("");
526 outStr.clear();
527 outStr << "found constraint suffix " << resultName
528 << " of type " << resultType << std::endl;
530
531 outStr.str("");
532 outStr.clear();
533 outStr << "retrieved these values:";
534 for (int m=0; m<n; m++)
535 outStr << " " << otherCon[m];
536 outStr << std::endl;
538#endif
539
540 if ( (resultType == "real")
541 || (resultType == "double")
542 || (resultType == "numeric")
543// || (resultType == "") // some versions of OSSolverService may not return a type
544 )
545 {
546 rData[iSuf] = new double[n];
547 for (int m=0; m<n; m++)
548 rData[iSuf][m] = os_strtod(otherCon[m].c_str(), NULL);
549#ifndef NDEBUG
550 outStr.str("");
551 outStr.clear();
552 outStr << "values (real): ";
553 for (int m=0; m < n; m++)
554 outStr << rData[iSuf][m] << " ";
555 outStr << std::endl << std::endl;
557#endif
558 suf_rput(resultName.c_str(), ASL_Sufkind_con, rData[iSuf]);
559// delete [] rData; //creates a segfault...
560 }
561 else if (resultType == "integer")
562 {
563 iData[iSuf] = new int[n];
564 for (int m=0; m<n; m++)
565 iData[iSuf][m] = atoi(otherCon[m].c_str());
566#ifndef NDEBUG
567 outStr.str("");
568 outStr.clear();
569 outStr << "values (integer): ";
570 for (int m=0; m < n; m++)
571 outStr << iData[iSuf][m] << " ";
572 outStr << std::endl << std::endl;
574#endif
575 suf_iput(resultName.c_str(), ASL_Sufkind_con, iData[iSuf]);
576// delete [] iData; //creates a segfault...
577 }
578 else
579 throw ErrorClass("otherConstraintResult has unsupported type in OSosrl2ampl()");
580 }
581 }
582 }
583
584 // Basis information associated with the variables
585
586
587 // note that AMPL uses different numeric values for representing basis status:
588 // 1 = basic = ENUM_BASIS_STATUS_basic
589 // 3 = nonbasic <= (normally =) lower bound = ENUM_BASIS_STATUS_atLower
590 // 4 = nonbasic >= (normally =) upper bound = ENUM_BASIS_STATUS_atUpper
591 // 5 = nonbasic at equal lower and upper bounds = ENUM_BASIS_STATUS_atEquality
592 // 6 = nonbasic between bounds = ENUM_BASIS_STATUS_isFree
593 // 2 = superbasic = ENUM_BASIS_STATUS_superbasic
594 // 0 = no status assigned = ENUM_BASIS_STATUS_unknown
595
596 int basCode[ENUM_BASIS_STATUS_NUMBER_OF_STATES] = {1,3,4,5,6,2,0};
597 if (have_basic_var && numVars > 0)
598 {
599 iData[iSuf] = new int[numVars];
601 if (n < 0)
602 throw ErrorClass("unspecified error in routine getBasisInformationDense()");
603 else if (n > 0)
604 {
605 for (i=0; i<numVars; i++)
606 iData[iSuf][i] = basCode[iData[iSuf][i]];
607#ifndef NDEBUG
608 outStr.str("");
609 outStr.clear();
610 outStr << "primal basic: ";
611 for (int k=0; k < numVars; k++)
612 outStr << iData[iSuf][k] << " ";
613 outStr << std::endl << std::endl;
615#endif
616 suf_iput("sstatus", ASL_Sufkind_var, iData[iSuf]);
617 }
618 iSuf++;
619// delete [] iData; //creates a segfault...
620 }
621 if (have_basic_con && numCons > 0)
622 {
623 iData[iSuf] = new int[numCons];
625 if (n < 0)
626 throw ErrorClass("unspecified error in routine getBasisInformationDense()");
627 else if (n > 0)
628 {
629 for (i=0; i<numCons; i++)
630 iData[iSuf][i] = basCode[iData[iSuf][i]];
631#ifndef NDEBUG
632 outStr.str("");
633 outStr.clear();
634 outStr << "dual basic: ";
635 for (int k=0; k < numCons; k++)
636 outStr << iData[iSuf][k] << " ";
637 outStr << std::endl << std::endl;
639#endif
640 suf_iput("sstatus", ASL_Sufkind_con, iData[iSuf]);
641 iSuf++;
642// delete [] iData; //creates a segfault...
643 }
644 }
645 }
646
647 // finally set the solution status
648
649 int OS_solve_result = returnSolutionStatus(osresult->getSolutionStatusType(0));
650 switch (OS_solve_result)
651 {
653 {
654 solve_result_num = 90;
655 break;
656 }
658 {
659 solve_result_num = 50;
660 break;
661 }
663 {
664 solve_result_num = 10;
665 break;
666 }
668 {
669 solve_result_num = 110;
670 break;
671 }
673 {
674 solve_result_num = 120;
675 break;
676 }
678 {
679 solve_result_num = 200;
680 break;
681 }
683 {
684 solve_result_num = 300;
685 break;
686 }
688 {
689 solve_result_num = 500;
690 break;
691 }
693 {
694 solve_result_num = 520;
695 break;
696 }
698 {
699 solve_result_num = 550;
700 break;
701 }
702 default:
703 throw ErrorClass("Unknown solution status detected");
704 } //end of switch statement
705
706 // Produce a message to send back to AMPL
707
708 std::string solMsg;
709 std::string tmpStr;
710 tmpStr = osresult->getSolutionMessage(0);
711 if (tmpStr != "")
712 solMsg = tmpStr;
713 else
714 {
715 std::ostringstream outStr;
716 try
717 {
718 outStr << "Solution status: " << osresult->getSolutionStatusType(0) << std::endl;
720 if (tmpStr != "")
721 outStr << "Description: " << tmpStr << std::endl;
722 }
723 catch (const ErrorClass& eclass)
724 {
725 outStr << "Solution status: " << "unknown" << std::endl;
726 }
727 try
728 {
730 if (objIdx == 0) objIdx = -1;
731 double objVal = osresult-> getOptimalObjValue(objIdx,0);
732 outStr << "Objective value: " << objVal << std::endl;
733 outStr << "Objective index: " << objIdx << std::endl;
734 }
735 catch (const ErrorClass& eclass)
736 {
737 outStr << "Objective info: " << "not returned" << std::endl;
738 }
739 solMsg = outStr.str();
740 }
741
742 amplflag = 1; // to suppress a second writing of the solMsg
743
744/*
745 If we ever want to send back a non-null option info pointer (last argument of write_sol),
746 we should do this (according to David Gay):
747
748 oi->wantsol = 9;
749
750 after suitably declaring and populating
751
752 Option_Info *oi;
753 */
754
755 try
756 {
757#ifndef NDEBUG
759#endif
760 write_solf_ASL(asl, const_cast<char*>(solMsg.c_str()), x, y , NULL, solfile.c_str());
761
762#ifndef NDEBUG
764#endif
765 }
766 catch(const ErrorClass& eclass)
767 {
768#ifndef NDEBUG
770#endif
771 }
772 // garbage collection
773 if (osrlreader != NULL) delete osrlreader;
774 osrlreader = NULL;
775 if (x != NULL)
776 delete [] x;
777 x = NULL;
778 if (y != NULL)
779 delete [] y;
780 y = NULL;
781 if (otherVar != NULL)
782 delete [] otherVar;
783 otherVar = NULL;
784 if (otherObj != NULL)
785 delete [] otherObj;
786 otherObj = NULL;
787 if (otherCon != NULL)
788 delete [] otherCon;
789 otherCon = NULL;
790 if (rData != NULL)
791 {
792 for (i=0; i<nSuffixes; i++)
793 {
794 if (rData[i] != NULL) delete [] rData[i];
795 }
796 delete [] rData;
797 rData = NULL;
798 }
799 if (iData != NULL)
800 {
801 for (i=0; i<nSuffixes; i++)
802 {
803 if (iData[i] != NULL) delete [] iData[i];
804 }
805 delete [] iData;
806 iData = NULL;
807 }
808 return true;
809 }
810 catch(const ErrorClass& eclass)
811 {
812 outStr.str("");
813 outStr.clear();
814 outStr << "There was an error: " + eclass.errormsg << std::endl;
816 if (osrlreader != NULL) delete osrlreader;
817 osrlreader = NULL;
818 if (x != NULL)
819 delete [] x;
820 x = NULL;
821 if (y != NULL)
822 delete [] y;
823 y = NULL;
824 if (otherVar != NULL)
825 delete [] otherVar;
826 otherVar = NULL;
827 if (otherObj != NULL)
828 delete [] otherObj;
829 otherObj = NULL;
830 if (otherCon != NULL)
831 delete [] otherCon;
832 otherCon = NULL;
833 if (rData != NULL)
834 {
835 for (int i=0; i<nSuffixes; i++)
836 {
837 if (rData[i] != NULL) delete [] rData[i];
838 }
839 delete [] rData;
840 rData = NULL;
841 }
842 if (iData != NULL)
843 {
844 for (int i=0; i<nSuffixes; i++)
845 {
846 if (iData[i] != NULL) delete [] iData[i];
847 }
848 delete [] iData;
849 iData = NULL;
850 }
851 return false;
852 }
853 }
854}
855
const OSSmartPtr< OSOutput > osoutput
Definition OSOutput.cpp:39
double os_strtod(const char *s00, char **se)
Definition OSdtoa.cpp:2541
OtherConstraintResult ** other
a pointer to an array of other pointer objects for constraint functions
Definition OSResult.h:1879
BasisStatus * basisStatus
a pointer to a BasisStatus object
Definition OSResult.h:1874
used for throwing exceptions.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
The Result Class.
Definition OSResult.h:2549
std::string getSolutionStatusType(int solIdx)
Get the [i]th optimization solution status type, where i equals the given solution index.
std::string getOtherObjectiveResultName(int solIdx, int otherIdx)
int getNumberOfOtherConstraintResults(int solIdx)
int getOtherVariableResultArrayDense(int solIdx, int otherIdx, std::string *resultArray, int dim)
Get the values of a array or an <enumeration> associated with an <other> result for some solution.
std::string getSolutionStatusDescription(int solIdx)
Get the [i]th optimization solution status description, where i equals the given solution index.
int getObjectiveNumber()
Get objective number.
OptimizationResult * optimization
optimization holds the fifth child of the OSResult specified by the OSrL Schema.
Definition OSResult.h:2581
std::string getSolutionMessage(int solIdx)
Get the [i]th optimization solution message, where i equals the given solution index.
std::vector< IndexValuePair * > getOptimalDualVariableValues(int solIdx)
Get one solution of optimal dual variable values.
std::vector< IndexValuePair * > getOptimalPrimalVariableValues(int solIdx)
Get one solution of optimal primal variable values.
std::string getOtherConstraintResultName(int solIdx, int otherIdx)
int getBasisInformationDense(int solIdx, int object, int *resultArray, int dim)
Get the basis information associated with the variables, objectives or constraints for some solution.
int getOtherObjectiveResultArrayDense(int solIdx, int otherIdx, std::string *resultArray, int dim)
Get the values of an <obj> array or an <enumeration> associated with an <other> result for some solut...
int getSolutionNumber()
get the number of solutions.
int getSolutionTargetObjectiveIdx(int solIdx)
int getConstraintNumber()
Get constraint number.
std::string getOtherVariableResultName(int solIdx, int otherIdx)
std::string getOtherObjectiveResultArrayType(int solIdx, int otherIdx)
Get the type of values contained in the <obj> or <enumeration> array associated with an <other> resul...
int getNumberOfOtherVariableResults(int solIdx)
Get numberOfOtherVariableResult.
int getVariableNumber()
Get variable number.
int getOtherConstraintResultArrayDense(int solIdx, int otherIdx, std::string *resultArray, int dim)
Get the values of a <con> array or an <enumeration> associated with an <other> result for some soluti...
std::string getOtherConstraintResultArrayType(int solIdx, int otherIdx)
Get the type of values contained in the <con> or <enumeration> array associated with an <other> resul...
int getNumberOfOtherObjectiveResults(int solIdx)
std::string getOtherVariableResultArrayType(int solIdx, int otherIdx)
Get the type of values contained in the or <enumeration> array associated with an <other> result for...
OSosrl2ampl()
the OSosrl2ampl class constructor
bool writeSolFile(std::string osrl, ASL *asl, std::string filename)
Convert the solution to AMPL .sol format.
ASL * asl
Pointers to AMPL data structures.
Definition OSosrl2ampl.h:76
~OSosrl2ampl()
the OSosrl2ampl class destructor
The OSrLReader Class.
Definition OSrLReader.h:43
OSResult * readOSrL(const std::string &posrl)
Get an OSResult object from an OSrL string.
OtherObjectiveResult ** other
a pointer to an array of other pointer objects for objective functions
Definition OSResult.h:1555
OptimizationSolution ** solution
solution is an array of pointers to OptimizationSolution objects
Definition OSResult.h:2500
VariableSolution * variables
variables holds the solution information for the variables
Definition OSResult.h:2291
ObjectiveSolution * objectives
objectives holds the solution information for the objectives
Definition OSResult.h:2300
ConstraintSolution * constraints
constraints holds the solution information for the constraints
Definition OSResult.h:2295
OtherConResult ** con
Definition OSResult.h:1805
OtherOptionOrResultEnumeration ** enumeration
Definition OSResult.h:1814
OtherOptionOrResultEnumeration ** enumeration
Definition OSResult.h:1490
OtherObjResult ** obj
Definition OSResult.h:1481
OtherOptionOrResultEnumeration ** enumeration
Definition OSResult.h:1171
OtherVarResult ** var
Definition OSResult.h:1162
OtherVariableResult ** other
a pointer to an array of other pointer objects for variables
Definition OSResult.h:1238
BasisStatus * basisStatus
a pointer to a BasisStatus object
Definition OSResult.h:1233
@ ENUM_OUTPUT_LEVEL_debug
@ ENUM_OUTPUT_LEVEL_trace
@ ENUM_OUTPUT_LEVEL_error
int returnSolutionStatus(std::string status)
@ ENUM_SOLUTION_STATUS_bestSoFar
@ ENUM_SOLUTION_STATUS_unbounded
@ ENUM_SOLUTION_STATUS_locallyOptimal
@ ENUM_SOLUTION_STATUS_feasible
@ ENUM_SOLUTION_STATUS_other
@ ENUM_SOLUTION_STATUS_optimal
@ ENUM_SOLUTION_STATUS_error
@ ENUM_SOLUTION_STATUS_unsure
@ ENUM_SOLUTION_STATUS_infeasible
@ ENUM_SOLUTION_STATUS_globallyOptimal
@ ENUM_BASIS_STATUS_NUMBER_OF_STATES
@ ENUM_OUTPUT_AREA_OSModelInterfaces
@ ENUM_PROBLEM_COMPONENT_constraints
@ ENUM_PROBLEM_COMPONENT_variables
OSResult * osresult