I faced this problem when I ran the code on Azure Synapse Analytics using Notebook.
I run this code
# Instantiate our problem class
model = pulp.LpProblem("Profit_maximising_problem", LpMaximize)
A = pulp.LpVariable('A', lowBound=0, cat='Integer')
B = pulp.LpVariable('B', lowBound=0, cat='Integer')
# Objective function
model = 30000 * A 45000 * B, "Profit"
# Constraints
model = 3 * A 4 * B <= 30
model = 5 * A 6 * B <= 60
model = 1.5 * A 3 * B <= 21
# Solve our problem
model.solve()
pulp.LpStatus[model.status]
# Print our decision variable values
print "Production of Car A = {}".format(A.varValue)
print "Production of Car B = {}".format(B.varValue)
# Print our objective function value
print pulp.value(model.objective)
I got this code from this link http://benalexkeen.com/linear-programming-with-python-and-pulp-part-3/.
So, I follow step by step but when I run model.solve() I will get the error like this.
1. com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Welcome': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (String)"Welcome to the CBC MILP Solver "; line: 1, column: 8]
2. com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'command': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (String)"command line - /home/trusted-service-user/cluster-env/env/lib/python3.8/site-packages/pulp/apis/../solverdir/cbc/linux/64/cbc /tmp/29f229eb8406409583a8333341306957-pulp.mps max timeMode elapsed branch printingOptions all solution /tmp/29f229eb8406409583a8333341306957-pulp.sol (default strategy 1)"; line: 1, column: 8]
3. com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'At': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (String)"At line 3 ROWS"; line: 1, column: 3]
4. com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'At': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (String)"At line 80 ENDATA"; line: 1, column: 3]
every time that I rerun the code I will get another error ... total 4 type as you can see.
My condition is I need to run it on azure synapse analytics using azure notebook.
- Some part of code I change before run such as add a parenthesis for print() function.
If you have any suggestion or advice please tell me.
Many thanks !
CodePudding user response:
To resolve this com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Welcome': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
error, try either of these following ways:
As suggested by pchtsp:
It seems Jackson package is trying to convert logs and throwing
JsonParseException
, passmsg=False
model.solve(PULP_CBC_CMD(msg=False))
As suggested by Imolkova:
- This issue could be because of mismatch between versions of different Jackson packages, you can refer to Troubleshoot dependency version conflicts