Originally posted by: s.st1led
Hi everybody, I posted this issue in the CP forum, but after some further testing I found out this also applies to Cplex so it's relevant also here (and, to be fully honest, this forum looks much more active than the CP one :). At this point, I'm thinking it might be a bug. I report my further test here, even though it's basically the same as the other.
I'm using the x64 library delivered with CPLEX Optimization Studio 12.5.1 under Windows 8 x64 and Visual Studio 2012. Let's assume I have this pretty straightforward code:
// Initializes the OPL Factory and Error Handler
OplFactory.DebugMode = false;
OplFactory oplFactory = new OplFactory();
OplErrorHandler oplErrorHandler = oplFactory.CreateOplErrorHandler();
// Initializes the OPL Run Settings
OplSettings oplSettings = oplFactory.CreateOplSettings(oplErrorHandler);
oplSettings.setWithWarnings(false);
// Initializes the OPL Model
OplModelSource oplModelSource = oplFactory.CreateOplModelSource(@"model.mod");
OplModelDefinition oplModelDefinition = oplFactory.CreateOplModelDefinition(oplModelSource, oplSettings);
// Initializes the OPL Data
OplDataSource oplDataSource = oplFactory.CreateOplDataSource(@"data.dat");
// Initializes the Cplex solver
ILOG.CPLEX.Cplex cplex = oplFactory.CreateCplex();
StreamWriter streamWriter = File.CreateText(@"log.log");
TextWriter synchronizedStreamWriter = TextWriter.Synchronized(streamWriter);
cplex.SetOut(synchronizedStreamWriter);
// Instantiates the OPL Model
OplModel oplModel = oplFactory.CreateOplModel(oplModelDefinition, cplex);
oplModel.AddDataSource(oplDataSource);
// Generates the OPL Model
oplModel.Generate();
// Returns the loaded and configured OplModel
return oplModel;
When I execute it, I have the following runtime execption upon the Cplex.SetOut call:
System.OverflowException was unhandled
HResult=-2146233066
Message=Arithmetic operation resulted in an overflow.
Source=mscorlib
StackTrace:
at System.IntPtr.ToInt32()
at ILOG.Concert.Cppimpl.NotifierStream.initCppCallback()
at ILOG.Concert.Cppimpl.NotifierStream..ctor(IntPtr cPtr, Boolean cMemoryOwn)
at ILOG.Concert.Cppimpl.NotifierStream..ctor()
at ILOG.Concert.Cppimpl.DotnetToCppOutputStreamAdapter..ctor(TextWriter os)
at ILOG.CPLEX.Cplex.SetOut(TextWriter s)
at Test.Test.InitializeNewSearch() in Test.cs:line 42
at Test.Program.Main(String[] args) in Program.cs:line 14
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Am I doing something wrong? I also tried with Cplex.SetOut(Console.Out), but this same exception is thrown. Basically, every Cplex.SetOut() call (apart from Cplex.SetOut(null)) throws this exception.
Is anyone else experiencing the same thing?
Regards,
Stefano
#CPLEXOptimizers#DecisionOptimization